Docs

subnetInfo_getAllMetagraphs - Bittensor RPC Method

Retrieve SCALE-encoded metagraphs for all Bittensor subnets in a single call. Essential for network-wide analytics, cross-subnet comparisons, and global monitoring dashboards.

Overview

The subnetInfo_getAllMetagraphs method returns the SCALE-encoded metagraphs for every active subnet on the Bittensor network in a single RPC call. This is the bulk equivalent of calling subnetInfo_getMetagraph for each netuid individually.

Each metagraph contains the complete topology of a subnet: all registered neurons, their stakes, trust scores, incentive values, weight matrices, emission distributions, and axon endpoints. By fetching all metagraphs at once, you can efficiently perform cross-subnet analysis and build network-wide monitoring dashboards.

Note: This method returns a large payload since it includes metagraph data for every active subnet. Expect response sizes in the range of several megabytes for networks with many subnets. Consider using subnetInfo_getMetagraph for targeted single-subnet queries when you only need specific data.

Parameters

PositionNameTypeRequiredDescription
0atBlockHashNoOptional block hash to query at a specific block. Pass null for the latest state

Response

The result is a JSON array of SCALE bytes. When decoded, it returns a vector of metagraph structures, one per active subnet. Each metagraph contains:

FieldTypeDescription
netuidu16The subnet identifier
nu16Number of neurons registered
blocku64Block number at capture time
hotkeysVec<AccountId32>Hotkey addresses for every neuron
coldkeysVec<AccountId32>Coldkey (owner) addresses
stakeVec<u64>Total stake per neuron (RAO). Divide by 1e9 for TAO
trustVec<u16>Trust scores (0--65535 scaled)
consensusVec<u16>Consensus scores (0--65535 scaled)
incentiveVec<u16>Incentive scores (0--65535 scaled)
dividendsVec<u16>Dividend scores (0--65535 scaled)
emissionVec<u64>Emissions per neuron per tempo (RAO)
validator_permitVec<bool>Validator permit flags
activeVec<bool>Active neuron flags
weightsVec<Vec<(u16, u16)>>Weight matrix (sparse: uid, weight pairs)
bondsVec<Vec<(u16, u16)>>Bond matrix (sparse: uid, bond pairs)
axonsVec<AxonInfo>Network endpoint info (IP, port, protocol)

SCALE Decoding

The response decodes to Vec<MetagraphInfo>, where each MetagraphInfo contains the fields above. Due to the size of this response, decoding can be computationally intensive.

Using @polkadot/api: Register all Bittensor types including MetagraphInfo and AxonInfo before calling. The decoded result is an array that can be iterated. Each element has the same structure as the single subnetInfo_getMetagraph response.

Using bittensor Python SDK: There is no single SDK call that returns all metagraphs at once. Instead, iterate over subnet netuids: for netuid in sub.get_all_subnet_netuids(): meta = sub.metagraph(netuid=netuid). For the raw RPC approach, decode Vec<MetagraphInfo> using the Bittensor type registry.

Performance notes:

  • The total payload can exceed 10 MB for networks with 30+ active subnets
  • Decoding time scales linearly with the number of subnets and neurons
  • Consider processing the response in a background thread to avoid blocking your main application
  • Cache the result and refresh at a cadence appropriate for your use case (once per tempo or less frequently)

Code Examples

Using SubstrateExamples

Decode with Python

Python
import requests
import json

url = 'https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY'

payload = {
    'jsonrpc': '2.0',
    'method': 'subnetInfo_getAllMetagraphs',
    'params': [None],
    'id': 1
}

response = requests.post(url, json=payload, timeout=60)
result = response.json()

if result.get('result'):
    scale_bytes = result['result']
    print(f'All metagraphs SCALE data size: {len(scale_bytes)} bytes')
    print(f'Approximate size: {len(scale_bytes) // 2 / 1024:.1f} KB')
else:
    print('No metagraphs returned')

# To decode with bittensor SDK:
# import bittensor as bt
# sub = bt.subtensor(network='finney')
# for netuid in sub.get_all_subnet_netuids():
#     meta = sub.metagraph(netuid=netuid)
#     print(f"Subnet {netuid}: {meta.n} neurons, emissions: {meta.E.sum():.4f}")

Full Python cross-subnet analysis

Python
import bittensor as bt
import numpy as np

sub = bt.subtensor(network='finney')
netuids = sub.get_all_subnet_netuids()

print(f"{'Netuid':>6} {'Neurons':>8} {'Validators':>11} {'Total Stake':>15} {'Emissions':>12} {'Avg Trust':>10}")
print("-" * 66)

total_neurons = 0
total_stake = 0

for netuid in netuids:
    try:
        meta = sub.metagraph(netuid=netuid)
        n_validators = sum(meta.validator_permit)
        total_s = meta.S.sum()
        total_e = meta.E.sum()
        avg_trust = meta.T.mean()

        total_neurons += meta.n
        total_stake += total_s

        print(f"{netuid:>6} {meta.n:>8} {n_validators:>11} {total_s:>14,.2f} {total_e:>11,.4f} {avg_trust:>9,.4f}")
    except Exception as e:
        print(f"{netuid:>6} Error: {e}")

print("-" * 66)
print(f"Total neurons: {total_neurons}, Total stake: {total_stake:,.2f} TAO")

# Find hotkeys registered on multiple subnets
hotkey_subnets = {}
for netuid in netuids:
    meta = sub.metagraph(netuid=netuid)
    for uid in range(meta.n):
        hk = meta.hotkeys[uid]
        hotkey_subnets.setdefault(hk, []).append(netuid)

multi_subnet = {k: v for k, v in hotkey_subnets.items() if len(v) > 1}
print(f"\nHotkeys on multiple subnets: {len(multi_subnet)}")
for hk, nets in sorted(multi_subnet.items(), key=lambda x: len(x[1]), reverse=True)[:5]:
    print(f"  {hk[:18]}.. on subnets: {nets}")

Decode with JavaScript

JavaScript
import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

const allMetagraphs = await api.rpc.subnetInfo.getAllMetagraphs();
console.log('Raw data size:', allMetagraphs.toHex().length, 'bytes');

// With Bittensor type definitions registered, iterate decoded metagraphs
// for (const meta of allMetagraphs) {
//   console.log(`Subnet ${meta.netuid}: ${meta.n} neurons`);
// }

await api.disconnect();

Error Handling

Error ScenarioBehaviorRecommended Action
Response too largeConnection may timeout or dropIncrease HTTP/WebSocket timeout to 60+ seconds
Node memory limitsNode may reject the requestFall back to individual getMetagraph calls per subnet
Node not syncedReturns partial or stale dataCheck system_health before making bulk queries
Invalid block hashReturns JSON-RPC errorVerify the block hash exists on chain
Rate limit exceededHTTP 429Cache results aggressively; this data changes slowly

Best practices:

  • Set an HTTP timeout of at least 60 seconds for this call
  • Process the response asynchronously to avoid blocking your application
  • Cache the result and refresh only when needed (e.g., every 5--10 minutes)
  • If you only need a few subnets, prefer subnetInfo_getMetagraph with specific netuids

Common Use Cases

  • Network-wide analytics — Build dashboards that aggregate neuron counts, total stake, emission distributions, and health metrics across all subnets.
  • Cross-subnet comparisons — Compare validator performance, miner incentive scores, and consensus quality between subnets.
  • Global monitoring — Track network growth by monitoring how many neurons are registered across all subnets over time.
  • Emission analysis — Visualize how TAO emissions are distributed across subnets and identify which subnets receive the most rewards.
  • Research — Study the global network topology and how different subnet configurations affect incentive dynamics.
  • Multi-subnet operators — Monitor all your neurons across subnets in a single query instead of making individual calls.