One wallet's swaps and PnL
const url = 'https://api.getchord.xyz/v1/chains/avalanche/wallet/example';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.getchord.xyz/v1/chains/avalanche/wallet/exampleA wallet’s swaps on the chain and an average-cost PnL over them. The window is short: the database keeps the raw tape for a few days on these chains (about 3 on BNB Chain and Base, 7 on Avalanche today), and older days come from Chord’s data lake only where its days run without a gap up to that window. window says how far back the numbers go and history where they came from (raw, raw+lake, or raw (lake unavailable)). Say so when you show the number.
- A buy adds tokens and cost; a sell realizes proceeds minus the average cost of the part the window saw bought.
- A sell with nothing bought in the window has no cost basis: it is counted in
soldWithoutBasisUsd, never as profit. holdsTokensis bought minus sold inside the window, priced at the token’s last hourly print. It is not the on-chain balance (transfers are not swaps).- Trades under the chain’s ingest floor are not in the tape (BNB Chain: $100).
- Past 5,000 swaps in the window the newest 5,000 are kept and
truncatedis true (a bot or a router).
Chain-keyed data for Avalanche C-Chain, Base and BNB Chain, served from Chord’s rollup tables for the chain (every swap summed by hour, token and venue). Only the trade tape, the prints ticker and the wallet read raw rows, scoped to one token or one wallet and bounded.
- Access. No key needed while the chain is public (all three are today). A chain whose tape is off, or that is not public yet, answers
400 UNSUPPORTED_CHAIN(“chain N is not served yet”) unless the request carries anX-API-Key; those answers are sentCache-Control: private. - Ingest floor. Every count, volume and print covers trades at or above the chain’s floor, returned as
ingestFloor. BNB Chain runs at $100 today; Avalanche and Base at 0. - Readiness.
503 NOT_READYuntil the chain’s rollup has run on this deployment;503 CHAIN_DATA_UNAVAILABLEwhen the store cannot be read. Never treat either as “no trades”.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”The chain, by key or id: avalanche or 43114, base or 8453, bnb or 56, arbitrum or 42161, ethereum or 1 (case-insensitive). Arc, Robinhood Chain and Monad are refused with 400 UNSUPPORTED_CHAIN and a pointer to their own routes.
EVM address, hex, case-insensitive.
Wallet address.
Responses
Section titled “ Responses ”object
EVM address, hex, case-insensitive.
The span the numbers cover. fromTs null = no trades indexed for the wallet.
object
Unix time, seconds, UTC.
Unix time, seconds, UTC.
Where the window’s rows came from.
Swaps in the window.
More than 5,000 swaps in the window: only the newest 5,000 are counted.
Sell proceeds with no buy in the window to match. Not profit.
Largest absolute PnL first.
object
EVM address, hex, case-insensitive.
Bought minus sold in the window, whole tokens.
Average cost per token of what is still held.
Last hourly print within 7 days.
Last 25 swaps, newest first.
object
Unix time, seconds, UTC.
Transaction hash.
EVM address, hex, case-insensitive.
The tape’s ingest floor. BNB Chain runs at $100 today; Avalanche and Base at 0.
object
Trades under this USD value (at index time) are not in the index, so every count, volume and candle covers trades at or above it. 0 = every priced trade.
Floors in force over time, oldest first. Empty when the chain was never floored. Raising a floor does not remove older, smaller rows.
object
Floor in force.
Unix time, seconds, UTC.
Unix time, milliseconds — when the server built this answer.
Example
{ "chain": 56, "wallet": "0x34135a8b5cc02d1b579789fb09dd9cec4f8d7c13", "window": { "fromTs": 1790726400, "toTs": 1791021452, "days": 3 }, "history": "raw", "trades": 438, "truncated": false, "realizedUsd": -52.50256178614943, "unrealizedUsd": 264.3511103300407, "totalUsd": 211.84854854389124, "volumeUsd": 1074760.992352269, "soldWithoutBasisUsd": 142196.1744304485, "tokens": [ { "token": "0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c", "symbol": "BTCB", "buys": 82, "sells": 88, "boughtUsd": 232801.99929077973, "soldUsd": 268637.2602480728, "realizedUsd": 332.35056120683566, "unrealizedUsd": 322.78762778211967, "totalUsd": 655.1381889889553, "holdsTokens": 0.48237177905003725, "holdsUsd": 40925.42133609123, "avgCostUsd": 84172.90453490094, "lastPriceUsd": 84842.07226361385, "soldWithoutBasisUsd": 76105.54410439507 }, { "token": "0x2170ed0880ac9a755fd29b2688956bd959f933f8", "symbol": "ETH", "buys": 92, "sells": 96, "boughtUsd": 179038.3807585184, "soldUsd": 167683.46997452437, "realizedUsd": -421.56179009490035, "unrealizedUsd": -58.43651745207899, "totalUsd": -479.99830754697933, "holdsTokens": 14.799424875074559, "holdsUsd": 39691.36613138376, "avgCostUsd": 2685.901849860607, "lastPriceUsd": 2681.9532830787653, "soldWithoutBasisUsd": 28816.45365493667 } ], "recent": [ { "ts": 1791021243, "tx": "0xfacfd422253d675c6f886afffeb849d5a4f50c38cb0a3a5979b73473dd5b4273", "logIndex": 31, "token": "0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c", "side": "buy", "tokenAmt": 0.007796979293366881, "usd": 661.4196898072091, "priceUsd": 84830.24834629204, "dex": "pancake_v3", "symbol": "BTCB" }, { "ts": 1791016125, "tx": "0x06ac8ef3af4d007c08c7a9ca9e7ab666a724e1393c21865fe1d70d7c5825c19b", "logIndex": 76, "token": "0x2170ed0880ac9a755fd29b2688956bd959f933f8", "side": "sell", "tokenAmt": 0.1525057769098823, "usd": 408.73262726748277, "priceUsd": 2680.1124229478096, "dex": "pancake_v3", "symbol": "ETH" } ], "ingestFloor": { "minTradeUsd": 100, "history": [ { "usd": 100, "fromTs": 1790789196 } ] }, "updatedAt": 1791021452229}UNSUPPORTED_CHAIN (unknown chain, a chain with its own routes, or a chain not served to this caller yet), or BAD_ADDRESS.
Every non-2xx body.
object
Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.
For humans.
HTTP status, when included.
Example
{ "error": "INVALID_PARAMS", "message": "amount must be an integer string in the token's smallest unit"}Over the per-minute limit (RATE_LIMIT_EXCEEDED). Read X-RateLimit-Reset and back off.
Every non-2xx body.
object
Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.
For humans.
HTTP status, when included.
Example
{ "error": "INVALID_PARAMS", "message": "amount must be an integer string in the token's smallest unit"}CHAIN_DATA_UNAVAILABLE: the store could not be read. Retry later; do not treat it as an empty answer.
Every non-2xx body.
object
Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.
For humans.
HTTP status, when included.
Example
{ "error": "INVALID_PARAMS", "message": "amount must be an integer string in the token's smallest unit"}