JSON API¶
REST API for external frontend apps with JWT token authentication.
Overview¶
FastAPI Admin Kit provides a JSON API alongside the HTML admin panel. The API shares the same RBAC system, making it easy to build custom frontends or mobile apps.
Endpoints¶
The API is mounted at /admin/api/ by default.
Authentication¶
| Method | Endpoint | Description |
|---|---|---|
POST |
/admin/api/auth/login |
Obtain JWT token pair |
POST |
/admin/api/auth/refresh |
Refresh access token |
POST |
/admin/api/auth/logout |
Invalidate refresh token |
GET |
/admin/api/auth/me |
Get current user info |
CRUD¶
| Method | Endpoint | Description |
|---|---|---|
GET |
/admin/api/{model}/ |
List records |
POST |
/admin/api/{model}/ |
Create record |
GET |
/admin/api/{model}/{id} |
Get single record |
PUT |
/admin/api/{model}/{id} |
Update record |
DELETE |
/admin/api/{model}/{id} |
Delete record |
Roles¶
| Method | Endpoint | Description |
|---|---|---|
GET |
/admin/api/roles/ |
List roles |
POST |
/admin/api/roles/ |
Create role |
GET |
/admin/api/roles/{id} |
Get role |
PUT |
/admin/api/roles/{id} |
Update role |
DELETE |
/admin/api/roles/{id} |
Delete role |
Search¶
| Method | Endpoint | Description |
|---|---|---|
GET |
/admin/api/search?q={query} |
Search across models |
Authentication¶
Token Obtain¶
curl -X POST http://localhost:8000/admin/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "mypassword"}'
Response:
Using the Token¶
Token Refresh¶
curl -X POST http://localhost:8000/admin/api/auth/refresh \
-H "Content-Type: application/json" \
-d '{"refresh_token": "eyJ..."}'
Requirements¶
The JSON API requires the pyjwt package:
RBAC¶
The API uses the same permission system as the HTML admin:
- Users can only access models they have
viewpermission for - Create/edit/delete require corresponding permissions
- Superusers bypass all permission checks
Schema Generation¶
Auto-generated JSON schemas are available for each model:
Next Steps¶
- Authentication & RBAC — Set up permissions
- Configuration — Admin options