Erori
Apelurile în stil TMDB întorc erorile în corpul TMDB: success false, un status_code numeric și un status_message. Apelurile în stil OMDb întorc Response False cu un șir Error. amodb folosește 8 coduri TMDB, de la 7 pentru o cheie invalidă la 25 pentru limita de cereri și 36 pentru un plan expirat. Reîncearcă doar 429, 500 și 504.
Corpul de eroare în stil TMDB
Fiecare eroare de la https:/ are aceeași formă JSON ca în TMDB:
{
"success": false,
"status_code": 34,
"status_message": "The resource you requested could not be found."
}Coduri de eroare
| HTTP | status_code | status_message | Ce să faci |
|---|---|---|---|
| 401 | 7 | Invalid API key: You must be granted a valid key. | Verifică cheia și modul în care o trimiți. |
| 401 | 10 | Suspended API key: Access to your account has been suspended, contact amodb. | Scrie la support@amodb.dev. |
| 402 | 36 | Your plan has expired. Renew at https://amodb.dev/pricing | Plătește o perioadă nouă. |
| 404 | 34 | The resource you requested could not be found. | Verifică ID-ul sau calea. |
| 405 | 37 | This method is not offered by amodb. | Folosește un endpoint de citire. |
| 429 | 25 | Your request count (N) is over the allowed limit of (L). | Așteaptă Retry-After secunde. |
| 500 | 11 | Internal error: Something went wrong, contact amodb. | Reîncearcă după câteva secunde. |
| 504 | 24 | Your request to the backend server timed out. Try again. | Reîncearcă după câteva secunde. |
Corpul de eroare în stil OMDb
Endpoint-ul compatibil OMDb păstrează forma și formularea OMDb:
Un apel OMDb cu r=xml întoarce HTTP 400. Folosește r=json sau omite 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']}")Situații de rezervă care nu sunt erori
- O etichetă
languagenecunoscută nu produce eroare. amodb servește engleza pentru ea. - Un câmp fără date este
nullsau un array gol, ca în TMDB.