First request (direct REST)
The OneSource REST API is plain HTTPS + JSON: any HTTP client works. The same endpoint shape covers all three access paths; only the auth header changes.
curl
# Bearer API key (from app.onesource.io/signup)
curl https://api.onesource.io/api/chain/network-info \
-H "Authorization: Bearer $ONESOURCE_API_KEY"
# x402 / MPP / no auth: OneSource will return 402 with payment challenges
curl -v https://api.onesource.io/api/chain/network-info
For wallet-paid calls, a custom HTTP client handles the 402 → sign → retry loop. See x402 on Base or MPP on Tempo.
Node.js (fetch)
const res = await fetch('https://api.onesource.io/api/chain/live-balance?' + new URLSearchParams({
address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
tokens: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0xdAC17F958D2ee523a2206206994597C13D831ec7',
}), {
headers: { Authorization: `Bearer ${process.env.ONESOURCE_API_KEY}` },
});
const { data, error, meta } = await res.json();
if (error) throw new Error(`${error.code}: ${error.message}`);
console.log(`Request ${meta.request_id} cost ${meta.cost_usdc ?? 'free'} USDC`);
Python (httpx)
import os, httpx
resp = httpx.get(
'https://api.onesource.io/api/chain/erc20-balance',
params={
'account': '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'token': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
},
headers={'Authorization': f"Bearer {os.environ['ONESOURCE_API_KEY']}"},
timeout=10.0,
)
resp.raise_for_status()
body = resp.json()
if body['error']:
raise RuntimeError(body['error']['message'])
print(body['data'])
Go
req, _ := http.NewRequest("GET", "https://api.onesource.io/api/chain/tx/"+hash, 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 json.RawMessage `json:"data"`
Error *APIError `json:"error"`
Meta map[string]any `json:"meta"`
}
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return err }
if body.Error != nil { return fmt.Errorf("%s: %s", body.Error.Code, body.Error.Message) }
Choosing a network
Every /api/chain/* endpoint accepts an optional network query parameter. It defaults to ethereum (mainnet); pass network=sepolia to run the same call against the Sepolia testnet.
# Mainnet (default): the parameter can be omitted
curl "https://api.onesource.io/api/chain/network-info" \
-H "Authorization: Bearer $ONESOURCE_API_KEY"
# Sepolia testnet: add ?network=sepolia
curl "https://api.onesource.io/api/chain/network-info?network=sepolia" \
-H "Authorization: Bearer $ONESOURCE_API_KEY"
For POST endpoints, network is still a query parameter, so it goes on the URL (for example …/api/chain/call?network=sepolia), not in the JSON body. To confirm which chain a backend is on, call /api/chain/chain-id: it returns 0x1 for mainnet and 0xaa36a7 for Sepolia.
| Network | network value | EIP-155 chain id |
|---|---|---|
| Ethereum mainnet | ethereum (default) | 1 (0x1) |
| Sepolia testnet | sepolia | 11155111 (0xaa36a7) |
POST endpoints
A few endpoints accept JSON bodies, notably /api/chain/call (simulate eth_call) and /api/chain/estimate-gas:
curl -X POST https://api.onesource.io/api/chain/call \
-H "Authorization: Bearer $ONESOURCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"data": "0x18160ddd"
}'
The full request shape for each endpoint is documented in the API Reference.
Next
- Response envelope: exact shape of
data,error,meta - API Reference: all 25 endpoints