Error Response Format
All API errors follow a consistent JSON structure that makes it easy to parse and handle errors programmatically.Standard Error Response
Response Fields
| Field | Type | Description |
|---|---|---|
meta.code | integer | Internal error code for categorizing errors |
meta.message | string | Human-readable error title |
meta.description | string | Detailed error description (optional) |
HTTP Status Codes
The API uses standard HTTP status codes to indicate the type of error:200 OK
Request succeeded
400 Bad Request
Invalid request parameters or malformed request body
401 Unauthorized
Missing or invalid authentication token
404 Not Found
Resource not found or endpoint doesn’t exist
500 Internal Server Error
Server error or unexpected exception
Error Codes
The API uses internal error codes in addition to HTTP status codes for more granular error handling:Common Error Codes
errors.py
Error Code Reference
| Code | HTTP Status | Error Type | Description |
|---|---|---|---|
200 | 200 | OK | Request completed successfully |
10 | 404 | Not Supported | Method or endpoint not supported |
21 | 404 | User Not Exists | User account not found |
22 | 400 | Password Not Match | Invalid password provided |
77 | 500 | Database Rollback | Database transaction failed |
88 | 400 | Invalid Parameter | Request parameter validation failed |
99 | 401 | Auth Required | Authentication token required or invalid |
500 | 500 | Unknown Error | Unexpected server error |
Always check both the HTTP status code and the internal error code for comprehensive error handling.
Error Classes
The API defines custom exception classes for different error scenarios:AppError (Base Class)
InvalidParameterError
Raised when request parameters fail validation:UnauthorizedError
Raised for authentication and authorization failures:UserNotExistsError
Raised when a user account cannot be found:DatabaseError
Raised for database operation failures:NotSupportedError
Raised when an endpoint or method is not supported:Common Error Scenarios
Authentication Errors
Expired Token
Expired Token
HTTP Status: 401 Unauthorized
Error Code: 99How to Handle:
Error Code: 99
- Clear local authentication token
- Redirect user to login page
- Implement token refresh mechanism
Blocked Account
Blocked Account
HTTP Status: 401 Unauthorized
Error Code: 99How to Handle:
Error Code: 99
- Display customer support contact information
- Log out the user immediately
- Prevent further API requests
Two-Factor Authentication Mismatch
Two-Factor Authentication Mismatch
HTTP Status: 401 Unauthorized
Error Code: 99Occurs when:
Error Code: 99Occurs when:
- User has 2FA enabled but provides a non-2FA token (or vice versa)
- Token prefix “2f.” doesn’t match user’s 2FA status
Validation Errors
Missing Required Parameter
Missing Required Parameter
HTTP Status: 400 Bad Request
Error Code: 88How to Handle:
Error Code: 88
- Validate request parameters before sending
- Display field-specific error messages to users
- Check API documentation for required fields
Invalid Parameter Value
Invalid Parameter Value
HTTP Status: 400 Bad Request
Error Code: 88
Error Code: 88
Resource Errors
User Not Found
User Not Found
HTTP Status: 404 Not Found
Error Code: 21
Error Code: 21
Endpoint Not Supported
Endpoint Not Supported
HTTP Status: 404 Not Found
Error Code: 10
Error Code: 10
Server Errors
Database Error
Database Error
HTTP Status: 500 Internal Server Error
Error Code: 77How to Handle:
Error Code: 77
- Implement retry logic with exponential backoff
- Log error details for debugging
- Display generic error message to users
Unknown Error
Unknown Error
HTTP Status: 500 Internal Server Error
Error Code: 500How to Handle:
Error Code: 500
- Retry the request once
- Log the full request/response for investigation
- Contact API support if error persists
Best Practices
1. Check HTTP Status First
Always check the HTTP status code before parsing the response body:2. Handle Authentication Errors Globally
Implement a global handler for 401 errors:3. Implement Retry Logic
Retry failed requests with exponential backoff:4. Display User-Friendly Messages
Map technical errors to user-friendly messages:5. Log Errors for Debugging
Always log error details in development:The API includes detailed error descriptions to help with debugging. Always check the
description field for additional context.Error Handling in Production
The API includes a global error handler that catches unhandled exceptions:main.py
- All exceptions are logged for monitoring
- Sensitive information is not exposed to clients
- Consistent error format is maintained
- Database connections are properly cleaned up
Contact Support
If you encounter persistent errors or need assistance:- Check the API documentation for correct usage
- Review your request parameters and authentication
- Contact technical support with error codes and timestamps