Does IMDB provide an API? [closed]

2018-12-31 08:57发布

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?

19条回答
长期被迫恋爱
2楼-- · 2018-12-31 09:43

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

  1. 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 (e.g. 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) {
    /* ... */
});
  1. More advanced search

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.

查看更多
一个人的天荒地老
3楼-- · 2018-12-31 09:43

Yes, but not for free.

.....annual fees ranging from $15,000 to higher depending on the audience for the data and which data are being licensed.

URL :- http://www.imdb.com/licensing/

查看更多
只靠听说
4楼-- · 2018-12-31 09:46

Another legal alternative to get movie info is the Rotten-Tomatoes API (by Fandango).

查看更多
初与友歌
5楼-- · 2018-12-31 09:46

https://deanclatworthy.com/tools.html is an IMDB API but has been down due to abuse.

查看更多
冷夜・残月
6楼-- · 2018-12-31 09:46

Here is a simple solution that fetches shows by name based on the query from Krinkle:

You can get around the same-origin policy by having your server fetch the URL instead of trying to fetch it directly with AJAX and you don't have to use JSONP to do it.

Javascript (jQuery):

function getShowOptionsFromName (name) {
    $.ajax({
        url: "ajax.php",
        method: "GET",
        data: {q: name},
        dataType: "json"
    }).done(function(data){
        console.log(data);
    });
}

PHP (in file ajax.php):

$q = urlencode($_GET["q"]);
echo file_get_contents("http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=$q");
查看更多
查无此人
7楼-- · 2018-12-31 09:47

Here is a Python module providing API's to get data from IMDB website

http://techdiary-viki.blogspot.com/2011/03/imdb-api.html

查看更多
登录 后发表回答