This API wrapper system creates secure endpoints for all 219 Top Ledger APIs, hiding the original API keys and allowing users to access them with their own API keys.
- Original APIs: 219 Top Ledger APIs each with their own API keys (stored in
public/apis_list.json) - Wrapper APIs: Dynamic endpoints at
/api/tl/[...path]that proxy requests to original APIs - User Authentication: Users authenticate with their own API keys created in the Keys section
- Usage Tracking: All API calls are logged and tracked per user API key
User Request → /api/tl/tl-research/api/queries/13448/results.json?api_key=USER_KEY
↓
Wrapper validates USER_KEY
↓
Wrapper calls → https://analytics.topledger.xyz/tl-research/api/queries/13448/results.json?api_key=ORIGINAL_KEY
↓
Response returned to user + usage logged
GET /api/tl-apisReturns list of all 219 wrapped APIs with their wrapper URLs.
GET /api/tl/[original-path]?api_key=YOUR_USER_API_KEY
POST /api/tl/[original-path]?api_key=YOUR_USER_API_KEYcurl "http://localhost:3000/api/tl-apis"curl "http://localhost:3000/api/tl/tl-research/api/queries/13448/results.json?api_key=AAohjJhtsyggedgavpjn"curl "http://localhost:3000/api/tl/tl/api/queries/13192/results.json?api_key=AAohjJhtsyggedgavpjn"- Create API keys in the "API Keys" section of the dashboard
- Use these keys to authenticate with wrapper APIs
- Each key tracks usage and hits
- All wrapper API calls require a valid user API key
- Invalid keys return 403 Forbidden
- Missing keys return 401 Unauthorized
- Every API call increments user's total hits
- Daily usage is tracked per API key
- Credits are deducted from user account
- Last used timestamp is updated
- Total hits per API key
- Daily hit breakdown
- Usage data for analytics
- Credit consumption
- Compute Units (13 APIs) - CU pricing, consumption, overspending
- DEX (13 APIs) - Trading volume, TVL, aggregators
- Launchpads (6 APIs) - Token launches, fees, revenue
- MEV (6 APIs) - Sandwich attacks, value extraction
- Overview (11 APIs) - Network usage, market dynamics
- Projects (63 APIs) - Protocol-specific analytics
- Protocol Revenue (11 APIs) - dApp revenue, network fees
- REV (5 APIs) - Economic value, issuance, burn
- SF Dashboards (74 APIs) - Solana Foundation dashboards
- Stablecoins (10 APIs) - USDC/USDT analytics
- Test (3 APIs) - Testing endpoints
- Valuation Insights (1 API) - Protocol valuations
- Wrapped BTC (11 APIs) - Bitcoin on Solana
- xStocks (8 APIs) - Tokenized equities
Including: DeFi, AI Tokens, Consumer, Depin, Treasury, VC Funding, Transaction Activity, Network Usage, and many more.
401: Missing API key403: Invalid API key404: API endpoint not found500: Top Ledger API error or internal error
{
"error": "Invalid API key",
"details": "Additional error information"
}- Displays all 219 wrapped APIs
- Category and page filtering
- API key selection dropdown
- Copy wrapper URLs with user API key
The "Copy endpoint" button now generates URLs like:
http://localhost:3000/api/tl/tl-research/api/queries/13448/results.json?api_key=USER_KEY
- Original Top Ledger API keys are hidden from users
- Only server-side code has access to original keys
- User keys are validated before proxying requests
- Credit-based system prevents abuse
- Per-key usage tracking
- Rate limiting through credit deduction
GET /api/test-wrapper?api_key=YOUR_KEYTests the wrapper system with a sample API call.
app/api/
├── tl/[...endpoint]/route.ts # Dynamic wrapper endpoints
├── tl-apis/route.ts # API listing endpoint
└── test-wrapper/route.ts # Test endpoint
public/
└── apis_list.json # Original API definitions
data/
└── users.json # User data and API keys
- Rate Limiting: Add request rate limits per API key
- Caching: Implement response caching for better performance
- Analytics: Enhanced usage analytics and reporting
- Webhooks: Real-time usage notifications
- API Documentation: Auto-generated docs for each endpoint