IMDb & OMDb API

IMDb logoWhen I was thought of posting well know APIs, first in my mind its came IMDB API.  A simple question why ?

Because they having huge volume of data with different languages, year and lots more content about the movie.

Also when I was searching for any content or movie,  I am able to see the link which give way to IMDb from google. So I thought of posting IMDb API first.

How its works.

IMDb providing API which have limited access like title / name search with format json / xml and no documents available in their site. But website http://www.omdbapi.com/ which not affiliate with IMDb, but providing the movie search with flexible way.

first we will see about the IMDb API.

<?php
$strUrl = "http://www.imdb.com/xml/find?json=1&tt=on&q=titanic%";

$json=file_get_contents($strUrl);
$info=json_decode($json);
print_r($info);

Above API will  return the array set title_popular, title_exact and title_substring which will have list of array element like id, title, name, title_description, episode_title and description. which search titanic keyword from the tt (title field) return in json format.

Output will be

stdClass Object
(
    [title_popular] => Array
        (
            [0] => stdClass Object
                (
                    [id] => tt0120338
                    [title] => Titanic
                    [name] => 
                    [title_description] => 1997,     James Cameron
                    [episode_title] => 
                    [description] => 1997,     James Cameron
                )

            [1] => stdClass Object
                (
                    [id] => tt0098213
                    [title] => Roger & Me
                    [name] => 
                    [title_description] => 1989 documentary,     Michael Moore
                    [episode_title] => 
                    [description] => 1989 documentary,     Michael Moore
                )

        )

    [title_exact] => Array
        (
            [0] => stdClass Object
                (
                    [id] => tt0051994
                    [title] => A Night to Remember
                    [name] => 
                    [title_description] => 1958, 
                    [episode_title] => 
                    [description] => 1958, 
                )

            [1] => stdClass Object
                (
                    [id] => tt0046435
                    [title] => Titanic
                    [name] => 
                    [title_description] => 1953,     Jean Negulesco
                    [episode_title] => 
                    [description] => 1953,     Jean Negulesco
                )

        )

    [title_substring] => Array
        (
            [0] => stdClass Object
                (
                    [id] => tt0081400
                    [title] => Raise the Titanic
                    [name] => 
                    [title_description] => 1980,     Jerry Jameson
                    [episode_title] => 
                    [description] => 1980,     Jerry Jameson
                )

            [1] => stdClass Object
                (
                    [id] => tt0129923
                    [title] => The Chambermaid on the Titanic
                    [name] => 
                    [title_description] => 1997,     Bigas Luna
                    [episode_title] => 
                    [description] => 1997,     Bigas Luna
                )

        )

)

Now we will see about omdbapi.com api, they are providing list of documented parameters in their website.

Parameter Value Description

string (optional) title of a movie to search for
i string (optional) a valid IMDb movie id
t string (optional) title of a movie to return
y year (optional) year of the movie
r JSON, XML response data type (JSON default)
plot short, full short or extended plot (short default)
callback name (optional) JSONP callback name
tomatoes true (optional) adds rotten tomatoes data

omdbapi.com api which search the titanic and display the result.

<?php
$strUrl = "http://www.omdbapi.com/?s=titanic";

$json=file_get_contents($strUrl);
$info=json_decode($json);
print_r($info);

Output will be.

stdClass Object
(
    [Search] => Array
        (
            [0] => stdClass Object
                (
                    [Title] => Titanic
                    [Year] => 1997
                    [imdbID] => tt0120338
                    [Type] => movie
                )

            [1] => stdClass Object
                (
                    [Title] => Titanic II
                    [Year] => 2010
                    [imdbID] => tt1640571
                    [Type] => movie
                )

        )

)