API
Overview The CLAS API provides programmatic access to recipe sharing, user management, and platform features. Authentication All API requests require authentication using JWT tokens. Authentication Header
Authorization: Bearer <your_access_token>
Base Endpoints
User Management
Register User
Endpoint:
/api/v1/users/registerMethod: POST
Request Body:
{
"username": "string",
"email": "string",
"password": "string",
"display_name": "string"
}
Response:
{
"user_id": "string",
"status": "success",
"token": "jwt_token"
}
Get User Profile
Endpoint:
/api/v1/users/profileMethod: GET
Response:
{
"user_id": "string",
"username": "string",
"tier": "light|black",
"total_recipes": "integer",
"total_likes": "integer"
}
Recipe Endpoints
Create Recipe
Endpoint:
/api/v1/recipes/createMethod: POST
Request Body:
{
"title": "string",
"description": "string",
"ingredients": ["string"],
"steps": ["string"],
"cuisine_type": "string",
"difficulty_level": "easy|medium|hard"
}
Response:
{
"recipe_id": "string",
"status": "success"
}
Get Recipe
Endpoint:
/api/v1/recipes/{recipe_id}Method: GET
Response:
{
"recipe_id": "string",
"title": "string",
"author": "string",
"likes": "integer",
"ingredients": ["string"],
"steps": ["string"]
}
Like Recipe
Endpoint:
/api/v1/recipes/{recipe_id}/likeMethod: POST
Response:
{
"status": "success",
"total_likes": "integer"
}
Ranking Endpoints
Get Tier Rankings
Endpoint:
/api/v1/rankingsMethod: GET
- Parameters:
tier: light|blackpage: integerlimit: integer (default 10)
Response:
{
"rankings": [
{
"user_id": "string",
"username": "string",
"total_likes": "integer",
"rank": "integer"
}
],
"total_pages": "integer"
}
Error Handling
API returns standard HTTP status codes:
200: Successful request400: Bad request401: Unauthorized403: Forbidden404: Not found500: Server error
Error Response Format .. code-block:: json {
“error”: “string”, “message”: “detailed error description”, “code”: “error_code”
}
Rate Limiting
Maximum 100 requests per minute Exceeding limit returns 429 Too Many Requests
Webhooks Real-time event notifications available for:
New recipe creation User tier changes Ranking updates
Example Webhook Payload .. code-block:: json
- {
“event_type”: “recipe_created”, “data”: {
“recipe_id”: “string”, “user_id”: “string”
}, “timestamp”: “iso8601_datetime”
}
SDK and Library Support
Official Python SDK available
- Community-contributed libraries for:
JavaScript
Ruby
Go
Version History
v1.0.0: Initial releasev1.1.0: Added ranking and tier systemv1.2.0: Enhanced API capabilities