Error Handling
Understanding and handling Wryn API errors.
Error Response Format
All errors return this structure:
{
"error": {
"code": "invalid_request",
"message": "The 'url' parameter is required",
"details": {
"parameter": "url"
}
}
}
HTTP Status Codes
| Status | Meaning | Action |
|---|---|---|
| 200 | Success | Request completed |
| 400 | Bad Request | Fix request parameters |
| 401 | Unauthorized | Check API key |
| 403 | Forbidden | Contact support |
| 404 | Not Found | Verify endpoint URL |
| 429 | Too Many Requests | Implement rate limiting |
| 500 | Server Error | Retry or contact support |
Error Codes
Authentication Errors
unauthorized - Invalid API key
{
"error": {
"code": "unauthorized",
"message": "Invalid API key"
}
}
forbidden - IP not whitelisted
{
"error": {
"code": "forbidden",
"message": "IP address not whitelisted"
}
}
Request Errors
invalid_request - Missing or invalid parameters
invalid_url - URL format is invalid
rate_limit_exceeded - Too many requests
Scraping Errors
page_not_found - Target page returned 404
timeout - Request took too long
blocked - Unable to bypass anti-bot protection
Error Handling Example
import requests
try:
response = requests.post(
'https://api.wryn.io/v1/scrape',
headers={'Authorization': f'Bearer {api_key}'},
json={'url': 'https://example.com'}
)
response.raise_for_status()
data = response.json()
except requests.exceptions.HTTPError as e:
if e.response.status_code == 429:
# Rate limited - wait and retry
time.sleep(60)
retry()
elif e.response.status_code == 401:
# Invalid API key
print("Check your API key")
else:
print(f"Error: {e.response.json()['error']['message']}")