Skip to content
Docs

Portfolio and balances

Get balance

GET /v1/balance returns the balance of one native asset or token for an address.

Endpoint

GET/v1/balance

Query

  • chainId, address (required)
  • token (optional) — token id in the chain's format (below); omit for native
  • relatedAddresses (optional) — Gram siblings
Request
curl -sS "https://blockchain.gray3.io/v1/balance?chainId=ethereum&address=0xYourAddress&token=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" \
  -H "X-Gray-Project-Id: proj_your_project_id" \
  -H "Authorization: Bearer gray_sk_your_secret"

Token ids

The token value is the same string the portfolio returns as the asset address:

  • EVM, TRON — contract address. Solana — mint. Sui, Aptos — coin type.
  • Stellar — CODE:ISSUER. XRP Ledger — CURRENCY:ISSUER (currency as returned by the ledger, 3-char or 40-hex).
  • Hedera — token id 0.0.N. Algorand — asset id. NEAR — token contract account.
  • Gram (TON) — jetton master address. Cardano — policy id + hex asset name. Stacks — token contract principal. Cosmos Hub — bank denom (ibc/…, factory/…).

On Bitcoin-family chains, Polkadot, Bittensor, Kaspa, Filecoin and Monero only the native coin is available; VeChain also returns VTHO.

Response

HTTP 200 — success envelope wraps the payload in data.

json
{
  "data": {
    "chainId": "ethereum",
    "address": "0xYourAddress",
    "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "asset": {
      "chainId": "ethereum",
      "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "symbol": "USDC",
      "name": "USD Coin",
      "decimals": 6,
      "balance": "250000000",
      "priceUsd": "1.00",
      "balanceUsd": "250.00"
    },
    "source": "indexer"
  }
}

asset is null when the token is not held (zero balance)—not an HTTP error.

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.

CodeHTTPWhen
invalid_argument400Missing or malformed chainId, address, or body fields
plan_chain_denied403chainId is not on the project plan
chain_disabled403Chain turned off in Console › Networks
unsupported_capability400Capability not offered for this chain (e.g. testnet prices)
portfolio_unavailable503Balance data is temporarily unavailable (retryable)
json
{
  "error": {
    "code": "invalid_argument",
    "message": "Human-readable detail (may be sanitized).",
    "retryable": false
  }
}