Errors
The Repurai API uses standard HTTP status codes and returns the same JSON format for every error.
Error format
{
"error": "NOT_FOUND",
"message": "No feed with that ID exists in your workspace",
"status": 404
}
| Field | Type | Description |
|---|---|---|
error | string | A short code identifying the type of error. |
message | string | A plain-English description of what went wrong. |
status | integer | The HTTP status code (same as the response status). |
Error codes
| Code | HTTP Status | Meaning |
|---|---|---|
UNAUTHORIZED | 401 | The Authorization header is missing, incorrect, or the API key is invalid. |
FORBIDDEN | 403 | The API key is valid but doesn't have access to this resource. |
NOT_FOUND | 404 | The requested resource doesn't exist or isn't in your workspace. |
VALIDATION_ERROR | 422 | Something in the request body or URL parameters is invalid. Check message for details. |
SERVER_ERROR | 500 | Something went wrong on our end. |
Handling errors
Always check the HTTP status code before reading the response body:
const res = await fetch('https://repurai.com/api/v1/feeds', {
headers: { Authorization: `Bearer ${process.env.REPURAI_API_KEY}` },
})
if (!res.ok) {
const err = await res.json()
console.error(`[${err.error}] ${err.message}`)
if (res.status === 401) { /* check your API key */ }
if (res.status === 404) { /* resource doesn't exist */ }
return
}
const data = await res.json()
import requests, os
res = requests.get(
'https://repurai.com/api/v1/feeds',
headers={'Authorization': f"Bearer {os.environ['REPURAI_API_KEY']}"},
)
if not res.ok:
err = res.json()
print(f"[{err['error']}] {err['message']}")
else:
data = res.json()