PHP: Get movie information from IMDB

If you are building a website about movies and want to access movie information from Imdb then you can get it only by web scrapping because Imdb doesn’t provide any API to access its movie database. But there are some third-party API which provides information from Imdb.

In this article I will explain how to use following two APIs

  1. omdbapi.com (Requires API key)
  2. imdbapi.org (stopped working)

Working With omdbapi.com

Service Endpoint http://www.omdbapi.com/

Parameter Value Description
apikey string (required) Get a free API key http://www.omdbapi.com/apikey.aspx
s 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 d

Sample Request: http://www.omdbapi.com/?apikey=[your-api-key]&t=titanic&y=1997

Sample Response :
{"Title":"Titanic","Year":"1997","Rated":"PG-13","Released":"19 Dec 1997","Runtime":"3 h 14 min","Genre":"Drama, Romance","Director":"James Cameron","Writer":"James Cameron","Actors":"Leonardo DiCaprio, Kate Winslet, Billy Zane, Kathy Bates","Plot":"A seventeen-year-old aristocrat, expecting to be married to a rich claimant by her mother, falls in love with a kind but poor artist aboard the luxurious, ill-fated R.M.S. Titanic.","Poster":"http://ia.media-imdb.com/images/M/MV5BMjExNzM0NDM0N15BMl5BanBnXkFtZTcwMzkxOTUwNw@@._V1_SX300.jpg","imdbRating":"7.6","imdbVotes":"449,162","imdbID":"tt0120338","Type":"movie","Response":"True"}
php code to access movie information omdbapi.com

1
2
3
4
5
<?
$json=file_get_contents("http://www.omdbapi.com/?apikey=[your-api-key]&t=titanic&y=1997");
$info=json_decode($json);
print_r($info);
?>

Working With imdbapi.org

Service Endpoint http://imdbapi.org/

Parameter Required Valid options Default Value Description
id (or ids) No if title /^ttd+$/ The IMDB ID of the movie you wish to get the info for (e.g. tt0120689)id  – only one IMDb ID.ids – max 10 IMDb ID (comma-separated).
title No if id movie title The valid imdb title of movie you wish to get the info for.(e.g. titanic)
type No json, jsonp, xml json The data type you wish the API to return.
plot No none, simple, full simple The plot type you wish the API to return.
episode No 1,0 1 When the parameter is 0, “episodes” is not included in the result.
lang No en-US, zh-CN en-US The data language you wish the API to reutrn.
aka No simple,full simple The aka type you wish the API to return.
release No simple,full simple The release date type you wish the API to return.
business No 1, 0 0 Whether to include the business field in the result.
tech No 1, 0 0 Whether to include the technical field in the result.

Sample Request: http://imdbapi.org/?title=titanic

Sample response:
[{"runtime": ["194 min"], "rating": 7.6, "genres": ["Drama", "Romance"], "rated": "PG_13", "language": ["English", "French", "German", "Swedish", "Italian", "Russian"], "title": "Titanic", "filming_locations": "Santa Clarita, California, USA", "poster": "http://ia.media-imdb.com/images/M/MV5BMjExNzM0NDM0N15BMl5BanBnXkFtZTcwMzkxOTUwNw@@._V1._SY317_CR0,0,214,317_.jpg", "imdb_url": "http://www.imdb.com/title/tt0120338/", "writers": ["James Cameron"], "imdb_id": "tt0120338", "directors": ["James Cameron"], "rating_count": 426376, "actors": ["Leonardo DiCaprio", "Kate Winslet", "Billy Zane", "Kathy Bates", "Frances Fisher", "Gloria Stuart", "Bill Paxton", "Bernard Hill", "David Warner", "Victor Garber", "Jonathan Hyde", "Suzy Amis", "Lewis Abernathy", "Nicholas Cascone", "Anatoly M. Sagalevitch"], "plot_simple": "A seventeen-year-old aristocrat, expecting to be married to a rich claimant by her mother, falls in love with a kind but poor artist aboard the luxurious, ill-fated R.M.S. Titanic.", "year": 1997, "country": ["USA"], "type": "M", "release_date": 19980403, "also_known_as": ["Titanic in 3D"]}]
php code to access movie information from imdbapi.org

1
2
3
4
5
<?
$json=file_get_contents("http://imdbapi.org/?title=titanic");
$info=json_decode($json);
print_r($info);
?>

Liked It? Get Free updates in your Email

Delivered by feedburner

5 thoughts on “PHP: Get movie information from IMDB

  1. Rohan Kandwal
    #

    I think the imdbapi is no longer providing any api.

    Reply
    1. sunny Post author
      #

      yes imdbapi is no longer working

      Reply
  2. Steven
    #

    Hi,

    the IMDB Info Box plugin for WordPress does not seem to be working anymore 🙁 are you going to make an update? PLEAAAAASE? 🙂

    A loyal fan 🙂

    Reply
    1. sunny Post author
      #

      Yes I am planing to release an update soon

      Reply
  3. Dilip
    #

    Oh i was search imdb api for a while and i found your post on omdb api. Thanks Sunny for sharing this. Excellent movie database api code.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *