CodeGuessr API Documentation
Access CodeGuessr's educational features programmatically. Our API is designed for teachers, students, and educational integrations.
API Overview
The CodeGuessr API provides access to daily challenges, student progress tracking, and classroom management features. All API endpoints are authenticated and rate-limited to ensure security and fair usage.
Base URL
https://codeguessr.com/api
All API requests should be made to this base URL with the appropriate endpoint path.
Authentication
CodeGuessr API uses session-based authentication. Users must be logged in to access API endpoints. Different endpoints require different permission levels.
Authentication Methods
Session Authentication
Standard web session authentication using cookies. Users must be logged in through the web interface.
Teacher Authentication
Teachers must be verified and have appropriate plan access for classroom management endpoints.
Permission Levels
- Student: Access to personal progress and daily challenges
- Teacher: Access to classroom management and student data
- Verified Teacher: Full access to all educational features
API Endpoints
Available endpoints organized by functionality:
Daily Challenge Endpoints
GET/api/daily-challenge/get-question
Get today's daily challenge question
GET/api/daily-challenge/get-hint
Get hint for the current daily challenge
GET/api/daily-challenge/get-explanation
Get explanation after completing the challenge
Teacher Endpoints
GET/api/teacher/stats
Get teacher dashboard statistics
GET/api/teacher/students
Get list of students in teacher's classes
GET/api/teacher/analytics
Get detailed class analytics and performance data
GET/api/teacher/leaderboard
Get class leaderboard data
POST/api/teacher/class-code
Generate or manage class codes for student enrollment
Student Endpoints
POST/api/student/join-class
Join a class using a class code
GET/api/student/class-leaderboard
Get leaderboard for student's class
GET/api/student/completed-challenges
Get list of completed daily challenges
Rate Limits
API rate limits help ensure system stability and fair usage:
Standard Limits
- General API calls: 60 requests per minute per user
- Daily challenge attempts: Limited by game rules (typically 6 guesses)
- Teacher analytics: 30 requests per minute
- Class management: 20 requests per minute
Rate limits are enforced per user session. If you exceed the rate limit, you'll receive a 429 status code and should wait before making additional requests.
Code Examples
Common API usage patterns:
Get Daily Challenge (JavaScript)
// Fetch today's daily challenge
const response = await fetch('/api/daily-challenge/get-question', {
method: 'GET',
credentials: 'include', // Include session cookies
headers: {
'Content-Type': 'application/json'
}
});
if (response.ok) {
const challenge = await response.json();
console.log('Today\\'s challenge:', challenge);
}
Join Class (JavaScript)
// Student joins a class using class code
const response = await fetch('/api/student/join-class', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
classCode: 'ABC123'
})
});
const result = await response.json();
if (result.success) {
console.log('Successfully joined class!');
}
Get Teacher Stats (JavaScript)
// Get teacher dashboard statistics
const response = await fetch('/api/teacher/stats', {
method: 'GET',
credentials: 'include'
});
if (response.ok) {
const stats = await response.json();
console.log('Students:', stats.totalStudents);
console.log('Active classes:', stats.activeClasses);
}
Security & Best Practices
Important security considerations when using the CodeGuessr API:
Authentication Security
- Always use HTTPS for API requests
- Include credentials in requests to maintain session state
- Handle authentication errors gracefully
- Don't expose sensitive student data unnecessarily
Data Privacy
- Teachers can only access data for their own students
- Students can only access their own progress data
- All data access is logged and monitored
- Follow your institution's data privacy policies
Error Handling
// Proper error handling example
try {
const response = await fetch('/api/teacher/stats');
if (!response.ok) {
if (response.status === 401) {
// Redirect to login
window.location.href = '/login';
} else if (response.status === 403) {
// Handle permission denied
console.error('Access denied');
}
return;
}
const data = await response.json();
// Process successful response
} catch (error) {
console.error('API request failed:', error);
}
Need Help?
If you need assistance with API integration or have questions about specific endpoints:
Contact SupportTroubleshooting GuideTeacher Help