api/v2/xpub - Bitcoin

This endpoint returns wallet-level balance and transaction data for an extended public key or output descriptor. The indexer derives the wallet's addresses and returns the combined result.

Parameters

ParameterTypeLocationRequiredDescription
xpubstringpathYesThe extended public key or supported descriptor
pageintegerqueryNo1-based page index for transaction history. Default 1
pageSizeintegerqueryNoHistory items per page. Default and maximum is 1000
fromintegerqueryNoFirst block height to include when filtering history
tointegerqueryNoLast block height to include when filtering history
detailsstringqueryNoDetail level: basic, tokens, tokenBalances, txids, or txs. Default txids
tokensstringqueryNoWhich derived addresses to include: nonzero, used, or derived
gapintegerqueryNoDerivation gap limit, capped by the server
secondarystringqueryNoSecondary fiat currency code for converted values

Request

bashcurl --location --request GET 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/api/v2/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz?details=tokens&tokens=used'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/api/v2/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz?details=tokens&tokens=used'
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.get('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/api/v2/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz?details=tokens&tokens=used')

print(response.json())

Response

json{
    "page": 1,
    "totalPages": 1,
    "itemsOnPage": 1000,
    "address": "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz",
    "balance": "18452100",
    "totalReceived": "58452100",
    "totalSent": "40000000",
    "unconfirmedBalance": "0",
    "unconfirmedTxs": 0,
    "txs": 12,
    "usedTokens": 3,
    "tokens": [
        {
            "type": "XPUBAddress",
            "name": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq",
            "path": "m/44'/145'/0'/0/0",
            "transfers": 7,
            "balance": "9407625",
            "totalReceived": "45231890",
            "totalSent": "35824265"
        }
    ]
}

Response Parameters

FieldTypeDescription
balancestringCombined confirmed balance of the wallet in satoshis
totalReceivedstringCombined total received in satoshis
totalSentstringCombined total sent in satoshis
txsintegerNumber of confirmed transactions across the wallet
usedTokensintegerNumber of derived addresses that have been used
tokensarrayDerived address rows with path, balance, and transfer count

Use Cases

  • Wallet Balances: Return a full wallet balance from one xpub call
  • Address Derivation: List derived addresses without deriving them locally
  • Portfolio Trackers: Aggregate wallet activity across derived addresses
  • Gap Control: Tune the derivation gap limit for sparsely used wallets
  • Receive Flows: Find the next unused address from the derived rows

Error Handling

HTTP StatusMessageDescription
400Bad requestThe address, XPUB, or descriptor is malformed
404Not foundNo indexed data exists for the requested account
500Internal errorThe indexer failed to read account data