Make your first request
A single HTTP call confirms your subscription is active and your API key works.
curl
curl https://api.onesource.io/api/chain/network-info \
-H "Authorization: Bearer $ONESOURCE_API_KEY"
Expected response:
{
"data": {
"chain_id": "0x1",
"block_number": "0x14abcde",
"gas_price": "0x3b9aca00"
},
"error": null,
"meta": { "endpoint": "/api/chain/network-info", "request_id": "..." }
}
block_number is the live mainnet tip; it should be close to the current block reported on https://etherscan.io. To hit the Sepolia testnet instead, add ?network=sepolia to the URL (the chain_id then comes back as 0xaa36a7). See Choosing a network.
Node.js (fetch)
const res = await fetch('https://api.onesource.io/api/chain/network-info', {
headers: { Authorization: `Bearer ${process.env.ONESOURCE_API_KEY}` },
});
const { data, error } = await res.json();
if (error) throw new Error(`${error.code}: ${error.message}`);
console.log(`Chain ${parseInt(data.chain_id, 16)} at block ${parseInt(data.block_number, 16)}`);
Python (httpx)
import os, httpx
resp = httpx.get(
'https://api.onesource.io/api/chain/network-info',
headers={'Authorization': f"Bearer {os.environ['ONESOURCE_API_KEY']}"},
)
resp.raise_for_status()
body = resp.json()
print(f"Chain {int(body['data']['chain_id'], 16)} at block {int(body['data']['block_number'], 16)}")
Go
req, _ := http.NewRequest("GET", "https://api.onesource.io/api/chain/network-info", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("ONESOURCE_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil { return err }
defer resp.Body.Close()
var body struct {
Data struct{ ChainID, BlockNumber, GasPrice string } `json:"data"`
Error *struct{ Code, Message string } `json:"error"`
Meta map[string]any `json:"meta"`
}
json.NewDecoder(resp.Body).Decode(&body)
Response envelope
Every /api/* response uses the same shape:
{ "data": { ... }, "error": null, "meta": { "endpoint": "...", "request_id": "..." } }
On failure, data is null and error is an object with code and message. See Response envelope for the full reference.
What can go wrong
| Status | What it means | What to do |
|---|---|---|
401 | Missing or invalid Authorization header. | Confirm the env var is set and holds the full key you copied when you created it. If you've lost the key, create a replacement on the dashboard. |
403 | Your plan doesn't cover this endpoint (e.g. still on the Sandbox tier). | Subscribe to the Developer plan in app.onesource.io, or call the endpoint with x402 / MPP instead. |
5xx | Upstream RPC node, facilitator, or unhandled service-side issue. | Retry with exponential backoff. |
Your per-second rate limit is advisory (watch X-RateLimit-Remaining rather than waiting for a 429), but your monthly quota is enforced: once it's exhausted, calls are rejected until the next cycle. See Rate limits and quotas.
Next
- Browse the API Reference for the full endpoint catalog.
- If you're wiring this into an AI assistant, switch to the MCP server instead of raw REST.