Skip to content
Docs

Portfolio and balances

Get portfolio

Native and token balances for one chain and address.

Endpoint

GET/v1/portfolio

Query

  • chainId (required)
  • address (required)
  • relatedAddresses (optional) — comma-separated siblings (Gram W5 + V4R2)
Request
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.

json
{
  "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.

FieldRequiredDescription
rawAmountNoAmount in base units as an integer string
decimalsNoToken decimals. Always present for native assets
balanceNoAmount in base units, present when token metadata is known
priceUsd / balanceUsdNoUSD 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.

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_unavailable503Portfolio data is temporarily unavailable (retryable)
json
{
  "error": {
    "code": "invalid_argument",
    "message": "Human-readable detail (may be sanitized).",
    "retryable": false
  }
}