POST /api/registerRegister a new user account.
Request Body:
{
"username": "string",
"email": "string",
"password": "string"
}Response:
{
"message": "Registration successful! Please check your email to verify your account.",
"email": "string"
}Error Responses:
{
"error": "This email is already registered. Please use a different email or try logging in.",
"field": "email"
}{
"error": "This username is already taken. Please choose a different username.",
"field": "username"
}GET /verify-email/{uidb64}/{token}/Verify email address. Returns HTML pages for success/error.
Success Response:
- Renders verification_success.html with login button
- Redirects to frontend login page
Error Response:
- Renders verification_error.html with error details
- Provides link to registration page
POST /api/loginLogin with email and password.
Request Body:
{
"email": "string",
"password": "string"
}Response:
{
"message": "Login successful!",
"tokens": {
"access": "string",
"refresh": "string"
},
"user": {
"username": "string",
"email": "string"
}
}Error Responses:
{
"error": "Please verify your email before logging in."
}{
"error": "Invalid email or password."
}POST /api/logoutLogout and blacklist the refresh token.
Request Body:
{
"refresh_token": "string"
}Response:
{
"message": "Logout successful!"
}POST /api/auth/password-resetRequest a password reset link.
Request Body:
{
"email": "string"
}Response:
{
"message": "Password reset link has been sent to your email."
}Error Response:
{
"error": "Email is required."
}POST /api/auth/password-reset/confirmReset password using the token from the email link.
Request Body:
{
"uid": "string",
"token": "string",
"new_password": "string"
}Response:
{
"message": "Password has been reset successfully."
}Error Responses:
{
"error": "Invalid or expired reset link."
}{
"error": "All fields are required."
}POST /api/games/fetchFetch games from Chess.com or Lichess.
Request Headers:
Authorization: Bearer <access_token>
Request Body:
{
"platform": "chess.com | lichess",
"username": "string",
"game_mode": "all | bullet | blitz | rapid | classical",
"num_games": "integer"
}Response:
{
"message": "Successfully fetched and saved games!",
"games_saved": "integer",
"credits_deducted": "integer",
"credits_remaining": "integer",
"games": [
{
"id": "integer",
"platform": "string",
"white": "string",
"black": "string",
"opponent": "string",
"result": "string",
"date_played": "datetime",
"opening_name": "string",
"game_id": "string"
}
]
}GET /api/games/userGet list of games for the authenticated user.
Request Headers:
Authorization: Bearer <access_token>
Query Parameters:
platform: all | chess.com | lichess (optional)
Response:
{
"games": [
{
"id": "integer",
"white": "string",
"black": "string",
"result": "string",
"date_played": "datetime",
"platform": "string",
"analysis": "object | null"
}
]
}GET/POST /api/analysis/{game_id}Analyze a specific game.
Request Headers:
Authorization: Bearer <access_token>
Request Body (POST only):
{
"depth": "integer (optional, default: 20)",
"use_ai": "boolean (optional, default: true)"
}Response:
{
"message": "Analysis completed successfully!",
"analysis": {
"moves": [
{
"move_number": "integer",
"move": "string",
"score": "float",
"is_mistake": "boolean",
"is_blunder": "boolean",
"time_spent": "float"
}
]
},
"feedback": {
"opening": {
"accuracy": "float",
"played_moves": ["string"],
"suggestions": ["string"]
},
"tactics": {
"missed_opportunities": ["string"],
"suggestions": ["string"]
},
"mistakes": "integer",
"blunders": "integer",
"inaccuracies": "integer",
"time_management": {
"time_pressure_moves": ["integer"],
"suggestions": ["string"]
},
"strengths": [
{
"area": "string",
"description": "string"
}
],
"improvement_areas": [
{
"area": "string",
"description": "string"
}
],
"ai_suggestions": "string | object"
},
"credits_remaining": "integer"
}POST /api/analysis/batchAnalyze multiple games.
Request Headers:
Authorization: Bearer <access_token>
Request Body:
{
"num_games": "integer",
"use_ai": "boolean (optional, default: true)",
"depth": "integer (optional, default: 20)"
}Response:
{
"message": "Batch analysis completed!",
"results": {
"individual_games": {
"game_id": {
"blunders": "integer",
"mistakes": "integer",
"inaccuracies": "integer",
"opening": {
"accuracy": "float",
"played_moves": ["string"]
},
"time_management": {
"time_pressure_moves": ["integer"]
}
}
},
"overall_stats": {
"total_games": "integer",
"wins": "integer",
"losses": "integer",
"draws": "integer",
"average_accuracy": "float",
"common_mistakes": {
"blunders": "float",
"mistakes": "float",
"inaccuracies": "float",
"time_pressure": "float"
},
"improvement_areas": [
{
"area": "string",
"description": "string"
}
],
"strengths": [
{
"area": "string",
"description": "string"
}
]
},
"dynamic_feedback": "string | object"
}
}GET /api/dashboardGet user-specific games and statistics for the dashboard.
Request Headers:
Authorization: Bearer <access_token>
Response:
{
"total_games": "integer",
"analyzed_games": "integer",
"unanalyzed_games": "integer",
"statistics": {
"wins": "integer",
"losses": "integer",
"draws": "integer",
"win_rate": "float"
},
"recent_games": [
{
"id": "integer",
"platform": "string",
"white": "string",
"black": "string",
"opponent": "string",
"result": "string",
"date_played": "datetime",
"opening_name": "string",
"analysis": "object | null"
}
]
}GET /api/creditsGet current credit balance.
Request Headers:
Authorization: Bearer <access_token>
Response:
{
"credits": "integer"
}POST /api/credits/purchaseCreate a checkout session for credit purchase.
Request Headers:
Authorization: Bearer <access_token>
Request Body:
{
"package_id": "string"
}Response:
{
"success": true,
"checkout_url": "string",
"session_id": "string"
}POST /api/credits/confirmConfirm credit purchase and add credits.
Request Headers:
Authorization: Bearer <access_token>
Request Body:
{
"session_id": "string"
}Response:
{
"success": true,
"credits": "integer",
"added_credits": "integer"
}GET /api/profileGet the authenticated user's profile information.
Request Headers:
Authorization: Bearer <access_token>
Response:
{
"username": "string",
"email": "string",
"rating": "integer",
"credits": "integer",
"preferences": {
"emailNotifications": "boolean",
"darkMode": "boolean",
"autoAnalyze": "boolean"
},
"created_at": "datetime",
"games_analyzed": "integer"
}PATCH /api/profileUpdate the authenticated user's profile information.
Request Headers:
Authorization: Bearer <access_token>
Request Body:
{
"username": "string (optional)",
"preferences": {
"emailNotifications": "boolean (optional)",
"darkMode": "boolean (optional)",
"autoAnalyze": "boolean (optional)"
}
}Response:
{
"message": "Profile updated successfully.",
"username": "string",
"preferences": {
"emailNotifications": "boolean",
"darkMode": "boolean",
"autoAnalyze": "boolean"
}
}Error Responses:
{
"error": "Username already taken."
}All endpoints may return the following error responses:
{
"error": "Error message describing the issue"
}{
"error": "Authentication credentials were not provided"
}{
"error": "You do not have permission to perform this action"
}{
"error": "Requested resource not found"
}{
"error": "Internal server error occurred",
"details": "Optional error details"
}Most endpoints are rate-limited to prevent abuse. The current limits are:
- Authentication endpoints: 5 requests per minute
- Game fetching: 10 requests per minute
- Analysis endpoints: 3 requests per minute
- Credit operations: 5 requests per minute
When rate limit is exceeded, you'll receive a 429 Too Many Requests response:
{
"error": "Too many requests. Please try again later."
}