Bittensor RPC Usage
Use this guide for direct JSON-RPC requests to Bittensor through the FlameWire gateway.
Endpoint Formats
HTTP
Authenticated:
https://gateway-dev.flamewire.io/public/rpc/bittensor/{api-key}Public (free-tier):
https://gateway-dev.flamewire.io/public/rpc/bittensorWebSocket
Authenticated:
wss://gateway-dev.flamewire.io/public/rpc/bittensor/{api-key}Public (free-tier):
wss://gateway-dev.flamewire.io/public/rpc/bittensorQuick Start (HTTP)
curl -X POST https://gateway-dev.flamewire.io/public/rpc/bittensor/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "system_health",
"params": []
}'JavaScript Example
async function callRpc(method, params = []) {
const response = await fetch(
"https://gateway-dev.flamewire.io/public/rpc/bittensor/YOUR_API_KEY",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: Date.now(),
method,
params,
}),
}
);
if (!response.ok) {
throw new Error(`RPC request failed: ${response.status}`);
}
return response.json();
}
callRpc("chain_getHeader").then(console.log).catch(console.error);Quick Start (WebSocket)
Install the WebSocket client:
npm install wsconst WebSocket = require("ws");
const ws = new WebSocket(
"wss://gateway-dev.flamewire.io/public/rpc/bittensor/YOUR_API_KEY"
);
ws.on("open", () => {
ws.send(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "chain_subscribeNewHeads",
params: [],
}));
});
ws.on("message", (message) => {
console.log("RPC response:", message.toString());
});
ws.on("error", (error) => {
console.error("WebSocket error:", error.message);
});Common Methods
| Method | Use Case |
|---|---|
system_health | Node/service health checks |
chain_getHeader | Latest block header |
state_getStorage | Read on-chain storage keys |
chain_subscribeNewHeads | Subscribe to new block headers |
Production Tips
- Use API keys for stable quotas and billing visibility
- Add retries with backoff for transient gateway/network failures
- Use WebSocket subscriptions for real-time flows instead of tight polling loops
- Validate JSON-RPC errors and handle non-200 HTTP responses explicitly
Using MCP and RPC Together
Use MCP for discovery and fast scaffolding, then move high-throughput production paths to direct RPC modules.