Errori
Le chiamate in stile TMDB restituiscono gli errori nel corpo TMDB: success false, uno status_code numerico e uno status_message. Le chiamate in stile OMDb restituiscono Response False con una stringa Error. amodb usa 8 codici TMDB, da 7 per una chiave non valida a 25 per il limite e 36 per un piano scaduto. Riprova solo 429, 500 e 504.
Corpo dell'errore in stile TMDB
Ogni errore di https:/ ha la stessa forma JSON di TMDB:
{
"success": false,
"status_code": 34,
"status_message": "The resource you requested could not be found."
}Codici di errore
| HTTP | status_code | status_message | Cosa fare |
|---|---|---|---|
| 401 | 7 | Invalid API key: You must be granted a valid key. | Controlla la chiave e come la invii. |
| 401 | 10 | Suspended API key: Access to your account has been suspended, contact amodb. | Scrivi a support@amodb.dev. |
| 402 | 36 | Your plan has expired. Renew at https://amodb.dev/pricing | Paga un nuovo periodo. |
| 404 | 34 | The resource you requested could not be found. | Controlla l'ID o il percorso. |
| 405 | 37 | This method is not offered by amodb. | Usa un endpoint di lettura. |
| 429 | 25 | Your request count (N) is over the allowed limit of (L). | Attendi i secondi indicati da Retry-After. |
| 500 | 11 | Internal error: Something went wrong, contact amodb. | Riprova dopo qualche secondo. |
| 504 | 24 | Your request to the backend server timed out. Try again. | Riprova dopo qualche secondo. |
Corpo dell'errore in stile OMDb
L'endpoint compatibile con OMDb mantiene la forma e le parole di OMDb:
Una chiamata OMDb con r=xml restituisce HTTP 400. Usa r=json oppure ometti r.
{
"Response": "False",
"Error": "Movie not found!"
}const res = await fetch("https://api.amodb.dev/3/movie/550", {
headers: { Authorization: `Bearer ${process.env.AMODB_KEY}` },
});
if (!res.ok) {
const err = await res.json();
if (res.status === 429) {
// wait Retry-After seconds, then retry
}
throw new Error(`amodb ${res.status} code ${err.status_code}: ${err.status_message}`);
}res = requests.get(url, headers=headers, timeout=10)
if not res.ok:
err = res.json()
raise RuntimeError(f"amodb {res.status_code} code {err['status_code']}: {err['status_message']}")Ripieghi che non sono errori
- Un tag
languagesconosciuto non fa fallire la chiamata. amodb serve l'inglese. - Un campo senza dati è
nullo un array vuoto, come in TMDB.