# Endpoint compatibile OMDb

> GET https://api.amodb.dev/omdb/ risponde a richieste in stile OMDb con gli stessi nomi. Cerca un titolo per ID IMDb con i o per titolo con t, oppure cerca con s. I link alle locandine puntano a img.amodb.dev. Sono serviti solo r=json, film e serie. Cambia l'URL di base e la chiave e un client tipico continua a funzionare.

## Endpoint

`GET /omdb/`

```bash
curl "https://api.amodb.dev/omdb/?i=tt0137523&plot=short&apikey=$AMODB_KEY"
```

Risposta:

```json
{
  "Title": "Fight Club",
  "Year": "1999",
  "Rated": "R",
  "Released": "15 Oct 1999",
  "Runtime": "139 min",
  "Genre": "Crime, Drama, Thriller",
  "Director": "David Fincher",
  "Writer": "Chuck Palahniuk, Jim Uhls",
  "Actors": "Brad Pitt, Edward Norton, Meat Loaf",
  "Plot": "A nameless first-person narrator attends support groups in an attempt to subdue his emotional state and relieve his insomniac state.",
  "Language": "English",
  "Country": "United States, Germany",
  "Awards": "Nominated for 1 Oscar. 12 wins & 38 nominations total",
  "Poster": "https://img.amodb.dev/t/p/w300/pfPob0mrC1KiPVP9NXZnqvpks9u.jpg",
  "Ratings": [
    {
      "Source": "Internet Movie Database",
      "Value": "8.8/10"
    },
    {
      "Source": "Rotten Tomatoes",
      "Value": "81%"
    },
    {
      "Source": "Metacritic",
      "Value": "67/100"
    }
  ],
  "Metascore": "67",
  "imdbRating": "8.8",
  "imdbVotes": "2,669,989",
  "imdbID": "tt0137523",
  "Type": "movie",
  "DVD": "N/A",
  "BoxOffice": "$38,003,039",
  "Production": "N/A",
  "Website": "N/A",
  "Response": "True"
}
```

## Cercare un titolo per ID IMDb o per titolo

`GET https://api.amodb.dev/omdb/` restituisce un titolo come JSON piatto con i nomi dei campi di OMDb. Passa `i` per un ID IMDb come `tt0137523`, oppure `t` per un titolo. L'autenticazione è il parametro di query `apikey`. La risposta ha `Response` impostato su `True` in caso di successo e su `False` in caso di errore.

L'esempio carica Fight Club per ID IMDb e si ferma con il testo di errore di OMDb quando `Response` è `False`.

```bash
curl -sf "https://api.amodb.dev/omdb/?i=tt0137523&plot=short&apikey=$AMODB_KEY"
```

```js
const params = new URLSearchParams({ i: 'tt0137523', plot: 'short', apikey: process.env.AMODB_KEY });
const res = await fetch(`https://api.amodb.dev/omdb/?${params}`);
if (!res.ok) throw new Error(`amodb returned ${res.status}`);
const data = await res.json();
if (data.Response === 'False') throw new Error(data.Error);
console.log(data.Title, data.Year, data.imdbRating);
```

```python
import os
import requests

r = requests.get(
    "https://api.amodb.dev/omdb/",
    params={"i": "tt0137523", "plot": "short", "apikey": os.environ["AMODB_KEY"]},
    timeout=10,
)
r.raise_for_status()
data = r.json()
if data["Response"] == "False":
    raise SystemExit(data["Error"])
print(data["Title"], data["Year"], data["imdbRating"])
```

```php
<?php
$query = http_build_query(['i' => 'tt0137523', 'plot' => 'short', 'apikey' => getenv('AMODB_KEY')]);
$ch = curl_init('https://api.amodb.dev/omdb/?' . $query);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
    throw new RuntimeException("amodb returned $status");
}
$data = json_decode($body, true);
if ($data['Response'] === 'False') {
    throw new RuntimeException($data['Error']);
}
echo $data['Title'], ' ', $data['Year'], ' ', $data['imdbRating'], PHP_EOL;
```

```go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"os"
	"time"
)

type Title struct {
	Title      string `json:"Title"`
	Year       string `json:"Year"`
	ImdbRating string `json:"imdbRating"`
	Response   string `json:"Response"`
	Error      string `json:"Error"`
}

func main() {
	q := url.Values{"i": {"tt0137523"}, "plot": {"short"}, "apikey": {os.Getenv("AMODB_KEY")}}
	client := &http.Client{Timeout: 10 * time.Second}
	res, err := client.Get("https://api.amodb.dev/omdb/?" + q.Encode())
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	if res.StatusCode != http.StatusOK {
		panic(res.Status)
	}
	var t Title
	if err := json.NewDecoder(res.Body).Decode(&t); err != nil {
		panic(err)
	}
	if t.Response == "False" {
		panic(t.Error)
	}
	fmt.Println(t.Title, t.Year, t.ImdbRating)
}
```

### Parametri

| Parametro | In    | Obbligatorio          | Descrizione                                                      |
| --------- | ----- | --------------------- | ---------------------------------------------------------------- |
| `apikey`  | query | sì                    | La tua chiave amodb.                                             |
| `i`       | query | uno tra `i`, `t`, `s` | ID IMDb del titolo: `tt` più 7-9 cifre, per esempio `tt0137523`. |
| `t`       | query | uno tra `i`, `t`, `s` | Titolo da cercare, restituisce la corrispondenza migliore.       |
| `s`       | query | uno tra `i`, `t`, `s` | Testo di ricerca di almeno 3 lettere, restituisce una lista.     |
| `type`    | query | no                    | `movie` o `series`. `episode` non trova nulla.                   |
| `y`       | query | no                    | Anno di uscita.                                                  |
| `plot`    | query | no                    | `short` o `full`. Predefinito `short`.                           |
| `page`    | query | no                    | Pagina dei risultati di ricerca, da 1 a 100. Si usa con `s`.     |
| `r`       | query | no                    | Solo `json`. Qualsiasi altro valore restituisce HTTP 400.        |

I parametri `Season`, `Episode`, `callback` e `v` dell'API OMDb originale non sono supportati e vengono ignorati.

### Campi della risposta

| Campo                                            | Note                                                                                                      |
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| `Title`, `Year`, `Rated`, `Released`, `Runtime`  | Testo. `Released` si legge come `15 Oct 1999`.                                                            |
| `Genre`, `Director`, `Writer`, `Actors`          | Nomi separati da virgole.                                                                                 |
| `Plot`, `Language`, `Country`, `Awards`          | Testo.                                                                                                    |
| `Poster`                                         | Indirizzo su `https://img.amodb.dev/t/p/w300/`.                                                           |
| `Ratings`                                        | Array di oggetti con `Source` e `Value`.                                                                  |
| `Metascore`, `imdbRating`, `imdbVotes`, `imdbID` | Testo, compreso il numero di voti con le virgole.                                                         |
| `Type`                                           | `movie` o `series`.                                                                                       |
| `DVD`, `BoxOffice`, `Production`, `Website`      | Solo film. `BoxOffice` porta un valore quando noto. `DVD`, `Production` e `Website` valgono sempre `N/A`. |
| `totalSeasons`                                   | Solo serie, come testo. Le risposte delle serie non hanno `DVD`, `BoxOffice`, `Production` né `Website`.  |
| `Response`                                       | `True` o `False`, sempre una stringa.                                                                     |

I campi seguono OMDb, quindi un parser OMDb esistente non richiede modifiche oltre all'URL di base.

### Risposta di esempio

```json
{
  "Title": "Fight Club",
  "Year": "1999",
  "Rated": "R",
  "Released": "15 Oct 1999",
  "Runtime": "139 min",
  "Genre": "Crime, Drama, Thriller",
  "Director": "David Fincher",
  "Writer": "Chuck Palahniuk, Jim Uhls",
  "Actors": "Brad Pitt, Edward Norton, Meat Loaf",
  "Plot": "A nameless first-person narrator attends support groups in an attempt to subdue his emotional state and relieve his insomniac state.",
  "Language": "English",
  "Country": "United States, Germany",
  "Awards": "Nominated for 1 Oscar. 12 wins & 38 nominations total",
  "Poster": "https://img.amodb.dev/t/p/w300/qkrH7rjYKU4KOwwIl6wF6H3ISvm.jpg",
  "Ratings": [
    { "Source": "Internet Movie Database", "Value": "8.8/10" },
    { "Source": "Rotten Tomatoes", "Value": "81%" },
    { "Source": "Metacritic", "Value": "67/100" }
  ],
  "Metascore": "67",
  "imdbRating": "8.8",
  "imdbVotes": "2,669,989",
  "imdbID": "tt0137523",
  "Type": "movie",
  "DVD": "N/A",
  "BoxOffice": "$38,003,039",
  "Production": "N/A",
  "Website": "N/A",
  "Response": "True"
}
```

Per una serie come The Wire (`i=tt0306414`) la risposta termina con `"Type": "series"`, `"totalSeasons": "5"` e `"Response": "True"`.

## Cercare con s

Invia `s` per ottenere una lista invece di un solo titolo. Ogni pagina contiene 10 elementi, e `totalResults` dà il conteggio totale come stringa. Richiedi `page=2` per gli elementi da 11 a 20, e prosegui finché non hai letto `totalResults` elementi. Una pagina oltre l'ultima risponde `Movie not found!`.

```bash
curl -sf "https://api.amodb.dev/omdb/?s=Matrix&type=movie&page=1&apikey=$AMODB_KEY"
```

| Campo          | Note                                                                             |
| -------------- | -------------------------------------------------------------------------------- |
| `Search`       | Array di al massimo 10 elementi con `Title`, `Year`, `imdbID`, `Type`, `Poster`. |
| `totalResults` | Conteggio di tutte le corrispondenze, come stringa.                              |
| `Response`     | `True` o `False`.                                                                |

```json
{
  "Search": [
    {
      "Title": "The Matrix",
      "Year": "1999",
      "imdbID": "tt0133093",
      "Type": "movie",
      "Poster": "https://img.amodb.dev/t/p/w300/kEDbym5htJgDQNenjUtSJxAHysB.jpg"
    },
    {
      "Title": "The Matrix Reloaded",
      "Year": "2003",
      "imdbID": "tt0234215",
      "Type": "movie",
      "Poster": "https://img.amodb.dev/t/p/w300/d0xVNNxIYxId2qHkqpgE39soOvD.jpg"
    }
  ],
  "totalResults": "20",
  "Response": "True"
}
```

L'elenco è tagliato a 2 dei 10 elementi.

## Leggere l'array Ratings

`Ratings` contiene un oggetto per fonte, ciascuno con `Source` e `Value`, e `Value` è un testo come `8.8/10`. Le fonti sono `Internet Movie Database`, `Rotten Tomatoes` e `Metacritic`, e sono elencate solo quelle note per il titolo. I campi piatti `imdbRating`, `imdbVotes` e `Metascore` ripetono parte degli stessi dati. Dividi `Value` sulla barra se ti serve un numero. Per numeri tipizzati e un punteggio Kinopoisk e TMDB, usa invece l'endpoint delle [valutazioni](https://amodb.dev/it/ratings/).

## Errori

Gli errori di ricerca restituiscono `{"Response":"False","Error":"..."}`. La maggior parte arriva con HTTP 200, quindi leggi `Error` e decidi in base al testo, non solo allo stato HTTP.

| Testo di `Error`                            | HTTP | Quando                                                                                                                |
| ------------------------------------------- | ---- | --------------------------------------------------------------------------------------------------------------------- |
| `Movie not found!`                          | 200  | Nessun titolo corrisponde a `t`, il valore di `i` è valido ma sconosciuto, o una pagina di ricerca è oltre l'ultima.  |
| `Incorrect IMDb ID.`                        | 200  | Il valore di `i` non ha la forma di un ID IMDb.                                                                       |
| `Too many results.`                         | 200  | Il testo di ricerca è più corto di 3 lettere o corrisponde a troppi titoli. Allunga il testo o aggiungi `type` o `y`. |
| `Something went wrong.`                     | 200  | Non è stato inviato nessuno tra `i`, `t` e `s`.                                                                       |
| `Only r=json is supported.`                 | 400  | `r` è impostato su qualcosa di diverso da `json`.                                                                     |
| `No API key provided.` o `Invalid API key!` | 401  | L'`apikey` manca o è sbagliata.                                                                                       |
| `Request limit reached!`                    | 429  | Oltre le tue richieste al minuto. Attendi i secondi di `Retry-After`.                                                 |

Un piano terminato risponde HTTP 402. Vedi [errori](https://amodb.dev/it/errors/) e [limiti di richieste](https://amodb.dev/it/rate-limits/).

## Migrare un client OMDb

La migrazione si fa con due modifiche: l'URL di base e la chiave. Nient'altro nella richiesta cambia.

```js
// Before: the base URL and key of your current OMDb setup.
// After:
const OMDB_BASE = 'https://api.amodb.dev/omdb/';
const OMDB_KEY = process.env.AMODB_KEY;
```

Rimuovi `r=xml` se lo invii. Un client che legge episodi, `Season` o `callback` ha bisogno di un'altra fonte per quelle parti. Il limite di richieste è per chiave, quindi le chiamate in stile OMDb e le [chiamate in stile TMDB](https://amodb.dev/it/movies/) condividono un unico budget di 20, 40 o 120 richieste al minuto.

## Note pratiche

- Tratta ogni valore come testo. Converti tu `Year`, `imdbRating` e `totalResults`, e tratta `N/A` come mancante.
- Usa `plot=full` solo quando mostri la trama lunga. `short` mantiene le risposte più piccole.
- Le ricerche per `i` o `t` restano in cache più a lungo delle ricerche con `s`, quindi una ricerca ripetuta restituisce la risposta salvata.
- Per ottenere un ID TMDB da un ID IMDb, chiama la [ricerca per ID esterno](https://amodb.dev/it/find-by-external-id/).
- Le locandine sono a `w300`. Per altre dimensioni, costruisci l'indirizzo dal `poster_path` in stile TMDB e dall'elenco delle dimensioni di [immagini](https://amodb.dev/it/images-api/).
- Tieni la chiave su un server. Una `apikey` nell'URL di una pagina è visibile a ogni visitatore.

## Domande e risposte

### Mi serve una chiave diversa per l'endpoint OMDb?

No. La stessa chiave di 32 caratteri funziona sui percorsi in stile TMDB e sull'endpoint OMDb. Inviala come parametro di query apikey, esattamente come fa oggi un client OMDb.

### Posso richiedere XML?

No. Si serve solo r=json. Una richiesta con r=xml restituisce HTTP 400 con il testo Only r=json is supported., quindi rimuovi quel parametro o impostalo su json prima di cambiare l'URL di base.

### Perché tutti i valori sono stringhe?

Il corpo segue OMDb campo per campo, e quel formato invia come stringhe numeri come Year, imdbRating e totalResults. Convertili nel tuo codice. I valori sconosciuti valgono N/A.

### Stagioni ed episodi sono supportati?

No. I parametri Season, Episode, callback e v vengono ignorati, e type=episode non trova nulla. Una risposta di serie ha totalSeasons ma nessun dato sugli episodi. Usa gli endpoint tv in stile TMDB per le stagioni.

### Da dove vengono le locandine?

Il campo Poster contiene un indirizzo su img.amodb.dev nella dimensione w300. Le immagini non richiedono chiave, quindi puoi mettere l'indirizzo direttamente in un tag img.

## Pagine correlate

- [Alternativa all'API OMDb](https://amodb.dev/it/omdb-api-alternative/): Hai raggiunto il limite giornaliero di OMDb? amodb risponde alle richieste in stile OMDb e serve anche gli endpoint TMDB v3, con la stessa chiave API.
- [Ricerca per ID esterno](https://amodb.dev/it/find-by-external-id/): Cerca un film, una serie o una persona per ID IMDb, TVDB, Wikidata o Kinopoisk con l'endpoint find di TMDB, e leggi ID esterni e dati Wikidata di un titolo.
- [API dei dettagli del film](https://amodb.dev/it/movies/): API dettagli film con gli stessi percorsi e JSON di TMDB v3. Ottieni un film per ID, aggiungi crediti, valutazioni e mood con append_to_response, in 14 lingue.
- [API delle immagini e host delle immagini](https://amodb.dev/it/images-api/): API immagini dei film con percorsi TMDB v3: elenca locandine, sfondi, loghi e fermi immagine di ogni titolo e caricali da img.amodb.dev in 10 dimensioni.
- [Autenticazione](https://amodb.dev/it/authentication/): Come inviare la chiave amodb: api_key nella query, un header Authorization Bearer o apikey per le chiamate OMDb. Formato, conservazione, rotazione, errori 401.
- [Avvio rapido](https://amodb.dev/it/quickstart/): Fai la prima chiamata ad amodb: ottieni una chiave, richiedi i dettagli di un film in curl, JavaScript, Python, PHP o Go, carica la locandina. Meno di 2 minuti.

Aggiornato: 2026-10-18. Source: https://amodb.dev/it/omdb-endpoint/
