Bitcoin wallet address lookup and transaction tracking: a developer's guide
Check a Bitcoin wallet's balance, look up every address behind an xpub and track an address's transactions with the GoldRush Bitcoin API, with working code.
On this page
- What a Bitcoin wallet lookup tells you
- Before you start: API key, address or xpub, and Node.js
- Step 1: Check a Bitcoin wallet balance
- Step 2: Look up every address in an HD wallet (xpub)
- Step 3: Track a Bitcoin address's transactions
- Step 4: Page through the full history
- Handle errors from the Bitcoin API
- What a Bitcoin wallet lookup costs in credits
- Frequently asked questions
- Next steps
What a Bitcoin wallet lookup tells you
Every Bitcoin address is public. Anyone can look one up and see how much BTC it holds and every transaction that paid into it or spent from it, without the owner's private key. A wallet lookup answers three questions:
- What is this wallet's balance? The BTC an address holds now, and what it's worth.
- Which addresses belong to this wallet? Most wallets are HD (hierarchical deterministic) wallets: they derive a new address for each payment from one extended public key, the xpub. The wallet's balance is the sum over all of them.
- What moved, and when? The transaction history: each payment received or sent, its amount, its block and its fee.
Payment processors, accounting and tax tools, portfolio trackers and self-custody wallets all need these answers for many addresses at once, which is where an API beats a block explorer.
The Bitcoin API in GoldRush has an endpoint for each question. They run on one chain, btc-mainnet (chain ID 20090103):
| You want | Endpoint | Credits |
|---|---|---|
| The balance of one address | Bitcoin balance | 1 per call |
| Every address and balance behind an xpub | Bitcoin HD wallet balances | 0.1 per address |
| The balance at a past block or date | Historical Bitcoin balance | 1 per call |
| An address's transaction history | Bitcoin transaction history | 0.1 per transaction |
Before you start: API key, address or xpub, and Node.js
- A GoldRush API key in the
GOLDRUSH_API_KEYenvironment variable. Sign up for the 14-day free trial, which includes 25,000 credits. Send the key in anAuthorization: Bearerheader, never in the URL. - A Bitcoin address (legacy
1…, P2SH3…or native SegWitbc1q…), or an HD wallet's xpub. - Node.js 18 or later for the JavaScript, which uses the built-in
fetch.
Every example below shares this helper, so put the JavaScript blocks in one file, in order, and save it as bitcoin.mjs: Node then runs it as an ES module, so top-level await works (node bitcoin.mjs). GoldRush wraps each response in a data object:
const API = "https://api.covalenthq.com/v1";const headers = { Authorization: `Bearer ${process.env.GOLDRUSH_API_KEY}`,}; // Errors come back as { data: null, error: true, error_code, error_message }; a request with no// Authorization header gets an HTML 401 from the edge instead, so don't assume the body is JSON.async function get(path) { const res = await fetch(`${API}${path}`, { headers }); const body = await res.json().catch(() => null); if (!res.ok || !body || body.error) { throw new Error(`GoldRush ${body?.error_code ?? res.status}: ${body?.error_message ?? res.statusText}`); } return body.data;} // Amounts arrive as strings of satoshis (1 BTC = 100,000,000 sats). BigInt keeps them exact.function toBtc(sats) { const s = BigInt(sats); const whole = s / 100_000_000n; const frac = (s % 100_000_000n).toString().padStart(8, "0"); return `${whole}.${frac}`;}Step 1: Check a Bitcoin wallet balance
The Bitcoin balance API takes one address and returns its BTC balance with a spot price:
curl "https://api.covalenthq.com/v1/btc-mainnet/address/34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo/balances_v2/" \ -H "Authorization: Bearer $GOLDRUSH_API_KEY"Here is the data object it returned on 19 November 2026, abridged:
{ "address": "34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo", "quote_currency": "USD", "chain_name": "btc-mainnet", "chain_tip_height": 976654, "chain_tip_signed_at": "2026-11-19T23:24:51Z", "items": [ { "contract_decimals": 8, "contract_ticker_symbol": "BTC", "last_transferred_at": "2026-11-11T06:38:07.000Z", "balance": "24859759296803", "balance_24h": "24859759296803", "quote_rate": 63775.82, "quote": 15854515000 } ]}balanceis in satoshis, as a string. Divide by 10^contract_decimals(10^8) for BTC: 24,859,759,296,803 sats is 248,597.59296803 BTC.quoteis the balance's value inquote_currencyatquote_rate, the BTC price. Add?quote-currency=EUR(or GBP, JPY and others) for another currency.balance_24his the balance 24 hours earlier, so you can show the day's change.chain_tip_heightis the latest block the answer reflects.
In JavaScript:
async function getBtcBalance(address) { const data = await get(`/btc-mainnet/address/${address}/balances_v2/`); const btc = data.items[0]; return { btc: toBtc(btc.balance), usd: btc.quote, asOfBlock: data.chain_tip_height };} console.log(await getBtcBalance("34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo"));// { btc: '248597.59296803', usd: 15854515000, asOfBlock: 976654 }For the balance at a past block or date, for a year-end statement or an audit, call historical Bitcoin balance at …/historical_balances/ with block-height or date.
Step 2: Look up every address in an HD wallet (xpub)
An HD wallet app shows one balance, but its coins sit on many addresses. To see them all, pass the wallet's extended public key to the Bitcoin xpub API. It accepts an xpub, ypub or zpub and returns each active address derived from it:
// Every active address an HD wallet has derived, with its balance, from the xpub.async function getHdWallet(xpub) { const data = await get(`/btc-mainnet/address/${xpub}/hd_wallets/`); const addresses = data.items.map((item) => ({ address: item.child_address, path: item.address_path, btc: toBtc(item.balance), lastActive: item.last_transferred_at, })); const total = data.items.reduce((sum, item) => sum + BigInt(item.balance), 0n); return { total: toBtc(total), addresses };}Each item has the fields of the single-address balance, plus child_address and address_path, its derivation path from the xpub. We ran it on the first xpub in the BIP32 specification's test vectors, which is public. It returned 12 addresses that have been used on mainnet, all now empty, including this one:
{ "child_address": "12CL4K2eVqj7hQTix7dM7CVHCkpP17Pry3", "address_path": "M/0/0", "last_transferred_at": "2016-01-23T08:07:23Z", "balance": "0", "quote": 0}An xpub is read-only: it can't sign or spend. It does reveal every address and transaction in the wallet, so treat your users' xpubs as private data.
Step 3: Track a Bitcoin address's transactions
The Bitcoin transaction history API returns every transaction that touched an address, newest first. Its path is different from the balance endpoints: the address goes in the query string.
curl "https://api.covalenthq.com/v1/cq/covalent/app/bitcoin/transactions/?address=12CL4K2eVqj7hQTix7dM7CVHCkpP17Pry3&page-size=100" \ -H "Authorization: Bearer $GOLDRUSH_API_KEY"Two of the items it returned for the M/0/0 address above, the day it received 10,000 sats and spent them:
[ { "block_signed_at": "2016-01-23T08:07:23.000Z", "block_height": "394589", "tx_hash": "75A0DE262C3922BC98B93B5B942D87C7834B48E9448120998E697E111F1E7811", "type": "input", "address": "12CL4K2eVqj7hQTix7dM7CVHCkpP17Pry3", "value": "10000", "quote_rate": 389.6409999999999, "quote": 0.03896409999999999, "fees_paid": "0", "coinbase": false }, { "block_signed_at": "2016-01-23T01:22:55.000Z", "block_height": "394547", "tx_hash": "19A195D273B200976DC21F09808907F24C1C850AD7C7409992BAC67FE85E4984", "type": "output", "address": "12CL4K2eVqj7hQTix7dM7CVHCkpP17Pry3", "value": "10000", "quote_rate": 389.6409999999999, "quote": 0.03896409999999999, "fees_paid": "23000", "coinbase": false }]How to read an item:
typeisoutputwhen the transaction paid BTC to the address, andinputwhen it spent BTC from it. Bitcoin has no account balances: an address holds unspent outputs, and spending one makes it an input of a new transaction.valueis the amount in satoshis that this address received or spent in the transaction.quote_rateis the BTC price in USD on the day of the block, andquoteisvalueat that price: the historical value an accounting or tax tool needs.fees_paidis the fee of the whole transaction in satoshis, not this address's share.coinbaseistruefor a block reward paid to a miner.
To list them as received and sent rows:
// One page of an address's history, newest first.async function getBtcTransactions(address, page = 0) { const qs = new URLSearchParams({ address, "page-size": "100", "page-number": String(page) }); const data = await get(`/cq/covalent/app/bitcoin/transactions/?${qs}`); const rows = data.items.map((tx) => ({ time: tx.block_signed_at, block: Number(tx.block_height), hash: tx.tx_hash.toLowerCase(), direction: tx.type === "output" ? "received" : "sent", btc: toBtc(tx.value), usdThen: tx.quote, })); return { rows, hasMore: data.pagination.has_more };} const { rows, hasMore } = await getBtcTransactions("12CL4K2eVqj7hQTix7dM7CVHCkpP17Pry3");console.table(rows);tx_hash comes back in upper case; lower-case it to match how block explorers show hashes.
Step 4: Page through the full history
A page holds up to 100 transactions by default. While pagination.has_more is true, ask for the next page-number (pages start at 0). This totals what an address has received and sent:
async function getTotals(address) { let received = 0n; let sent = 0n; for (let page = 0; ; page++) { const qs = new URLSearchParams({ address, "page-size": "100", "page-number": String(page) }); const data = await get(`/cq/covalent/app/bitcoin/transactions/?${qs}`); for (const tx of data.items) { if (tx.type === "output") received += BigInt(tx.value); else sent += BigInt(tx.value); } if (!data.pagination.has_more) break; } return { received: toBtc(received), sent: toBtc(sent) };}To track a whole HD wallet, get its addresses from Step 2 and run this for each one. Transaction history takes single addresses only, not an xpub.
Handle errors from the Bitcoin API
A failed request returns the same envelope as a successful one, with data set to null, and get throws on it. The error handling docs show this body for a chain the API doesn't serve:
{ "data": null, "error": true, "error_message": "Chain nosuchchain-mainnet not supported.", "error_code": 501 }A 501 is a stable answer, not an outage, so retrying it unchanged returns the same error. The Bitcoin endpoints run on btc-mainnet only, and an endpoint restricted to other chains, such as an EVM-only one called with btc-mainnet, answers 501 too. A request with no Authorization header is refused by the edge proxy with an HTML 401 page rather than JSON, which is why get doesn't assume the body parses. Error responses cost no credits, so a page that fails in Step 4 can be retried from its page-number.
What a Bitcoin wallet lookup costs in credits
A balance lookup costs 1 credit per call, whatever the address holds. HD wallet balances cost 0.1 credits per address returned, and transaction history 0.1 credits per transaction returned, so a full page of 100 costs 10 credits. The pricing calculator estimates a month of calls.
Frequently asked questions
Can I look up a Bitcoin wallet without the private key?
Yes. Balances and transactions are public on the blockchain, so an address or an xpub is all a lookup needs. The private key is only needed to spend.
How do I check the balance of a wallet that uses a new address for every payment?
Look it up by its xpub (or ypub or zpub) with the HD wallet balances endpoint. It returns every active address the wallet has derived with its balance, and their sum is the wallet's balance.
Why are Bitcoin balances returned in satoshis?
A satoshi is the smallest unit of Bitcoin, and Bitcoin records every amount in whole satoshis. Divide by 100,000,000 to get BTC: 2,017,356 sats is 0.02017356 BTC.
How do I tell received and sent transactions apart?
Read each item's type. output means the transaction paid BTC to the address and input means it spent BTC from it. value is the amount in satoshis.
Can I check a Bitcoin wallet without an API?
Yes. A block explorer such as mempool.space shows any address's balance and transactions in the browser. An API is for doing it from code, for many addresses, with prices attached.
How much does a Bitcoin wallet lookup cost with GoldRush?
A balance lookup costs 1 credit per call, so the 25,000 trial credits cover 25,000 lookups. Transaction history costs 0.1 credits per transaction returned.
Next steps
- Bitcoin API: every GoldRush endpoint for Bitcoin, in one place.
- Fund Flow Tracer: trace where BTC went after a theft or scam, hop by hop across Bitcoin, EVM chains and bridges, and export the evidence an exchange or the police can act on.
- Bitcoin balance API reference: every parameter and response field.
- Bitcoin xpub API reference: HD wallet balances by xpub, ypub or zpub.
- Bitcoin transaction history reference: parameters, pagination and fields.
- Sign up for a free API key.