Does IMDB provide an API?

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?


The IMDb currently has two public APIs that are, although undocumented, very quick and reliable (used on their own site through AJAX).

  • A statically cached search suggestions API:

  • http://sg.media-imdb.com/suggests/a/aa.json
  • http://sg.media-imdb.com/suggests/h/hello.json
  • Format: JSONP
  • Downside:

  • It's in JSONP format, however the callback parameter can not be set by passing a callback-query parameter. In order to use it cross-domain you'll have to use the function name they choose (which is in the "imdb${searchphrase}" format, see example below). Or use a local proxy (eg a small php file) that downloads (and caches!) it from IMDb and strips the JSON-P callback, or replaces it with a custom callback.

  • If there are no results, it doesn't gracefully fallback, but displays an XML error instead

  • // Basic
    window.imdb$foo = function (list) {
      /* ... */
    };
    jQuery.getScript('http://sg.media-imdb.com/suggests/f/foo.json');
    
    // Using jQuery.ajax (let jQuery handle the callback)
    jQuery.ajax({
        url: 'http://sg.media-imdb.com/suggests/f/foo.json',
        dataType: 'jsonp',
        cache: true,
        jsonp: false,
        jsonpCallback: 'imdb$foo'
    }).done(function (result) {
        /* ... */
    });
    
    // With local proxy to a PHP script replacing imdb$foo with a sanitized
    // version of $_GET['callback'] (https://stackoverflow.com/a/8811412/319266)
    jQuery.getJSON('./imdb.php?q=foo&callback=?', function (list) {
        /* ... */
    });
    
  • More 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: JSON, XML and more
  • Downside:
  • No JSONP. In order to use from JavaScript cross-domain, a local proxy is required.
  • No documentation, more formats may be available
  • Upside
  • Live search!
  • Name support for actors as well!
  • Proper fallback to empty object
  • As said, both of these APIs are undocumented. They could change at any time.

    See also https://stackoverflow.com/a/8811412/319266, for an example of a JSON API in PHP.


    new api @ http://www.omdbapi.com

    edit: due to legal issues had to move the service to a new domain :)


    IMDB themselves seem to distribute data, but only in text files:

    http://www.imdb.com/interfaces

    there are several APIs around this that you can Google. Screen scraping is explicitly forbidden. A official API seems to be in the works, but has been that for years already.

    链接地址: http://www.djcxy.com/p/65894.html

    上一篇: 在ASP.NET Web API中从控制器返回二进制文件

    下一篇: IMDB是否提供API?