Error Handling
DExchange API uses conventional HTTP response codes to indicate the success or failure of API requests. Here’s a comprehensive guide to our error codes and how to handle them.HTTP Status Codes
Status Code | Description |
---|---|
200 | Success - The request was processed successfully |
201 | Created - The resource was created successfully |
400 | Bad Request - Invalid request parameters or validation failed |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Valid API key but insufficient permissions |
404 | Not Found - The requested resource doesn’t exist |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Something went wrong on our end |
Error Response Format
Common Error Scenarios
Authentication Errors
Validation Errors
Transaction Errors
Best Practices for Error Handling
-
Always Check Response Status
- Verify HTTP status code before processing response
- Handle both success and error cases
-
Implement Retry Logic
- Retry failed requests with exponential backoff
- Only retry idempotent operations
- Respect rate limits
-
Log Error Details
- Store error responses for debugging
- Include transaction IDs in logs
- Monitor error patterns
-
User-Friendly Messages
- Display appropriate error messages to end-users
- Translate technical errors into user-friendly language
- Provide clear next steps when possible
-
Security Considerations
- Never expose sensitive information in error messages
- Validate all input data
- Handle timeouts gracefully
Maintenance Mode
When the API is under maintenance:Rate Limiting
- Requests are limited per API key
- Rate limit headers included in responses
- Implement proper backoff when limits are reached
Support
If you encounter persistent errors or need assistance:- Check our API Reference
- Contact support at team@dexchange.sn
- Include relevant transaction IDs and error messages