Overview
The Total Value API allows developers to retrieve comprehensive asset valuations for Web3 wallets, including tokens and DeFi positions. This powerful tool helps users track their entire portfolio value while filtering out unwanted assets like spam tokens.
Total Value API Endpoint
Request URL
GET `https://web3.okx.com/api/v5/wallet/asset/total-value`Key Features
- Complete portfolio valuation in USD
- Chain-specific filtering capabilities
- Asset type segmentation (tokens vs. DeFi)
- Spam token exclusion
API Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
accountId | String | Yes | Unique account identifier |
chains | String | No | Comma-separated chain filters (max 50) |
assetType | String | No | Asset filter: 0=All, 1=Tokens only, 2=DeFi only |
excludeRiskToken | Boolean | No | Filters risky airdrop tokens (default: true) |
Response Structure
| Field | Type | Description |
|---|---|---|
totalValue | String | USD-denominated total asset value |
Implementation Example
curl --location --request GET 'https://web3.okx.com/api/v5/wallet/asset/total-value?accountId=e7dba4c2-666d-496a-ad92-768d29291fee&chains=' \
--header 'OK-ACCESS-PROJECT: 86af********d1bc' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'Sample Response
{
"code": "0",
"msg": "success",
"data": [
{
"totalValue": "1172.895057177065864522056725546579939398"
}
]
}Frequently Asked Questions
What types of assets does the Total Value API include?
The API calculates valuations for both fungible tokens and DeFi protocol positions across supported blockchains.
How often should I call this API for portfolio updates?
For most applications, polling every 5-15 minutes provides adequate refresh rates without exceeding rate limits.
Can I filter valuations by specific chains?
Yes, the chains parameter accepts comma-separated chain identifiers to scope valuation calculations.
Why would my total value fluctuate between calls?
Valuations change with market prices and network conditions. Large swings may indicate oracle updates or protocol activity.
How does the spam filter work?
Our risk engine identifies known scam tokens and questionable airdrops, excluding them from calculations when enabled.
Best Practices for Wallet Valuation Integration
- Cache Responses: Store valuation data locally to reduce API calls
- Error Handling: Implement retry logic for temporary failures
- User Education: Explain valuation methodologies to end users
- Performance Monitoring: Track API latency and success rates
For advanced wallet functionality, consider our complete 👉 Web3 API Suite.