Error Handling

The ZentyGents API uses conventional HTTP response codes to indicate success or failure of requests. All errors return a JSON object with an error message and code.

Error Response Format

{
  "success": false,
  "error": {
    "code": 404,
    "message": "Resource not found"
  }
}

Common Error Codes

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Insufficient permissions
404Not Found - Resource not found
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Something went wrong

Handling Errors

try {
  const balance = await client.wallets.getBalance(address);
} catch (error) {
  if (error.response?.status === 404) {
    console.error('Wallet not found');
  } else if (error.response?.status === 429) {
    console.error('Rate limit exceeded');
  } else {
    console.error('API Error:', error.message);
  }
}