Subtensor API package for bittensor
Project description
Subtensor API Python package
A python wrapper around the @polkadot/api
node library to query the bittensor chain.
Install from pypi
pip install subtensorapi==0.1.4
Running the CLI
Usage
View usage
python3 -m subtensorapi --help
Specify chain endpoint url
python3 -m subtensorapi [sync_and_save|blockAtReg_and_save] --endpoint_url ENDPOINT_URL
Specify filename to save to
python3 -m subtensorapi [sync_and_save|blockAtReg_and_save] --filename FILENAME.json
Specify blockhash to sync the chain at, default "latest"
python3 -m subtensorapi [sync_and_save|blockAtReg_and_save] --block_hash BLOCK_HASH
Sync And Save Metagraph
Pulls the neurons
storage map and saves it to a JSON file.
View usage
python3 -m subtensorapi sync_and_save --help
Run sync of metagraph and save to JSON file
python3 -m subtensorapi sync_and_save
Grab blockAtRegistration
Pulls the blockAtRegistration
storage map and saves it to a JSON file.
View usage
python3 -m subtensorapi blockAtReg_and_save --help
Using the library
FastSync class
Setup of a FastSync instance
from subtensorapi import FastSync
# check if fast sync is available on the platform
FastSync.verify_fast_sync_support()
# specify the chain endpoint_url
fast_sync: FastSync = FastSync(endpoint_url)
Run the metagraph sync
Pulls the neurons
storage map.
# specify block_hash to sync at. Default is "latest"
block_hash = "0xb2fa081[...]"
# run the sync command and save to JSON file at block_hash
fast_sync.sync_and_save(rich.Console(), block_hash)
# load neurons in from JSON file
neurons = fast_sync.load_neurons()
Run blockAtRegistration pull
Pulls the blockAtRegistration
storage map.
# specify block_hash to sync at. Default is "latest"
block_hash = "0xb2fa081[...]"
# run the pull command and save to JSON file at block_hash
fast_sync.get_blockAtRegistration_for_all_and_save(rich.Console(), block_hash)
# load blockAtRegistration_all from JSON file
blockAtRegistration_all = fast_sync.load_blockAtRegistration_for_all()
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 Distributions
Built Distributions
Hashes for subtensorapi-0.2.2-py3-none-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 128e642fc00c901ff6e2253e3a943ae6e470f32fdb9cd24ab7d4ea27c7bfed11 |
|
MD5 | 57bf32c91eaec229c23db034b05d6b95 |
|
BLAKE2b-256 | a325c547e8ba767bffab3f41c315a1de9c004cd25a0c6bf2df24ee63d8a3539f |
Hashes for subtensorapi-0.2.2-py3-none-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d0fdc7e04cd368603199538f4ec9bfc27344cbae2162e7f5117cfbc511f86e2 |
|
MD5 | 82cc9d04788cd463c91e7e54ce3b7e56 |
|
BLAKE2b-256 | 18d03dcb553d36b521fbf8c537c42b3050f3f3a443f038d5499a2c99ae93edd2 |