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:
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
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?