- Fetch all DeFi positions (staked, deposited, LP, locked, rewards)
- Filter by position type and chain
- Group positions by protocol and calculate per-protocol totals
- Build a complete runnable DeFi dashboard
Prerequisites
- A Zerion API key (get one here)
- A wallet address to query
Steps
1
Fetch DeFi positions
Call the positions endpoint with
filter[positions]=only_complex to get only DeFi protocol positions, excluding regular wallet tokens.2
Filter by position type (optional)
Use Available position types:
filter[position_types] to narrow results to specific DeFi categories.3
Filter by chain (optional)
To get DeFi positions on specific chains only, add
filter[chain_ids].4
Full working example
Save as
defi-dashboard.mjs and run with node defi-dashboard.mjs:Response fields reference
Each DeFi position includes:Deduplicating share tokens
Many DeFi positions come with a share token in the wallet, such as an aToken, a vault share or an LP token. The position names it inreceipt: receipt.fungible_info is the share token and receipt.quantity is the amount held. The position’s own quantity and value are the underlying asset.
With filter[positions]=no_filter, Zerion API often leaves out the share token’s wallet row, but not always. To count each holding once, drop a wallet row when either is true:
- Receipt match: Its chain and contract address match the
receipt.fungible_infoof a returned position. - Not displayable:
flags.displayableisfalse.
group_id, such as the legs of a liquidity pool, can carry the same receipt. Count receipt.quantity once per group_id.
For example, on October 1, 2026, wallet address 0x9026A229b535ecF0162Dfe48fDeb3c75f7b2A7AE returned a Compound V2 deposit with a receipt of 0.2442 cETH, and a separate wallet row for the same 0.2442 cETH. Each is worth about $13. The code below drops the duplicate row.
Next steps
- Use
filter[positions]=no_filterto get DeFi and wallet positions in one call, then deduplicate share tokens - Combine with the portfolio endpoint to see total value distribution by type