Skip to content

API Overview

The Discord Forum API exposes RESTful endpoints for accessing synced Discord forum content.

Base URL

http://localhost:3000/api

In production, replace with your deployed API URL.

API Design

The API follows REST conventions:

  • JSON responses for all endpoints
  • HTTP status codes indicate success/failure
  • Cursor-based pagination for list endpoints
  • Consistent error format across all endpoints

Authentication

Most endpoints are public and require no authentication. This makes it easy to:

  • Build static sites
  • Create public FAQs
  • Power search widgets

Protected endpoints (admin actions) require Discord OAuth:

Authorization: Bearer <access_token>

See Authentication for details.

Quick Reference

Servers

MethodEndpointDescription
GET/servers/:serverIdGet server info
GET/servers/:serverId/channelsList forum channels
GET/servers/:serverId/tagsList all tags
GET/servers/:serverId/statsGet statistics

Threads

MethodEndpointDescription
GET/threadsList threads with filters
GET/threads/:threadIdGet thread with messages
GET/threads/:threadId/participantsGet thread participants
MethodEndpointDescription
GET/searchSearch threads and messages

Users

MethodEndpointDescription
GET/users/:userIdGet user profile
GET/leaderboard/:serverIdGet user leaderboard

Response Format

Successful Response

{
"data": { ... },
"meta": {
"timestamp": "2024-01-15T12:00:00.000Z"
}
}

Or for lists:

{
"threads": [ ... ],
"nextCursor": "abc123",
"hasMore": true
}

Error Response

{
"error": "Human-readable message",
"code": "ERROR_CODE"
}

Common Parameters

Pagination

List endpoints support cursor-based pagination:

ParameterTypeDefaultDescription
limitnumber20Results per page (1-100)
cursorstring-Pagination cursor from previous response

Example:

Terminal window
# First page
curl "http://localhost:3000/api/threads?limit=10"
# Next page
curl "http://localhost:3000/api/threads?limit=10&cursor=abc123"

Filtering

Most list endpoints support filtering:

ParameterDescription
serverIdFilter by Discord server
channelIdFilter by forum channel
tagFilter by thread tag
statusFilter by thread status

Caching

The API implements caching for expensive operations:

EndpointCache TTL
/servers/:id/stats60 seconds
/leaderboard/:serverId120 seconds

Cache status is returned in headers:

X-Cache: HIT
X-Cache-TTL: 45

Rate Limiting

Currently, there are no hard rate limits on the API. However:

  • Expensive endpoints are cached
  • Abuse may result in IP blocking
  • Consider implementing client-side caching

SDKs & Libraries

No official SDKs yet, but the API works great with:

  • fetch / axios in JavaScript
  • requests in Python
  • curl from command line
  • Any HTTP client in any language

Example: JavaScript Fetch

const API_BASE = 'http://localhost:3000/api';
async function getThreads(serverId, options = {}) {
const params = new URLSearchParams({
serverId,
limit: options.limit || 20,
...(options.cursor && { cursor: options.cursor }),
...(options.status && { status: options.status }),
});
const response = await fetch(`${API_BASE}/threads?${params}`);
return response.json();
}
// Usage
const { threads, hasMore, nextCursor } = await getThreads('123456789', {
limit: 10,
status: 'resolved'
});

Next Steps