Błędy
Wywołania w stylu TMDB zwracają błędy w treści TMDB: success false, liczbowy status_code i status_message. Wywołania w stylu OMDb zwracają Response False z ciągiem Error. amodb używa 8 kodów TMDB, od 7 dla nieprawidłowego klucza przez 25 dla limitu żądań po 36 dla wygasłego planu. Ponawiaj tylko 429, 500 i 504.
Treść błędu w stylu TMDB
Każdy błąd z https:/ ma ten sam kształt JSON co w TMDB:
{
"success": false,
"status_code": 34,
"status_message": "The resource you requested could not be found."
}Kody błędów
| HTTP | status_code | status_message | Co zrobić |
|---|---|---|---|
| 401 | 7 | Invalid API key: You must be granted a valid key. | Sprawdź klucz i sposób jego wysyłania. |
| 401 | 10 | Suspended API key: Access to your account has been suspended, contact amodb. | Napisz na support@amodb.dev. |
| 402 | 36 | Your plan has expired. Renew at https://amodb.dev/pricing | Opłać nowy okres. |
| 404 | 34 | The resource you requested could not be found. | Sprawdź ID lub ścieżkę. |
| 405 | 37 | This method is not offered by amodb. | Użyj endpointu odczytu. |
| 429 | 25 | Your request count (N) is over the allowed limit of (L). | Poczekaj tyle sekund, ile podaje Retry-After. |
| 500 | 11 | Internal error: Something went wrong, contact amodb. | Ponów po kilku sekundach. |
| 504 | 24 | Your request to the backend server timed out. Try again. | Ponów po kilku sekundach. |
Treść błędu w stylu OMDb
Endpoint zgodny z OMDb zachowuje kształt i sformułowania OMDb:
Wywołanie OMDb z r=xml zwraca HTTP 400. Użyj r=json albo pomiń 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']}")Zachowania zastępcze, które nie są błędami
- Nieznany tag
languagenie powoduje błędu. amodb zwraca dla niego angielski. - Pole bez danych ma wartość
nullalbo jest pustą tablicą, tak jak w TMDB.