Portfolio and balances
Get portfolio
Native and token balances for one chain and address.
Endpoint
Query
chainId(required)address(required)relatedAddresses(optional) — comma-separated siblings (Gram W5 + V4R2)
curl -sS "https://blockchain.gray3.io/v1/portfolio?chainId=ethereum&address=0xYourAddress" \
-H "X-Gray-Project-Id: proj_your_project_id" \
-H "Authorization: Bearer gray_sk_your_secret"Response
HTTP 200 — success envelope wraps the payload in data.
{
"data": {
"chainId": "ethereum",
"address": "0xYourAddress",
"assets": [
{
"chainId": "ethereum",
"address": "native",
"symbol": "ETH",
"name": "Ether",
"decimals": 18,
"balance": "1500000000000000000",
"rawAmount": "1500000000000000000",
"priceUsd": "3200.12",
"balanceUsd": "4800.18"
},
{
"chainId": "ethereum",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"symbol": "USDC",
"name": "USD Coin",
"decimals": 6,
"balance": "250000000",
"rawAmount": "250000000",
"priceUsd": "1.00",
"balanceUsd": "250.00"
}
],
"source": "indexer"
}
}rawAmount is the holding in base units as an integer string. decimals and balance are optional: tokens without metadata return only rawAmount, so fall back to it (and hide the token or show a raw value) when decimals is missing. Native assets always include decimals. priceUsd and balanceUsd appear on mainnet when prices are available. Testnet portfolios usually contain balances only.
| Field | Required | Description |
|---|---|---|
| rawAmount | No | Amount in base units as an integer string |
| decimals | No | Token decimals. Always present for native assets |
| balance | No | Amount in base units, present when token metadata is known |
| priceUsd / balanceUsd | No | USD values when prices are available |
Base your arithmetic on rawAmount when it is present.
Errors
Errors use HTTP { "error": { "code", "message", "retryable" } }. Branch on code, not the message text.
Every authenticated route may also return unauthorized (401), revoked_secret (401), forbidden (403), credits_exhausted (402), plan_feature_denied (403), rate_limit_exceeded (429, retryable), and invalid_argument (413) for request bodies over 256 KiB.
| Code | HTTP | When |
|---|---|---|
| invalid_argument | 400 | Missing or malformed chainId, address, or body fields |
| plan_chain_denied | 403 | chainId is not on the project plan |
| chain_disabled | 403 | Chain turned off in Console › Networks |
| unsupported_capability | 400 | Capability not offered for this chain (e.g. testnet prices) |
| portfolio_unavailable | 503 | Portfolio data is temporarily unavailable (retryable) |
{
"error": {
"code": "invalid_argument",
"message": "Human-readable detail (may be sanitized).",
"retryable": false
}
}