Overview
The API provides:4chan compatibility
JSON endpoints matching 4chan’s API structure
Bearer authentication
Token-based authentication for protected resources
Rate limiting
Configurable rate limits to prevent abuse
Moderation support
Filtered content based on user permissions
Enabling the API
The API must be explicitly enabled in configuration:When disabled, API endpoints return 404 errors
Base URL
All API endpoints are prefixed with:Authentication
Public access
Some endpoints work without authentication:- Catalog listings
- Thread data
- Board indexes
Authenticated access
Authenticated requests see additional content:- Reported posts (if user has permissions)
- Moderation-hidden posts (for moderators)
- Admin-only data
Obtaining a token
Token expiration
Tokens expire based on configuration:Core endpoints
Catalog
Get a paginated list of threads on a board:board: Board shortname (e.g.,g,a,pol)
src/ayase_quart/blueprints/api/bp_app.py:13
Thread
Get all posts in a thread:board: Board shortnamethread_id: Thread number (OP post number)
src/ayase_quart/blueprints/api/bp_app.py:23
Board index
Get a page of threads from the board index:board: Board shortnamepage_num: Page number (0-indexed)
src/ayase_quart/blueprints/api/bp_app.py:36
Response format
Post object
All posts follow this structure:Common fields
Common fields
no: Post number (unique ID)resto: Thread number (0 for OP, otherwise parent thread)time: Unix timestampnow: Formatted timestamp stringname: Poster namecom: Comment HTMLcapcode: Poster capcode (“none”, “mod”, “admin”)
OP-specific fields
OP-specific fields
sub: Thread subject/titlesemantic_url: URL-safe thread titlereplies: Total reply countimages: Total image countsticky: 1 if pinned, 0 otherwiseclosed: 1 if archived, 0 otherwise
Media fields
Media fields
filename: Original filename (without extension)ext: File extension (e.g., “.jpg”, “.png”, “.webm”)tim: Server timestamp for filemd5: Base64-encoded MD5 hashfsize: File size in bytesw: Image widthh: Image heighttn_w: Thumbnail widthtn_h: Thumbnail height
Optional fields
Optional fields
trip: Tripcodecountry: Country code (if enabled)country_name: Country nameemail: Email fieldspoiler: 1 if spoilered, 0 otherwise
Moderation endpoints
Moderation actions are available via API:Submit report
Nuke post (admin only)
Error responses
400 Bad Request
401 Unauthorized
404 Not Found
429 Too Many Requests
Rate limiting
API endpoints have rate limits:- Authenticated requests: Higher limits
- Unauthenticated requests: Lower limits
- Report submissions: 4 per hour per IP
Content filtering
API responses respect moderation settings:Unauthenticated requests
- Reported posts are hidden
- Moderation-hidden posts are hidden
- Deleted posts may be excluded
Authenticated requests
Based on user permissions:- Moderators see reported posts
- Admins see all posts
- Regular users see public posts
src/ayase_quart/moderation/filter_cache/
Testing the API
Using Bruno
A Bruno API collection is included:- Login flow
- All core endpoints
- Moderation actions
- Example requests
Using cURL
Using Python
API compatibility
4chan API compatibility
Ayase Quart maintains compatibility with the 4chan API format:- Same JSON structure
- Same field names
- Same endpoint paths (under
/api/v1)
- Authentication required for full access
- Additional moderation fields
- Filter cache affects results
- Asagi schema differences may result in missing fields
Lainchan compatibility
The API also supports Lainchan archives with the same format.Performance
API performance considerations:- Database queries: Optimized for Asagi schema
- Filter caching: Redis or SQLite cache for fast filtering
- Pagination: Large threads are not paginated (returned complete)
- Rate limiting: Protects against abuse
For large instances, ensure Redis is configured for optimal filter cache performance
Configuration
API settings inconfig.toml:
Best practices
Use authentication
Authenticate to see complete data and get higher rate limits
Handle rate limits
Implement exponential backoff when receiving 429 errors
Cache responses
Cache API responses to reduce load on your archive
Validate data
Check for missing fields - not all Asagi archives have complete data
- API blueprints:
src/ayase_quart/blueprints/api/ - Authentication:
src/ayase_quart/moderation/auth_api.py - Data conversion:
src/ayase_quart/asagi_converter.py