5.2 KiB
Manager API Documentation Guide
Swagger/OpenAPI Documentation
The Manager API includes built-in Swagger/OpenAPI documentation using SpringDoc OpenAPI v2.8.8.
Accessing Swagger UI
Once the Manager API is running, you can access the interactive API documentation at:
http://localhost:8080/swagger-ui/index.html
Replace localhost:8080 with your actual server address and port.
API Groups
The API is organized into the following groups:
-
Device APIs (
/device/**)- Device registration
- Device management
- Device binding/unbinding
- Device status reporting
-
Agent APIs (
/agent/**)- Agent management
- Agent configuration
- Agent templates
- Chat history
- Memory management
- Voice print management
- MCP access points
-
Model APIs (
/models/**)- Model configuration
- Model providers
- Voice models
- LLM models
- TTS/ASR/VAD models
-
OTA APIs (
/ota/**)- Over-the-air updates
- Firmware management
- Update status
-
Timbre APIs (
/ttsVoice/**)- TTS voice management
- Voice configuration
-
Admin APIs (
/admin/**)- User management
- System administration
- Server management
-
User APIs (
/user/**)- User authentication
- User profile
- Password management
-
Config APIs (
/config/**)- System configuration
- Agent model configuration
OpenAPI JSON Specification
You can access the raw OpenAPI specification at:
http://localhost:8080/v3/api-docs
For specific API groups:
http://localhost:8080/v3/api-docs/device
http://localhost:8080/v3/api-docs/agent
http://localhost:8080/v3/api-docs/models
http://localhost:8080/v3/api-docs/ota
http://localhost:8080/v3/api-docs/timbre
http://localhost:8080/v3/api-docs/admin
http://localhost:8080/v3/api-docs/user
http://localhost:8080/v3/api-docs/config
Key API Endpoints
Authentication
POST /login- User loginPOST /logout- User logoutPOST /user/register- User registration
Agent Management
GET /agent/list- Get user's agentsGET /agent/{id}- Get agent detailsPOST /agent- Create new agentPUT /agent/{id}- Update agentDELETE /agent/{id}- Delete agentPUT /agent/saveMemory/{macAddress}- Update agent memory
Device Management
POST /device/register- Register devicePOST /device/bind- Bind device to userPOST /device/unbind- Unbind deviceGET /device/list- Get user's devicesPOST /device/report- Device status report
Model Configuration
GET /models/provider- Get model providersPOST /models/provider- Add model providerPUT /models/provider/{id}- Update model providerDELETE /models/provider/{id}- Delete model providerGET /models/config- Get model configurationsGET /models/voice/{modelId}- Get voice options for TTS model
Configuration
GET /config/agentModels- Get agent model configurationPOST /config/agentModels- Update agent model configuration
API Authentication
Most API endpoints require authentication. The API uses Shiro for security:
- Login to get a session token:
POST /login
Content-Type: application/json
{
"username": "your-username",
"password": "your-password"
}
-
Use the token in subsequent requests (stored in cookies/session)
-
Permissions are role-based:
sys:role:normal- Normal user permissionssys:role:superAdmin- Administrator permissions
Example API Calls
Create Memory Provider
POST /models/provider
Content-Type: application/json
{
"modelType": "Memory",
"providerCode": "mem0ai",
"name": "Mem0 Memory Provider",
"fields": [
{
"key": "api_key",
"label": "API Key",
"type": "password",
"value": "your-mem0-api-key"
}
],
"sort": 1
}
Update Agent Memory
PUT /agent/saveMemory/{macAddress}
Content-Type: application/json
{
"summaryMemory": "Memory configuration instructions"
}
Get Agent Configuration
GET /agent/{agentId}
Data Models
The API uses DTOs (Data Transfer Objects) for request/response:
- AgentDTO - Agent information
- AgentMemoryDTO - Agent memory update
- DeviceDTO - Device information
- ModelConfigDTO - Model configuration
- ModelProviderDTO - Model provider configuration
All DTOs include Swagger annotations for documentation.
Error Handling
The API returns standardized error responses:
{
"code": 0, // 0 for success, non-zero for errors
"msg": "Success or error message",
"data": {} // Response data
}
Common error codes:
401- Unauthorized403- Forbidden404- Not found500- Internal server error
Development Tips
- Use Swagger UI for testing APIs directly in the browser
- Check annotations in controller classes for detailed API documentation
- Review DTOs for request/response structures
- Monitor logs for debugging API issues
Additional Resources
- Controller classes in:
src/main/java/xiaozhi/modules/*/controller/ - DTO classes in:
src/main/java/xiaozhi/modules/*/dto/ - Entity classes in:
src/main/java/xiaozhi/modules/*/entity/ - Service implementations in:
src/main/java/xiaozhi/modules/*/service/