DeBank API Integration: DeFi Portfolio, Balances, and Caching

Integration with DeBank API for DeFi Portfolios A user logs into your DeFi dashboard and sees empty screens: balances fail to load, protocol positions are not displayed. The reason is the lack of data aggregation across different blockchains. Manually collecting balances from Aave, Uniswap, Compo

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1452
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1310
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    1005
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1270
  • image_logo-advance_0.webp
    B2B Advance company logo design
    719
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1012

Integration with DeBank API for DeFi Portfolios

A user logs into your DeFi dashboard and sees empty screens: balances fail to load, protocol positions are not displayed. The reason is the lack of data aggregation across different blockchains. Manually collecting balances from Aave, Uniswap, Compound, and other contracts on Ethereum, Arbitrum, Polygon, and BNB Chain is a task that takes weeks if not months. The DeBank API solves this with a single call: ready-made aggregated data without your own indexing infrastructure. Our experience (5+ years in Web3, 30+ DeFi portfolio integrations) shows that this saves 80% of development time for a portfolio module and reduces infrastructure costs by 10x.

How to Get a User's DeFi Portfolio?

DeBank OpenAPI provides several groups of endpoints. The most common scenario is to get all tokens and protocol positions at once. For this, use /v1/user/all_token_list and /v1/user/complex_protocol_list. A direct RPC indexer requires weekly maintenance, while DeBank delivers results in minutes.

const headers = { AccessKey: process.env.DEBANK_API_KEY } // All tokens for user on all chains const tokens = await axios.get( `https://pro-openapi.debank.com/v1/user/all_token_list?id=${userAddress}&is_all=true`, { headers } ) // Positions in a specific protocol const aavePositions = await axios.get( `https://pro-openapi.debank.com/v1/user/protocol?id=${userAddress}&protocol_id=aave3`, { headers } ) 

Data Model: What the API Returns

Each token in the response contains: chain (chain identifier), id (contract address), amount (quantity), price (current USD price), usd_value (total amount). For LP positions and protocol positions, the structure is more complex — nested objects with detail_types that describe the position type (lending, staking, vesting, etc.).

An important nuance: DeBank returns price: 0 for tokens without liquidity or with a price below the threshold. Do not interpret this as an error — it is normal for tail tokens. In such cases, we display "no price data" in the UI rather than zero.

Why DeBank Is Better Than a Custom Aggregator?

A custom indexer requires weekly maintenance, configuring RPC nodes, handling reorganizations and forks. DeBank API: 10x faster time to market and 90% cheaper to operate. Additionally, DeBank already accounts for custom tokens and complex protocols — your team doesn't spend time on reverse engineering.

How to Handle Rate Limits and Errors?

Why Is It Important to Cache DeBank Data?

DeBank Pro API rate limit is up to 300 requests per minute. For applications with hundreds of users, server-side caching is mandatory. Balance data changes rarely relative to RPC request time. A cache with TTL of 60–300 seconds suits most use cases.

Pattern: on a user data request — serve cached data immediately, trigger a background update. The user sees updated data on the next request.

async function getUserPortfolio(address: string) { const cacheKey = `portfolio:${address}` const cached = await redis.get(cacheKey) if (cached) { // Trigger background update updateInBackground(address, cacheKey) return JSON.parse(cached) } const fresh = await fetchFromDeBank(address) await redis.setex(cacheKey, 120, JSON.stringify(fresh)) return fresh } 
Caching Strategy TTL Applicability Infrastructure Cost
No cache 0 Single queries High (rate limit)
Simple TTL 60–300 s Most applications Medium
Background update 60–300 s High load Low

What to Do on Error 503?

DeBank API is an external service and may be unavailable. The application must properly handle 503, 429 (rate limit), and timeouts. On timeout — return cached data with a note about the last update time, rather than showing an empty screen. For critical functions (e.g., calculating collateral ratio for a lending product) — do not rely solely on DeBank. A fallback channel: direct RPC calls to contracts via wagmi/viem for the most important positions.

Typical Integration Mistakes

  • Ignoring ratio for LP tokens: DeBank returns the amount of LP tokens, but for valuation you need to substitute prices from the pool. Use the /v1/user/pool endpoint or external AMM prices.
  • Mixing chains: responses for chain_id=1 (Ethereum) and chain_id=137 (Polygon) may contain tokens with the same address — check the chain field.
  • Unhandled price: 0: if not filtered, zero amounts appear in the UI, misleading users.

What Is Included in Turnkey Integration

  • DeBank Pro API key setup and endpoint access
  • Server-side caching with Redis implementation
  • Error handling and RPC fallback
  • UI components: tokens, protocols, history, NFTs
  • Documentation and post-deployment support

Timeline and Cost

Basic integration (tokens + protocol positions + history) — 1-2 days. Full cycle (caching, error handling, UI) — up to 5 days. The exact cost is determined individually after project evaluation. Contact us to discuss details — our expertise in this area guarantees a reliable and scalable solution. Request integration and we will help you avoid typical mistakes.