API Documentation
Complete API reference for LuaBeans - Community Manager FiveM integration.
Overview
LuaBeans - Community Manager provides a REST API for FiveM resources to access department information, duty state, and user data. The API uses Bearer token authentication and returns JSON data.
Base URL
All API endpoints are prefixed with:
https://your-domain.com/api/leoAuthentication
All API requests must include a Bearer token in the Authorization header:
Authorization: Bearer YOUR_LEO_API_TOKENThe token must match the LEO_API_TOKEN value in your web panel's .env file.
Endpoints
GET /api/leo/user/:discordId/departments
Fetches a player's departments and ranks.
URL: /api/leo/user/:discordId/departments
Method: GET
Authentication: Required (Bearer token)
URL Parameters:
discordId(required) - Player's Discord ID
Headers:
Response (Success - 200):
Response (Error - 401):
Response (Error - 404):
Response (Error - 500):
Example (Lua):
POST /api/leo/duty/:action
Updates a player's duty state.
URL: /api/leo/duty/:action
Method: POST
Authentication: Required (Bearer token)
URL Parameters:
action(required) -onoroff
Headers:
Body (for on action):
Body (for off action):
Response (Success - 200):
Response (Error - 400):
Response (Error - 401):
Example (Lua - On Duty):
Example (Lua - Off Duty):
Response Format
Success Response
All successful responses follow this format:
Error Response
All error responses follow this format:
Error Codes
200
OK
Request successful
400
Bad Request
Invalid request parameters
401
Unauthorized
Missing or invalid authentication token
404
Not Found
Resource not found (user, department, etc.)
500
Internal Server Error
Server error
Rate Limiting
API requests are rate-limited to prevent abuse:
Default limit: 200 requests per minute per IP
Rate limit headers: Standard rate limit headers included
Rate limit exceeded: Returns 429 Too Many Requests
Best Practices
Cache Responses - Cache department data locally (LuaBeans Bridge caches for 5 minutes)
Handle Errors - Always check
okfield in responsesUse HTTPS - Always use HTTPS in production
Secure Token - Never expose API token in client-side code
Validate Input - Validate Discord IDs and department IDs before requests
Integration Examples
Using with ESX
Using with Custom Resources
Troubleshooting
Authentication Errors
Error: 401 Unauthorized
Solutions:
Verify
LEO_API_TOKENmatches in both FiveM config and web panel.envCheck token is sent in Authorization header
Verify token hasn't expired or been changed
Check token format:
Bearer YOUR_TOKEN
User Not Found
Error: 404 Not Found
Solutions:
Verify player has Discord identifier:
discord:123456789012345678Check Discord ID is correct format (18-19 digits)
Verify user exists in database (try logging into web panel)
Sync user data:
/syncmecommand in Discord or "Refresh roles" in web panel
Connection Errors
Error: Cannot connect to API
Solutions:
Verify
LUABEANS_API_BASEis correct and accessibleCheck web panel is running
Verify firewall allows connection from FiveM server
Check SSL certificate is valid (if using HTTPS)
Test API endpoint manually with curl
Rate Limiting
Error: 429 Too Many Requests
Solutions:
Implement caching (LuaBeans Bridge does this automatically)
Reduce request frequency
Use cached data instead of frequent API calls
Wait for rate limit to reset (usually 1 minute)
Related Documentation
LuaBeans Bridge - FiveM integration resource
LuaBeans Duty - Duty system UI
FiveM Configuration - Complete FiveM setup
Last updated
