Comprehensive API reference for burntop.dev platform
Base URL: https://burntop.dev
- Authentication
- Rate Limits
- Response Format
- Core APIs
- User APIs
- Social Features
- Dashboard APIs
- Leaderboard
- Achievements
- Notifications
- Real-time
- Badges
- Open Graph Images
- Wrapped
- Referrals
- SEO
Most endpoints require authentication via session cookie or Bearer token.
Web app uses session cookies set by Better Auth after OAuth login.
CLI uses Bearer token authentication:
Authorization: Bearer <your-api-token>Obtain token via burntop login command.
| Endpoint | Limit |
|---|---|
POST /api/sync |
10 requests per minute per user |
| All other endpoints | No explicit rate limit (fair use policy) |
{
"data": { ... },
"meta": { ... }
}{
"error": {
"code": "ERROR_CODE",
"message": "Human readable error message"
}
}UNAUTHORIZED- Authentication requiredFORBIDDEN- Insufficient permissionsNOT_FOUND- Resource not foundVALIDATION_ERROR- Invalid request dataRATE_LIMIT_EXCEEDED- Too many requestsINTERNAL_ERROR- Server error
GET /api/health
Check service health for monitoring.
Auth: None
Response:
{
"status": "ok",
"timestamp": "2024-01-05T12:34:56.789Z",
"checks": {
"database": "ok"
}
}Status Codes:
200- Service healthy503- Service unhealthy
Cache: no-cache
POST /api/sync
Upload AI usage data from CLI tool.
Auth: Required (Bearer token)
Rate Limit: 10 requests per minute
Request Body:
{
"records": [
{
"timestamp": "2024-01-05T12:00:00Z",
"model": "claude-3-5-sonnet-20241022",
"source": "claude-code",
"inputTokens": 1000,
"outputTokens": 500,
"cacheCreationTokens": 0,
"cacheReadTokens": 0,
"requestId": "req_abc123"
}
]
}Response:
{
"success": true,
"recordsAdded": 1,
"recordsSkipped": 0,
"achievements": ["first-sync"],
"leveledUp": false,
"newLevel": null
}Features:
- Deduplicates records by
requestId - Updates user stats (tokens, costs, XP)
- Calculates streak
- Checks for achievement unlocks
- Awards XP for activity
GET /api/users/:username
Get public user profile.
Auth: None
Response:
{
"id": "user_123",
"username": "alice",
"name": "Alice Smith",
"image": "https://github.com/alice.png",
"bio": "Full-stack developer",
"location": "San Francisco, CA",
"websiteUrl": "https://alice.dev",
"level": 12,
"xp": 2450,
"isPublic": true,
"createdAt": "2024-01-01T00:00:00Z"
}Status Codes:
200- Success404- User not found403- Profile is private
GET /api/users/:username/stats
Get comprehensive user statistics.
Auth: None (public profiles only)
Response:
{
"totalTokens": 1500000,
"totalCost": 15.5,
"cacheEfficiency": 0.85,
"currentStreak": 7,
"longestStreak": 30,
"achievementsUnlocked": 12,
"achievementsTotal": 68,
"topModels": [
{
"model": "claude-3-5-sonnet-20241022",
"tokens": 1000000,
"percentage": 66.7
}
],
"topSources": [
{
"source": "cursor",
"tokens": 800000,
"percentage": 53.3
}
]
}GET /api/users/:username/level
Get user's level and XP information.
Auth: None (public profiles only)
Response:
{
"level": 12,
"title": "AI Adept",
"currentXp": 2450,
"xpToNextLevel": 500,
"totalXpForNextLevel": 2950,
"progress": 0.83
}GET /api/users/:username/achievements
Get all achievements for a user (both locked and unlocked).
Auth: None (public profiles only)
Response:
{
"achievements": [
{
"id": "first-sync",
"name": "First Sync",
"description": "Synced your first usage data",
"rarity": "common",
"category": "onboarding",
"icon": "🎯",
"unlocked": true,
"unlockedAt": "2024-01-05T12:00:00Z",
"pinned": true,
"progress": null
},
{
"id": "token-millionaire",
"name": "Token Millionaire",
"description": "Used 1,000,000 tokens",
"rarity": "legendary",
"category": "usage",
"icon": "💎",
"unlocked": false,
"unlockedAt": null,
"pinned": false,
"progress": {
"current": 500000,
"target": 1000000,
"percentage": 0.5
}
}
]
}PATCH /api/users/me
Update authenticated user's profile.
Auth: Required
Request Body:
{
"name": "Alice Smith",
"bio": "Full-stack developer",
"location": "San Francisco, CA",
"websiteUrl": "https://alice.dev",
"isPublic": true
}Validation:
name: 1-50 charactersbio: max 500 characterslocation: max 100 characterswebsiteUrl: valid URL
Response:
{
"success": true,
"user": { ... }
}PATCH /api/users/me/achievements/:id/pin
Pin or unpin achievement to profile showcase.
Auth: Required
Request Body:
{
"pinned": true
}Constraints:
- Maximum 6 pinned achievements
- Can only pin unlocked achievements
Response:
{
"success": true,
"pinned": true
}POST /api/users/:username/follow
Follow a user.
Auth: Required
Response:
{
"success": true,
"following": true
}DELETE /api/users/:username/follow
Unfollow a user.
Auth: Required
Response:
{
"success": true,
"following": false
}GET /api/users/:username/followers
Get list of user's followers.
Auth: None (public profiles only)
Response:
{
"followers": [
{
"id": "user_456",
"username": "bob",
"name": "Bob Jones",
"image": "https://github.com/bob.png",
"level": 8
}
],
"total": 1
}GET /api/users/:username/following
Get list of users this user follows.
Auth: None (public profiles only)
Response:
{
"following": [
{
"id": "user_789",
"username": "charlie",
"name": "Charlie Brown",
"image": "https://github.com/charlie.png",
"level": 15
}
],
"total": 1
}GET /api/feed
Get activity feed from followed users.
Auth: Required
Query Parameters:
cursor(number, optional) - Pagination cursor (activity ID)limit(number, optional) - Results per page (default: 50, max: 100)
Response:
{
"activities": [
{
"id": 123,
"userId": "user_789",
"username": "charlie",
"name": "Charlie Brown",
"image": "https://github.com/charlie.png",
"type": "achievement_unlocked",
"data": {
"achievementId": "streak-7",
"achievementName": "Week Warrior",
"achievementIcon": "🔥"
},
"timestamp": "2024-01-05T12:00:00Z"
}
],
"nextCursor": 122,
"hasMore": true
}Activity Types:
achievement_unlocked- User unlocked achievementlevel_up- User leveled upleaderboard_rank- User reached new leaderboard rankstreak_milestone- User reached streak milestone
GET /api/dashboard/overview
Get dashboard overview stats for authenticated user.
Auth: Required
Response:
{
"allTime": {
"totalTokens": 1500000,
"totalCost": 15.5,
"cacheEfficiency": 0.85
},
"thisMonth": {
"totalTokens": 250000,
"totalCost": 2.5
},
"thisWeek": {
"totalTokens": 50000,
"totalCost": 0.5
},
"streak": {
"current": 7,
"longest": 30
},
"level": {
"level": 12,
"title": "AI Adept",
"currentXp": 2450,
"xpToNextLevel": 500
}
}GET /api/dashboard/trends
Get usage trends and comparisons.
Auth: Required
Response:
{
"weekOverWeek": {
"tokens": 0.15,
"cost": 0.12
},
"monthOverMonth": {
"tokens": 0.25,
"cost": 0.2
},
"usageOverTime": [
{
"date": "2024-01-01",
"tokens": 10000,
"cost": 0.1
}
],
"peakHours": [
{
"hour": 14,
"tokens": 50000
}
],
"dayOfWeek": [
{
"day": "Monday",
"tokens": 100000
}
]
}GET /api/dashboard/models
Get model usage distribution.
Auth: Required
Response:
{
"distribution": [
{
"model": "claude-3-5-sonnet-20241022",
"tokens": 1000000,
"cost": 10.0,
"percentage": 66.7
}
],
"overTime": [
{
"date": "2024-01-01",
"model": "claude-3-5-sonnet-20241022",
"tokens": 10000
}
],
"newModels": [
{
"model": "gpt-4-turbo-2024-04-09",
"firstUsed": "2024-01-05T12:00:00Z",
"tokens": 5000
}
]
}GET /api/dashboard/tools
Get tool/source usage distribution.
Auth: Required
Response:
{
"distribution": [
{
"source": "cursor",
"tokens": 800000,
"cost": 8.0,
"percentage": 53.3
}
],
"overTime": [
{
"date": "2024-01-01",
"source": "cursor",
"tokens": 8000
}
],
"newTools": [
{
"source": "claude-code",
"firstUsed": "2024-01-05T12:00:00Z",
"tokens": 10000
}
]
}GET /api/leaderboard
Get global or filtered leaderboard.
Auth: Optional (required for friends leaderboard)
Query Parameters:
period(string, optional) - Time period:all|month|week(default:all)type(string, optional) - Leaderboard type:global|diverse|efficient|streak|rising|reasoning|friends(default:global)tool(string, optional) - Filter by source (e.g.,cursor,claude-code)model(string, optional) - Filter by model (e.g.,claude-3-5-sonnet-20241022)region(string, optional) - Filter by region:NA|EU|APAC|SA|AF|OCEcursor(number, optional) - Pagination cursor (rank)limit(number, optional) - Results per page (default: 100, max: 100)
Leaderboard Types:
global- Total tokens (all-time, month, or week)diverse- Number of different models usedefficient- Cache hit ratestreak- Current streak lengthrising- Biggest gainers (week-over-week)reasoning- Reasoning tokens used (o1/o3 models)friends- Leaderboard of followed users (auth required)
Response:
{
"entries": [
{
"rank": 1,
"userId": "user_123",
"username": "alice",
"name": "Alice Smith",
"image": "https://github.com/alice.png",
"level": 12,
"score": 1500000,
"scoreLabel": "1.5M tokens"
}
],
"nextCursor": 101,
"hasMore": true,
"userEntry": {
"rank": 42,
"score": 100000
}
}GET /api/achievements
Get all achievement definitions.
Auth: None
Query Parameters:
category(string, optional) - Filter by category:onboarding|usage|social|streaks|efficiency|diversity|milestones|specialrarity(string, optional) - Filter by rarity:common|rare|epic|legendary
Response:
{
"achievements": [
{
"id": "first-sync",
"name": "First Sync",
"description": "Synced your first usage data",
"rarity": "common",
"category": "onboarding",
"icon": "🎯",
"xpReward": 10
}
],
"total": 68,
"byCategory": {
"onboarding": 5,
"usage": 15,
"social": 8,
"streaks": 10,
"efficiency": 10,
"diversity": 8,
"milestones": 10,
"special": 2
},
"byRarity": {
"common": 30,
"rare": 20,
"epic": 12,
"legendary": 6
}
}GET /api/notifications
Get user notifications.
Auth: Required
Query Parameters:
limit(number, optional) - Results per page (default: 50, max: 100)offset(number, optional) - Pagination offsetunreadOnly(boolean, optional) - Show only unread notifications
Response:
{
"notifications": [
{
"id": 1,
"type": "achievement_unlocked",
"title": "Achievement Unlocked!",
"message": "You unlocked the Week Warrior achievement",
"data": {
"achievementId": "streak-7",
"achievementName": "Week Warrior",
"achievementIcon": "🔥"
},
"read": false,
"createdAt": "2024-01-05T12:00:00Z"
}
],
"total": 10,
"unreadCount": 3
}Notification Types:
achievement_unlocked- Achievement unlockedlevel_up- Level upleaderboard_rank- New leaderboard rankstreak_at_risk- Streak at risk (22 hours)weekly_summary- Weekly summary readyfollowed- Someone followed you
POST /api/notifications
Mark notifications as read.
Auth: Required
Request Body:
{
"notificationIds": [1, 2, 3]
}Or mark all as read:
{
"markAll": true
}Response:
{
"success": true,
"markedCount": 3
}GET /api/sse
Subscribe to real-time activity feed updates.
Auth: Required
Connection:
const eventSource = new EventSource('/api/sse', {
headers: {
Authorization: 'Bearer <token>',
},
});
eventSource.addEventListener('activity', (event) => {
const activity = JSON.parse(event.data);
console.log('New activity:', activity);
});
eventSource.addEventListener('keepalive', () => {
console.log('Connection alive');
});Event Types:
activity- New activity from followed userskeepalive- Heartbeat every 30 seconds
Activity Event Data:
{
"id": 123,
"userId": "user_789",
"username": "charlie",
"type": "achievement_unlocked",
"data": { ... },
"timestamp": "2024-01-05T12:00:00Z"
}GET /api/badge/:username
Generate embeddable SVG badge.
Auth: None (public profiles only)
Query Parameters:
variant(string, optional) - Badge variant:compact|standard|detailed|streak|level|heatmap(default:standard)style(string, optional) - Badge style:flat|flat-square|plastic|for-the-badge(default:flat)theme(string, optional) - Color theme:dark|light(default:dark)color(string, optional) - Custom color (hex without #, e.g.,FF6B00)
Response: SVG image
Content-Type: image/svg+xml
Cache: public, max-age=900 (15 minutes)
Embed Example:
Badge Variants:
compact- Tokens only (110x20)standard- Tokens + streak + level (320x20)detailed- Full stats (400x100)streak- Streak only (150x20)level- Level only (150x20)heatmap- Contribution heatmap (600x100)
GET /api/badge/demo
Generate demo badge with mock data.
Auth: None
Query Parameters: Same as /api/badge/:username
Response: SVG image with sample data
Cache: public, max-age=3600 (1 hour)
GET /api/og/:username/stats
Generate stats card OG image (1200x630 PNG).
Auth: None (public profiles only)
Response: PNG image
Content-Type: image/png
Cache: public, max-age=3600, stale-while-revalidate=86400 (1 hour + 1 day SWR)
GET /api/og/:username/achievement/:id
Generate achievement unlock OG image.
Auth: None (public profiles only)
Response: PNG image
Content-Type: image/png
Cache: public, max-age=3600, stale-while-revalidate=86400
GET /api/og/:username/weekly
Generate weekly recap OG image.
Auth: None (public profiles only)
Response: PNG image
Content-Type: image/png
Cache: public, max-age=1800, stale-while-revalidate=3600 (30 minutes + 1 hour SWR)
GET /api/og/wrapped/:year
Generate Wrapped (year in review) OG image.
Auth: Required
Query Parameters:
format(string, optional) - Image format:standard(1200x630) |story(1080x1920) |square(1080x1080) (default:standard)
Response: PNG image
Content-Type: image/png
Cache: public, max-age=900, stale-while-revalidate=1800 (15 minutes + 30 minutes SWR)
GET /api/wrapped/:year
Get year-in-review data.
Auth: Required
Response:
{
"year": 2024,
"totalTokens": 5000000,
"totalCost": 50.0,
"daysActive": 300,
"longestStreak": 45,
"topModel": {
"model": "claude-3-5-sonnet-20241022",
"tokens": 3000000,
"percentage": 60.0
},
"topTool": {
"source": "cursor",
"tokens": 2500000,
"percentage": 50.0
},
"achievementsUnlocked": 25,
"leaderboardHighest": 12,
"efficiencyScore": 0.85,
"predictions": {
"nextYearTokens": 7500000,
"nextYearCost": 75.0,
"suggestedGoal": "Reach 10M tokens"
}
}GET /api/referrals/code
Get current user's referral code and URL.
Auth: Required
Response:
{
"code": "ALICE2024",
"url": "https://burntop.dev?ref=ALICE2024"
}POST /api/referrals/click
Track referral link click (analytics only).
Auth: None
Request Body:
{
"referralCode": "ALICE2024"
}Response:
{
"success": true
}POST /api/referrals/track
Track referral relationship on signup.
Auth: Required (new user only)
Request Body:
{
"referralCode": "ALICE2024"
}Response:
{
"success": true,
"xpAwarded": {
"level1": 25,
"level2": 6.25,
"level3": 2.5
}
}XP Rewards:
- Level 1 (Direct referral): 25 XP
- Level 2 (Referral's referral): 6.25 XP
- Level 3 (Level 2's referral): 2.5 XP
Maximum depth: 3 levels
GET /api/referrals/stats
Get referral statistics.
Auth: Required
Response:
{
"totalReferrals": {
"level1": 10,
"level2": 5,
"level3": 2
},
"totalXpEarned": 300,
"referredUsers": [
{
"userId": "user_456",
"username": "bob",
"name": "Bob Jones",
"image": "https://github.com/bob.png",
"level": 8,
"joinedAt": "2024-01-05T12:00:00Z",
"referralLevel": 1
}
],
"clickStats": {
"total": 50,
"converted": 10,
"conversionRate": 0.2
}
}GET /sitemap.xml
Generate sitemap for search engines.
Auth: None
Response: XML sitemap
Content-Type: application/xml
Cache: public, max-age=3600 (1 hour)
Includes:
- Static pages (homepage, login, dashboard, leaderboard, etc.)
- Public user profiles
- Achievement pages
GET /api/insights
Get personalized insights comparing user to community benchmarks.
Auth: Required
Query Parameters:
period(string, optional) - Time period:all|month|week(default:all)
Response:
{
"percentiles": {
"tokens": 0.75,
"cacheEfficiency": 0.9,
"streak": 0.6,
"diversity": 0.85
},
"insights": [
{
"type": "comparison",
"title": "Above Average Token Usage",
"message": "You use 50% more tokens than the average user",
"sentiment": "neutral"
},
{
"type": "efficiency",
"title": "Cache Efficiency Champion",
"message": "Your cache efficiency is in the top 10%",
"sentiment": "positive"
},
{
"type": "productivity",
"title": "Peak Productivity",
"message": "You're most productive on Tuesdays at 2 PM",
"sentiment": "neutral"
}
],
"recommendations": [
{
"title": "Improve Streak",
"message": "You're 3 days away from your longest streak record",
"action": "Keep syncing daily!"
}
]
}Insight Types:
comparison- Compare to community averageefficiency- Cache/cost efficiency insightsproductivity- Usage patterns and trendsachievement- Achievement progress suggestions
Sentiment:
positive- Good performanceneutral- Informationalnegative- Area for improvement
All API responses include appropriate cache headers:
- Dynamic user data: Short cache (5-15 minutes) with
stale-while-revalidate - Static content: Long cache (1 hour+) with
stale-while-revalidate - Real-time data: No cache
- Images (OG/badges): 15 minutes to 1 hour
Use cursor-based pagination for large result sets:
cursor- Last item's ID/rank from previous pagelimit- Results per page (respect max limits)hasMore- Boolean indicating more results available
Always check HTTP status codes and handle errors:
401- Redirect to login403- Show permission error404- Show not found page429- Retry with exponential backoff5xx- Show error message and retry
Respect user privacy settings:
- Public profiles: All data visible
- Private profiles: Only basic info (username, name, avatar) visible to non-followers
For API questions or issues:
- GitHub Issues: https://github.com/agusmdev/burntop/issues
- GitHub Discussions: https://github.com/agusmdev/burntop/discussions
Last Updated: 2024-01-05 API Version: 1.0.0