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.

Aggiornato il Vedi in Markdown

Corpo dell'errore in stile TMDB

Ogni errore di https://api.amodb.dev/3 ha la stessa forma JSON di TMDB:

JSON
{
  "success": false,
  "status_code": 34,
  "status_message": "The resource you requested could not be found."
}

Codici di errore

HTTPstatus_codestatus_messageCosa fare
4017Invalid API key: You must be granted a valid key.Controlla la chiave e come la invii.
40110Suspended API key: Access to your account has been suspended, contact amodb.Scrivi a support@amodb.dev.
40236Your plan has expired. Renew at https://amodb.dev/pricingPaga un nuovo periodo.
40434The resource you requested could not be found.Controlla l'ID o il percorso.
40537This method is not offered by amodb.Usa un endpoint di lettura.
42925Your request count (N) is over the allowed limit of (L).Attendi i secondi indicati da Retry-After.
50011Internal error: Something went wrong, contact amodb.Riprova dopo qualche secondo.
50424Your 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.

JSON
{
  "Response": "False",
  "Error": "Movie not found!"
}
jspy
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 language sconosciuto non fa fallire la chiamata. amodb serve l'inglese.
  • Un campo senza dati è null o un array vuoto, come in TMDB.