API Reference
The Community Engine exposes standard REST-like endpoints. Most interactions are managed internally through Server Actions and React Server Components, however the backend provides standard API routes under /api/*.
Authentication
Authentication is managed via HTTP Cookies, provided by Better-Auth. For API consumption outside a browser environment, standard token authentication mechanisms must be strictly defined in your local configurations.
Questions
GET /api/community/questions
Retrieves a paginated list of questions.
Query Parameters:
cursor(string): The ID of the last item fetched to enable infinite scrolling.limit(number): Configurable amount of returned records (Default: 20)
Response:
{
"questions": [...],
"nextCursor": "clk85o2...",
"hasNextPage": true
}POST /api/community/questions
Creates a newly formatted question.
Request Body:
{
"title": "How do I reverse a string in JS?",
"body": "I'm having trouble reversing standard JS strings...",
"tags": ["javascript", "arrays"]
}PATCH /api/community/questions/:id
Updates question metadata and markdown.
Request Body:
{
"title": "A modified title",
"body": "Modified content..."
}DELETE /api/community/questions/:id
Soft deletes or permanently deletes a question. Must be authenticated as the specific author or a community moderator.
Answers
GET /api/community/questions/:id/answers
Retrieves paginated answers mapped specifically to a single question parent.
POST /api/community/answers
Publishes an answer onto a question queue.
Request Body:
{
"questionId": "clk9j2...",
"body": "You can use `str.split('').reverse().join('')`"
}PATCH /api/community/answers/:id
Modifies the text body of an existing answer. Only executable by the original author.
Interactivity
POST /api/community/vote
Casts or modifies a user vote for a target entity.
Request Body:
{
"targetId": "clk2...",
"targetType": "QUESTION", // or "ANSWER"
"value": 1 // 1 for Upvote, -1 for Downvote
}POST /api/community/bookmarks
Toggles a bookmark explicitly for the authenticated user mapped to a question entity.