API Service
Deliver JSON APIs with keys, CORS, and rate limits.
The api Service returns JSON responses through services/api.php and helper classes in core/classes/api-class.php.
Health Endpoint
/api/v1/health
Use it to validate availability and response shape.
Authentication
Supply an API key using:
Authorization: Bearer <key>X-API-Key: <key>?api_key=<key>
Keys are read from API_KEYS in .env (comma-separated).
Resource Routing
After /api/v1, the next segment is treated as an Action class name. If the class exists, JamilX calls getApi() to render JSON.
/api/v1/apihome → class apihome → getApi()
Response Shape
successmessagedataerrorsmeta
CORS
Configure API_CORS_ALLOWLIST in .env to allow all origins (*) or specify a comma-separated list.
Rate Limits
Set API_RATE_LIMIT and API_RATE_WINDOW for API usage control. Rate limit buckets persist under data/api_rate_limit.json.
Quick Request
curl -H "X-API-Key: your-key" http://localhost/api/v1/apihome