API Reference¶
This section provides complete API documentation for litestar-admin, including both the REST API and Python API.
REST API¶
Complete REST API reference for litestar-admin. All endpoints are prefixed with /admin by default (configurable via AdminConfig.base_url).
Base URL¶
{your-app-url}/admin/api
Authentication¶
Most endpoints require authentication. Include the access token in the Authorization header:
Authorization: Bearer <access_token>
Alternatively, tokens can be sent via cookies if configured in your auth backend.
Response Format¶
All responses use JSON format. Successful responses return the requested data directly. Error responses follow this structure:
{
"detail": "Error message describing what went wrong",
"status_code": 400
}
Quick Reference¶
Authentication Endpoints¶
Method |
Endpoint |
Description |
|---|---|---|
POST |
|
Authenticate with credentials |
POST |
|
End current session |
POST |
|
Refresh access token |
GET |
|
Get current user info |
Model Endpoints¶
Method |
Endpoint |
Description |
|---|---|---|
GET |
|
List registered models |
GET |
|
List records |
POST |
|
Create record |
GET |
|
Get single record |
PUT |
|
Full update |
PATCH |
|
Partial update |
DELETE |
|
Delete record |
GET |
|
Get JSON schema |
Dashboard Endpoints¶
Method |
Endpoint |
Description |
|---|---|---|
GET |
|
Get model statistics |
GET |
|
Get recent activity |
Export Endpoints¶
Method |
Endpoint |
Description |
|---|---|---|
GET |
|
Export all records (CSV, JSON, XLSX) |
POST |
|
Export selected records |
Import Endpoints¶
Method |
Endpoint |
Description |
|---|---|---|
POST |
|
Preview CSV with auto-detection |
POST |
|
Validate with column mappings |
POST |
|
Execute batch import |
Bulk Action Endpoints¶
Method |
Endpoint |
Description |
|---|---|---|
POST |
|
Bulk delete records |
POST |
|
Custom bulk action |
HTTP Status Codes¶
Code |
Description |
|---|---|
200 |
Success |
201 |
Created (for POST creating new records) |
400 |
Bad Request (invalid input) |
401 |
Unauthorized (not authenticated) |
403 |
Forbidden (insufficient permissions) |
404 |
Not Found (model or record doesn’t exist) |
422 |
Validation Error |
429 |
Too Many Requests (rate limited) |
500 |
Internal Server Error |
Rate Limiting¶
When rate limiting is enabled, responses include these headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
If the limit is exceeded, you’ll receive a 429 status code:
{
"error": "Too Many Requests",
"retry_after": 60
}
OpenAPI Schema¶
The API is fully documented with OpenAPI 3.0. Access the interactive documentation at:
Swagger UI:
/schema/swaggerReDoc:
/schema/redocOpenAPI JSON:
/schema/openapi.json
These are provided by Litestar’s built-in OpenAPI support.
Python API¶
Core Classes¶
Class |
Description |
|---|---|
|
Main plugin implementing Litestar’s InitPluginProtocol |
|
Configuration dataclass for the admin panel |
|
Base class for model views with model binding |
|
Foundation class for model views |
|
Registry for managing model views |
|
Service layer for CRUD operations |
Authentication¶
Class |
Description |
|---|---|
|
JWT-based authentication backend |
|
Configuration for JWT authentication |
|
Protocol for authentication backends |
|
Protocol for admin user objects |
Guards & Permissions¶
Item |
Description |
|---|---|
|
Enum of available permissions |
|
Enum of available roles |
|
Guard that checks permissions |
|
Guard that checks roles |
|
Factory for permission guards |
|
Factory for role guards |
Audit Logging¶
Class |
Description |
|---|---|
|
Enum of auditable actions |
|
Single audit log entry |
|
Protocol for audit backends |
|
In-memory audit logger |
|
Helper to create audit entries |
Rate Limiting¶
Class |
Description |
|---|---|
|
Rate limiting middleware |
|
Rate limit configuration |
|
In-memory rate limit store |