Error Handling
All SieloTech APIs use standard HTTP status codes to indicate the success or failure of requests. This page provides information about how to handle errors when using our APIs.
HTTP Status Codes
The API returns appropriate HTTP status codes for various error conditions. Common status codes include:
Status Code | Description |
---|---|
200 OK | The request was successful |
401 Unauthorized | Invalid or missing API key |
403 Forbidden | The API key doesn't have permission to perform the request |
404 Not Found | The requested resource doesn't exist |
422 Unprocessable Entity | Validation error on request data |
429 Too Many Requests | Rate limit exceeded |
500 Internal Server Error | An error occurred on our server |
FastAPI Validation Errors
Since our API is built with FastAPI, validation errors return in FastAPI's standard format. These typically occur with a 422 Unprocessable Entity status code when request validation fails:
{
"detail": [
{
"type": "missing",
"loc": [
"body",
"text"
],
"msg": "Field required",
"input": {
"tsext": "日本語の車は大好きです",
"mode": "dictionary"
}
}
]
}
In the example above, the request failed because the required text
field is missing, but there was a typo in the input (tsext
instead of text
). The validation error provides details about:
type
: The type of error (missing, value_error, etc.)loc
: The location of the error (body, query, path) followed by the specific fieldmsg
: A human-readable error messageinput
: The actual input that was received
Best Practices for Error Handling
When working with SieloTech APIs, follow these best practices for handling errors:
- Always check the HTTP status code before processing the response
- Implement appropriate retry logic for 429 and 5xx errors
- Log detailed error information for troubleshooting
- Display user-friendly error messages in your application