Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does IMDB provide an API? [closed]

I recently found a movie organizer application which fetches its data from the IMDB database.

Does IMDB provide an API for this, or any third party APIs available?

like image 873
tusay Avatar asked Dec 27 '09 17:12

tusay


1 Answers

The IMDb has a public API that, although undocumented, is fast and reliable (used on the official website through AJAX).

Search Suggestions API

  • https://sg.media-imdb.com/suggests/h/hello.json

  • https://v2.sg.media-imdb.com/suggests/h/hello.json (as of 2019)

    • Format: JSON-P
    • Caveat: It's in JSON-P format, and the callback parameter can not customised. To use it cross-domain you'll have to use their function name for the callback (which is in the imdb${searchphrase} format). Alternatively, one could strip or replace the padding via a local proxy.
  • https://v2.sg.media-imdb.com/suggestion/h/hello.json (as of 2020)

    • Format: JSON
    • Caveat: It's not CORS-enabled. This is fine for use in apps and server-side scripts. For use in a web app, you'll need to route it through a simple proxy (and consider enabling caching, too!)
// 1) Vanilla JavaScript (JSON-P) function addScript(src) { var s = document.createElement('script'); s.src = src; document.head.appendChild(s); } window.imdb$foo = function (results) {   /* ... */ }; addScript('https://sg.media-imdb.com/suggests/f/foo.json');  // 2) Using jQuery (JSON-P) jQuery.ajax({     url: 'https://sg.media-imdb.com/suggests/f/foo.json',     dataType: 'jsonp',     cache: true,     jsonp: false,     jsonpCallback: 'imdb$foo' }).then(function (results) {     /* ... */ });  // 3) Pure JSON (with jQuery) // Use a local proxy to the clean `/suggestion` API. jQuery.getJSON('/api/imdb/?q=foo', function (results) {     /* ... */ });  // 4) Pure JSON (plain JavaScript; Modern ES6, ES2017, and Fetch API) // Serve a "/api" route in your app, that proxies (and caches!) // to v2.sg.media-imdb.com/suggestion/h/hello.json const resp = await fetch('/api/imdb/?q=foo'); const results = await resp.json(); 

Advanced Search

  • Name search (json): http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=jeniffer+garner
  • Title search (xml): http://www.imdb.com/xml/find?xml=1&nr=1&tt=on&q=lost
  • Format: XML
  • Upside: Supports both film titles and actor names (unlike Suggestions API).

Beware that these APIs are unofficial and could change at any time!


Update (January 2019): The Advanced API no longer exists. The good news is, that the Suggestions API now supports the "advanced" features of searching by film titles and actor names as well.

like image 95
Timo Tijhof Avatar answered Sep 29 '22 02:09

Timo Tijhof