Introduction
The Market Price API provides real-time and historical market data for decentralized exchanges (DEX). This comprehensive guide covers all available endpoints, usage examples, and error handling for seamless integration.
Core Features
- Real-time token prices
- Historical trade data
- Candlestick chart data
- Multi-chain support
Market Price API Endpoints
Get Supported Chains
Retrieve a list of all supported blockchain networks and their configurations.
**Endpoint**: `/api/v1/chains`
**Method**: GET
**Response**:{
"chains": [
{
"chainId": 1,
"name": "Ethereum",
"isActive": true
}]
}
### Get Token Price
Fetch the latest price for a specified token.
Endpoint: /api/v1/price
Parameters:
token: (Required) Token contract addresschainId: (Required) Blockchain network ID### Get Trades Retrieve recent transaction data for any token.Endpoint:
/api/v1/trades
Parameters:token: (Required) Token contract addresslimit: (Optional) Number of trades to return (default: 100)
## Advanced Features
### Candlestick Data
Access formatted price history with multiple time intervals:
1. 1-minute
2. 5-minute
3. 15-minute
4. 1-hour
5. 4-hour
6. 1-day
๐ [View candlestick documentation](https://www.okx.com/join/BLOCKSTAR)
## Error Handling
Common error codes:
| Code | Description |
|------|-------------|
| 400 | Invalid request parameters |
| 404 | Resource not found |
| 500 | Internal server error |
## FAQ Section
**Q: How frequently is price data updated?**
A: Prices update in real-time, with new data available every block confirmation.
**Q: What's the maximum historical data available?**
A: We maintain 2 years of historical trade data for all supported tokens.
**Q: Are there rate limits?**
A: Yes, the API allows 100 requests per minute per IP address.
## Implementation Tips
For optimal performance:
- Cache frequent responses
- Use WebSocket connections for real-time updates
- Implement exponential backoff for error retries
## Key Benefits
1. **Multi-chain support**: Access data across 15+ blockchains
2. **High reliability**: 99.9% uptime guarantee
3. **Enterprise-grade**: Scalable for high-volume applications