- Fetch and display a wallet’s transaction history with human-readable labels
- Filter transactions by type, chain, and date range
- Paginate through the full history
Prerequisites
- A Zerion API key (get one here)
- A wallet address to query
Steps
Use the wallet transactions endpoint to get a wallet’s history.
operation_type — the high-level action (trade, send, receive, deposit, etc.)transfers[] — individual token movements with direction (in/out/self)fee — gas fee paid, with USD valueapplication_metadata — the DApp involved (e.g., “Uniswap”, “Aave”)# Show only trades (swaps)
curl -u "YOUR_API_KEY:" \
"https://api.zerion.io/v1/wallets/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045/transactions/?currency=usd&filter[operation_types]=trade"
sendreceivetradedepositwithdrawmintburnapproveclaimexecutedeployNarrow results to specific chains or time windows. The
filter[min_mined_at] value is a Unix timestamp in milliseconds.# Ethereum transactions since Feb 26, 2024 (1708905600000 ms)
curl -u "YOUR_API_KEY:" \
"https://api.zerion.io/v1/wallets/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045/transactions/?currency=usd&filter[chain_ids]=ethereum&filter[min_mined_at]=1708905600000"
const API_KEY = process.env.ZERION_API_KEY;
const BASE_URL = "https://api.zerion.io/v1";
const headers = {
accept: "application/json",
authorization: `Basic ${btoa(API_KEY + ":")}`,
};
async function getTransactions(address, { types, chains, limit } = {}) {
const params = new URLSearchParams({ currency: "usd", "page[size]": limit || 20 });
if (types) params.set("filter[operation_types]", types);
if (chains) params.set("filter[chain_ids]", chains);
const res = await fetch(
`${BASE_URL}/wallets/${address}/transactions/?${params}`,
{ headers }
);
return res.json();
}
async function displayHistory(address) {
const { data } = await getTransactions(address, { limit: 10 });
for (const tx of data) {
const { operation_type, mined_at, transfers, fee, application_metadata } = tx.attributes;
const chain = tx.relationships.chain.data.id;
console.log(`[${mined_at}] ${operation_type} on ${chain}`);
if (application_metadata?.name) {
console.log(` via ${application_metadata.name}`);
}
for (const transfer of transfers) {
const symbol = transfer.fungible_info?.symbol || "NFT";
const dir = transfer.direction === "out" ? "-" : "+";
console.log(` ${dir}${transfer.quantity.float} ${symbol} (${transfer.value != null ? `$${transfer.value.toFixed(2)}` : "N/A"})`);
}
console.log(` Fee: ${fee.value != null ? `$${fee.value.toFixed(2)}` : "N/A"}\n`);
}
}
displayHistory("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
Next steps
- Use
filter[asset_types]=nftto show NFT transfers - Combine with the DApps endpoint to enrich
application_metadata - Build real-time alerts using the webhook recipe instead of polling