API Integration
Configure CoinGecko API and other data sources for cryptocurrency data.
CoinGecko API
CoinTrail uses CoinGecko as the primary data source for cryptocurrency prices, market data, and coin information.
API Plans
| Plan | Monthly Calls | Rate Limit | API Key Required |
|---|---|---|---|
| Demo (Free) | 10,000 | 30 calls/min | Optional |
| Analyst | 500,000 | 500 calls/min | Yes |
| Pro | Unlimited | 1,000 calls/min | Yes |
CoinGecko API plans dashboard - choose based on your traffic requirements
CoinTrail's tiered update system is designed to work within CoinGecko's free tier limits (10,000 calls/month).
Configuration
Configure your CoinGecko API settings in the admin panel or .env file:
# CoinGecko API Configuration
COINGECKO_API_KEY=your-api-key-here
COINGECKO_API_TYPE=demo
# API Types: demo, pro
# demo = Free tier (api.coingecko.com)
# pro = Paid tier (pro-api.coingecko.com)
Or configure via Admin Panel → Settings → API Settings.
Admin panel API settings - configure your CoinGecko API key and type
Tiered Update System
CoinTrail implements a smart tiered update system to optimize API usage while keeping popular coins updated frequently.
| Tier | Coins | Update Interval | API Calls/Day |
|---|---|---|---|
| Top Tier | 1-100 (by market cap) | Every 5 minutes | ~288 |
| Mid Tier | 101-500 | Every 15 minutes | ~96 |
| Low Tier | 501-1000 | Every 30 minutes | ~48 |
| Rare Tier | 1001+ | Every 60 minutes | ~24 |
Total estimated daily calls: ~450 (well within free tier limits)
Rate limit configuration - adjust update intervals for each tier in admin settings
Adjusting Update Intervals
You can customize update intervals in Admin → Settings → API Settings, or modify the configuration:
return [
'update_intervals' => [
'top' => 5, // minutes
'mid' => 15, // minutes
'low' => 30, // minutes
'rare' => 60, // minutes
],
'tier_ranges' => [
'top' => [1, 100],
'mid' => [101, 500],
'low' => [501, 1000],
'rare' => [1001, null],
],
];
Data Fetched from CoinGecko
Market Data (per coin)
- Current price (in multiple currencies)
- 24h price change (absolute and percentage)
- 7d, 30d, 1y price change
- Market cap and market cap rank
- 24h trading volume
- Circulating, total, and max supply
- All-time high/low prices and dates
Coin Details
- Coin name, symbol, and description
- Logo and images
- Categories and platforms
- Links (website, whitepaper, social media)
- Genesis date
- Developer and community stats
Historical Data
- OHLC data for charts
- Historical prices for specified date ranges
- Market chart data (prices, market caps, volumes)
Example API response - JSON structure returned from CoinGecko API
Other Data Sources
Fear & Greed Index
CoinTrail fetches the Crypto Fear & Greed Index from Alternative.me:
# Fear & Greed Index
FEAR_GREED_ENABLED=true
FEAR_GREED_UPDATE_INTERVAL=60 # minutes
Exchange Rates
For fiat currency conversion rates:
# Exchange Rates (optional - for fiat conversions)
EXCHANGE_RATE_API_KEY=your-key-here
EXCHANGE_RATE_PROVIDER=exchangerate-api # or openexchangerates
External API integrations - configure additional data sources like Fear & Greed Index
Rate Limiting & Error Handling
Built-in Rate Limiting
CoinTrail implements automatic rate limiting to prevent API quota exhaustion:
- Queues API requests with configurable delays
- Respects CoinGecko's rate limits per tier
- Implements exponential backoff on errors
- Caches responses to reduce duplicate calls
Error Handling
When API errors occur:
| Error Code | Meaning | Action Taken |
|---|---|---|
429 |
Rate limit exceeded | Wait and retry with backoff |
401 |
Invalid API key | Log error, use cached data |
500 |
Server error | Retry up to 3 times |
Timeout |
Request timeout | Retry with longer timeout |
Error handling in action - system logs showing automatic retry with exponential backoff
Data Caching
CoinTrail caches API responses to improve performance and reduce API calls:
| Data Type | Cache Duration | Storage |
|---|---|---|
| Price data | Based on tier interval | Database + Redis/File |
| Coin details | 24 hours | Database |
| Global market data | 5 minutes | Cache |
| Exchange rates | 1 hour | Cache |
| Fear & Greed Index | 1 hour | Cache |
For best performance, use Redis for caching. Configure CACHE_DRIVER=redis in your .env file.
Cache settings panel - configure cache driver and duration settings