Api Guide
Get started with the CodePlanet API in under 10 minutes. This guide covers authentication, common use cases, and provides code snippets for popular languages.
What is an API Key?
An API Key is like a password for applications. It allows you to write scripts or build apps that interact with CodePlanet on your behalf.
User API keys start with cp_live_ followed by a secure random string.
How to Generate a Key
- Go to Settings → API Keys.
- Click Generate New Key.
- Give it a name (e.g., "My Python Script").
- Copy the key immediately. We only show it once!
Authentication
All API requests must include your API key in the Authorization header or x-api-key header.
Header Format:
Quick Start Examples
Here is how to fetch your user profile in different languages.
JavaScript (Fetch)
Node.js (Axios)
Python (Requests)
Common Use Cases
1. Fetch Problems
Retrieve a list of coding problems.
Response:
2. Get User Stats
See your XP, streaks, and solve counts.
3. Bookmark a Problem
Save a problem for later.
4. Read Activity Feed
Get recent activity from you and people you follow.
Rate Limiting
To prevent abuse, we limit the number of requests you can make.
| Plan | Requests / Day |
|---|---|
| Free | 100 |
| Developer | 1,000 |
| Pro | 10,000 |
We provide headers in every response to help you track usage:
X-RateLimit-Limit: Your total daily limit.X-RateLimit-Remaining: Requests left today.X-RateLimit-Reset: Timestamp when your limit refreshes.
If you hit the limit, you will receive a 429 Too Many Requests error. The Retry-After header tells you how many seconds to wait.
Error Handling
| Status | Meaning | Solution |
|---|---|---|
401 | Unauthorized | Check if your API Key is correct. |
403 | Forbidden | Your plan does not allow this action. |
404 | Not Found | The resource (e.g., problem ID) doesn't exist. |
429 | Rate Limited | You've hit your daily limit. Upgrade or wait. |
500 | Server Error | Something went wrong on our end. Try again later. |
Need help? Join our Discord Community.