Skip to main content

metagraphed (Python)

Thin, dependency-free Python client for metagraphed — the operational + integration registry for Bittensor subnets at https://api.metagraph.sh.

It mirrors the npm client: one generic GET helper over the uniform, read-only API surface, returning the parsed { ok, schema_version, data, meta } envelope. Stdlib only — no transitive dependencies.

Install

pip install metagraphed              # dependency-free sync client
pip install 'metagraphed[async]'     # adds the async client (pulls httpx)

Usage

from metagraphed import MetagraphedClient, metagraphed_fetch

client = MetagraphedClient()  # base_url defaults to https://api.metagraph.sh

# List subnets (query params; None values are dropped). The /subnets collection
# nests its rows under data.subnets:
subnets = client.fetch(
    "/api/v1/subnets",
    query={"limit": 10, "sort": "completeness_score", "order": "desc"},
)
print(subnets["data"]["subnets"][0]["name"])

# One subnet by netuid (path params)
detail = client.fetch("/api/v1/subnets/{netuid}", path_params={"netuid": 7})

# Which subnets are buildable? (integration readiness lives in the agent catalog)
catalog = client.fetch("/api/v1/agent-catalog")

# Health of the registry itself:
health = metagraphed_fetch("/api/v1/health")

Every response is the standard envelope:

{"ok": True, "schema_version": 1, "data": ..., "meta": {...}}

On a network failure or non-2xx response, a MetagraphedError is raised (with .status for HTTP errors, and the API error code/message in the message).

Retries, pagination, and the RPC proxy

from metagraphed import (
    MetagraphedClient,
    metagraphed_paginate,
    metagraphed_rpc,
)

# Opt-in retry/backoff for idempotent reads — GETs *and* the read-only RPC proxy
# (retries 429/5xx + network errors, honoring a numeric Retry-After). Off by
# default.
client = MetagraphedClient(retries=3)

# Iterate every page of a list endpoint (follows meta.pagination.next_cursor):
for page in client.paginate("/api/v1/subnets", query={"limit": 100}):
    for subnet in page["data"]["subnets"]:
        print(subnet["netuid"])

# Call the read-only Subtensor RPC proxy and get back the JSON-RPC result. Via
# the client, RPC reads honor the same retries/backoff as GETs:
info = client.rpc("finney", "system_health")

# Or as a standalone call with explicit retries:
info = metagraphed_rpc("finney", "system_health", retries=3)

fetch_all + typed models

from metagraphed import MetagraphedClient

client = MetagraphedClient(retries=3)

# Auto-paginate a list endpoint and collect every item (flattened data arrays):
all_surfaces = client.fetch_all("/api/v1/surfaces")

# Typed convenience methods — IDE autocomplete, while .raw keeps the full dict:
for subnet in client.subnets():
    print(subnet.netuid, subnet.name, subnet.integration_readiness)

catalog = client.agent_catalog(7)  # -> AgentCatalogSubnet
print(catalog.service_count, catalog.services)

fetch / fetch_all still return raw dicts; the models (Subnet, Surface, Endpoint, Provider, AgentCatalogSubnet) are opt-in and never lose data.

Async client (httpx)

Install the extra (pip install 'metagraphed[async]'), then fetch many subnets concurrently — no hand-rolled threads:

import asyncio
from metagraphed import AsyncMetagraphedClient

async def main():
    async with AsyncMetagraphedClient(retries=3) as client:
        subnets = await client.subnets()  # typed, auto-paginated
        catalogs = await asyncio.gather(
            *(client.agent_catalog(s.netuid) for s in subnets[:10])
        )
        for c in catalogs:
            print(c.netuid, c.service_count)

asyncio.run(main())

The async client mirrors the sync one (fetch / paginate / fetch_all / rpc + retries/backoff) and reuses a single connection pool.

Versioning & stability

Tracks the public /api/v1 contract; changes are additive within v1. See the backend's API stability policy.

License

Apache-2.0 — see LICENSE. (The metagraphed backend itself is AGPL-3.0; this client SDK is permissively licensed so you can embed it freely.)

Release files for metagraphed 0.4.1

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

Source distribution (sdist)

Source distribution for metagraphed 0.4.1
File Size Uploaded
metagraphed-0.4.1.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metagraphed 0.4.1
File Interpreter ABI Platform
metagraphed-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / metagraphed-0.4.1.tar.gz

Download URL metagraphed-0.4.1.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b2676a4e7de9aa0c91203fb4bb841a809adee77863257a5350e9631d69c7a827
BLAKE2b-256 checksum
How to use checksums
7629c1c3060437a85c8119b96b4690c07969b08328bbc8b68b5a8dd437afeb16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / metagraphed-0.4.1-py3-none-any.whl

Download URL metagraphed-0.4.1-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2efa294c4f432c13bbe25f7e3fbfb5eeb7c2f79da75e978687a22ff55406dfbf
BLAKE2b-256 checksum
How to use checksums
f1ae5c5a3228f239b631a0d83d1db6d7720ce90f8d53d0555532b413ce67640f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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