IMDb is undoubtedly the largest database for movies worldwide. One can say, that is not so efficient for regional movies, but there aren’t any such online databases for them either. This article is about how to get details of a movie like its poster, cast, crew, summary, etc.
To Achieve the Task we will be using an API which is not Open source, but free. It is known as OMDB Api and was built by Brian Fritz(Thanks Man!).
The Latest Version at the time of this writing is 2.1 which is quite advanced and has the options to resolve name conflicts by using years.
So, How do I get details of any Film?
All you need to do is make an Ajax call to the following URL:
Following is an Example Script using this API:
// IMDb ID to Search
var imdbId = “tt1285016”;
// Send Request
var http = new ActiveXObject(“Microsoft.XMLHTTP”);
http.open(“GET”, “http://www.omdbapi.com/?i=” + imdbId, false);
// Response to JSON
var omdbData = http.responseText;
var omdbJSON = eval(“(” + omdbData + “)”);
// Returns Movie Title
You can use these results in any way you wish. To Know about how to make an AJAX call from jQuery you may read here: How to Return Data From PHP File to AJAX Call (jQuery).