Skip to main content

bt-network-api

A FastAPI REST service exposing Bittensor network data through the Bittensor SDK.

Features

  • Chain status and network data over HTTP
  • Mock mode for offline development and testing
  • Configurable network, host, and port
  • SQLAlchemy-powered persistent cache (SQLite by default) for query results
  • Request audit log of every API call

Endpoints

Route Description
GET / Service index
GET /health Liveness check
GET /block Current chain block number (cached)
GET /subnets All subnet info (cached)
GET /neurons/{netuid} Neurons on a subnet (cached)
GET /metagraph/{netuid} Metagraph of a subnet (cached)
GET /delegates Delegate identities (cached)
GET /staking/{address} Stake info for a coldkey address (cached)
GET /cache/history Last 20 served requests (audit log)
GET /cache/refresh Bypass notice (cache invalidation hook)

Install

pip install bt-network-api

Usage

# Install from source
uv sync --extra dev

# Run the server (defaults to 0.0.0.0:8091)
uv run bt-network-api --host 0.0.0.0 --port 8091

# Or via uvicorn (factory mode — app is created per worker)
uv run uvicorn --factory --app-dir . bt_network_api.app:create_app --host 0.0.0.0 --port 8091

Verify it is running:

curl -s http://localhost:8091/health

Configuration

Environment variables:

Variable Default Description
BT_API_NETWORK finney Bittensor network name
BT_API_MOCK 0 Use mock data (1) instead of the live chain
BT_API_DATABASE_URL sqlite:///./bt_network_api.db SQLAlchemy database URL (any DB supported)

Development

uv run ruff format --check src tests
uv run ruff check src
uv run mypy src/
uv run pytest
uv build

Metadata

Release files for bt-network-api 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bt-network-api 0.2.0
File Size Uploaded Provenance Actions
bt_network_api-0.2.0.tar.gz 9.2 kB Without provenance Details for bt_network_api-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bt-network-api 0.2.0
File Interpreter ABI Platform Actions
bt_network_api-0.2.0-py3-none-any.whl Python 3 none any Details for bt_network_api-0.2.0-py3-none-any.whl

Total release size: 17.8 kB

Release files / bt_network_api-0.2.0.tar.gz

Download URL bt_network_api-0.2.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2abe94f065817091f620371059317ec3746c11550f22587cb430dae02ae245de
BLAKE2b-256 checksum
How to use checksums
271056de96bd170f1c19d634c7e95a115e35713647188b3255065f94926a2d2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / bt_network_api-0.2.0-py3-none-any.whl

Download URL bt_network_api-0.2.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f2713198136920505a3a93e3b4847eda3dfe50903f5e81be8d32c2e14228581
BLAKE2b-256 checksum
How to use checksums
a9e48c36858d6d912153b473155bbd9c4c3618844238c403ca72805e41394c26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Security for bt-network-api 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page