API Documentation
API Documentation
API Overview
Base URL
https://yourdomain.com/apiAPI Version
Current API version: v1
All endpoints are prefixed with /api/v1/
Response Format
All responses are in JSON format:
{
"success": true,
"data": {
// Response data
},
"message": "Operation successful"
}Error Responses
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Error description"
}
}Authentication
API Keys
Generate API keys:
- Go to Admin Panel > Settings > API
- Click "Generate API Key"
- Copy and save the key securely
- Use key in API requests
Using API Keys
Include API key in requests:
Header:
X-API-Key: your-api-key-hereQuery Parameter:
?api_key=your-api-key-hereOAuth 2.0 (Coming Soon)
OAuth 2.0 support for more advanced authentication.
Rate Limiting
API requests are rate limited:
- Default Limit: 100 requests per hour per API key
- Headers:
X-RateLimit-Limit- Request limitX-RateLimit-Remaining- Remaining requestsX-RateLimit-Reset- Reset timestamp
Endpoints
Discussions
List Discussions
GET /api/v1/discussionsParameters:
category- Filter by category IDpage- Page number (default: 1)limit- Results per page (default: 20)sort- Sort order (latest, oldest, popular)
Response:
{
"success": true,
"data": {
"discussions": [
{
"id": "123",
"title": "Discussion Title",
"slug": "discussion-title",
"category_id": "456",
"author": {
"id": "789",
"username": "john_doe"
},
"created_at": "2025-12-25T10:00:00Z",
"reply_count": 5,
"view_count": 100
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 50,
"pages": 3
}
}
}Get Discussion
GET /api/v1/discussions/{id}Response:
{
"success": true,
"data": {
"discussion": {
"id": "123",
"title": "Discussion Title",
"content": "Discussion content...",
"category_id": "456",
"author": {
"id": "789",
"username": "john_doe",
"avatar": "https://example.com/avatar.jpg"
},
"created_at": "2025-12-25T10:00:00Z",
"updated_at": "2025-12-25T11:00:00Z",
"reply_count": 5,
"view_count": 100,
"tags": ["tag1", "tag2"]
}
}
}Create Discussion
POST /api/v1/discussionsRequest Body:
{
"title": "New Discussion",
"content": "Discussion content...",
"category_id": "456",
"tags": ["tag1", "tag2"]
}Response:
{
"success": true,
"data": {
"discussion": {
"id": "123",
"title": "New Discussion",
// ... full discussion object
}
}
}Posts
List Posts
GET /api/v1/discussions/{discussion_id}/postsParameters:
page- Page numberlimit- Results per page
Get Post
GET /api/v1/posts/{id}Create Post
POST /api/v1/discussions/{discussion_id}/postsRequest Body:
{
"content": "Post content..."
}Users
Get User
GET /api/v1/users/{id}List Users
GET /api/v1/usersParameters:
page- Page numberlimit- Results per pagesearch- Search by username
Categories
List Categories
GET /api/v1/categoriesGet Category
GET /api/v1/categories/{id}Code Examples
JavaScript (Fetch)
// Get discussions
fetch('https://yourdomain.com/api/v1/discussions', {
headers: {
'X-API-Key': 'your-api-key'
}
})
.then(response => response.json())
.then(data => {
console.log(data);
});PHP (cURL)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://yourdomain.com/api/v1/discussions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: your-api-key'
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);Python (Requests)
import requests
headers = {
'X-API-Key': 'your-api-key'
}
response = requests.get(
'https://yourdomain.com/api/v1/discussions',
headers=headers
)
data = response.json()Error Codes
Common error codes:
400- Bad Request401- Unauthorized403- Forbidden404- Not Found429- Too Many Requests500- Internal Server Error
Best Practices
Security
- Use HTTPS - Always use HTTPS for API requests
- Protect API Keys - Never expose API keys in client-side code
- Rate Limiting - Respect rate limits
- Validate Input - Validate all input data
Performance
- Use Pagination - Always paginate large result sets
- Cache Responses - Cache API responses when appropriate
- Minimize Requests - Batch requests when possible
- Use Filters - Use filters to reduce data transfer
Error Handling
- Check Status Codes - Always check HTTP status codes
- Handle Errors Gracefully - Implement proper error handling
- Retry Logic - Implement retry for transient errors
- Log Errors - Log API errors for debugging
Presence Endpoint
Flatboard 5 provides a presence update endpoint used by the frontend heartbeat to track the current visitor's page in real time.
POST /presence/update (authenticated users — CSRF protected)
POST /api/presence/update (API clients)Request Body:
{
"page": "/d/123/discussion-title"
}Response:
{ "success": true }Webhooks
Flatboard 5 includes a built-in webhook system for real-time notifications to external services. Configure webhooks at Admin Panel → Webhooks.
Webhook Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /api/webhooks | Receive inbound webhook payloads |
GET | /admin/webhooks | List configured webhooks |
GET | /admin/webhooks/history | View delivery history |
POST | /admin/webhooks/save | Create or update a webhook |
POST | /admin/webhooks/test | Send a test payload to a webhook |
GET | /admin/webhooks/stats | Webhook delivery statistics |
Supported Events
discussion.created— New discussion publishedpost.created— New reply publisheduser.registered— New user registeredreport.created— Content report submitted
Delivery
Each event sends a POST request to the configured URL with a JSON body and an X-Flatboard-Event header identifying the event type. Delivery history and retry status are available in the admin panel.
Resources
- Developer Guide - Advanced development
- Troubleshooting - API issues
Last updated: February 23, 2026