A Python client for Substrate telemetry.
Project description
Substrate telemetry client
A Python client for Substrate's telemetry backend, providing real-time access to node data from chains like Polkadot and Kusama. It offers both synchronous and asynchronous interfaces.
Quick start
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install the package in editable mode:
pip install -e .
-
Run the example script:
python3 examples/basic_usage.py
Usage
This client can be used in two ways: synchronously or asynchronously.
TelemetryClient
The TelemetryClient provides a simple, blocking interface that runs network communication in a background thread.
import time
from substrate_telemetry_client import TelemetryClient, ChainGenesis
with TelemetryClient(chain=ChainGenesis.POLKADOT) as client:
# Some time for data to arrive
time.sleep(5)
nodes = client.get_nodes()
if nodes:
print(nodes[0])
AsyncTelemetryClient
The AsyncTelemetryClient is designed for asyncio-based applications.
import asyncio
from substrate_telemetry_client import AsyncTelemetryClient, ChainGenesis
async def main():
client = AsyncTelemetryClient(chain=ChainGenesis.KUSAMA)
connect_task = asyncio.create_task(client.connect())
# ... use client methods ...
await client.disconnect()
For runnable examples demonstrating usage, please see the scripts in the examples/ directory.
Data structures
The client returns data in dataclasses like NodeInfo and ChainStats.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file substrate_telemetry_client-0.1.1.tar.gz.
File metadata
- Download URL: substrate_telemetry_client-0.1.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a06074acfc7a4786204ecaa0fceaef7d408f5610c10eb00d12bb052fb7f2ca47
|
|
| MD5 |
0c2714432a6c6ac974b3bbe1347a5cd4
|
|
| BLAKE2b-256 |
91a9aeec1ede28d22ba49ef9c551440b7f8222d2eed29e30a6df754a3125fbc6
|
File details
Details for the file substrate_telemetry_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: substrate_telemetry_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d01f77acc36717e114eedbd105e4879b1c249d496af7157a391f5d05aeabede
|
|
| MD5 |
02d4a500d29aaad2f0630001f48707ee
|
|
| BLAKE2b-256 |
306423fe7d19c26eec73235d8135b133dd9d852d4d436fd5fbf3e40e1c2909f0
|