Access Methods
API docs are auto-generated by FastAPI in two formats:
| Format | Local | Online |
|---|---|---|
| Swagger UI | http://127.0.0.1:8001/docs | https://service.fastapiadmin.com/api/v1/docs |
| Redoc | http://127.0.0.1:8001/redoc | https://service.fastapiadmin.com/api/v1/redoc |
Usage
- Open Swagger UI, click Authorize (top right)
- Enter username and password
- Find endpoint → Try it out → fill params → Execute
API Categories
- System Management: Users, roles, menus, departments, positions
- Monitoring: Online users, server, cache
- Task Management: Scheduled tasks
- Log Management: Operation logs
- Development Tools: Code generation, form builder
Response Format
All APIs use a unified format:
json
{
"code": 200,
"message": "success",
"data": {}
}Pagination
json
{
"code": 200,
"message": "success",
"data": {
"items": [],
"total": 100,
"page": 1,
"pageSize": 10
}
}Frontend API Usage
Web
API modules under frontend/web/src/api/:
typescript
import { authApi } from '@/api/module_system/auth'
const login = async (username: string, password: string) => {
const res = await authApi.login({ username, password })
// Save token, fetch user info, redirect
}Mobile
API modules under frontend/app/src/api/:
typescript
import { authApi } from '@/api/auth'
const login = async (username: string, password: string) => {
const res = await authApi.login({ username, password })
userStore.setToken(res.data.token)
uni.switchTab({ url: '/pages/index/index' })
}API Design Standards
| Standard | Description |
|---|---|
| URL | Lowercase + underscore, plural resources, version in prefix |
| GET | Retrieve resource |
| POST | Create resource |
| PUT | Update resource |
| DELETE | Delete resource |
FAQ
| Issue | Solution |
|---|---|
| 401 Auth failure | Check login state, re-login |
| 403 Insufficient permission | Contact admin for permissions |
| 422 Parameter error | Verify request parameters |
| 500 Server error | Check backend logs |