Home > Projects > REST-like webservice/api for imdb.com with XML or JSON output

REST-like webservice/api for imdb.com with XML or JSON output

New version available!
Read my update post.

The site imdb.thumnet.com is a personal project that I recently released on the web.

This webservice/api supplies an interface for the Internet Movie DataBase (in short IMDB). It gives you the abbillity to search for, or view details of,  a movie with a REST like request.

Some examples are:

The output for the result of the request can be as XML or JSON. This makes it fairly easy to integrate movie information on you’re personal site.

For more information check out the site yourself.

If you encounter any problems please report them as a comment below.

Categories: Projects Tags: , , , , , ,
  1. Jimmy
    September 8th, 2009 at 15:17 | #1

    Hi !

    Very cool and usefull indeed :) Exactly what I needed for my own little htpc movie library. Only thing that worries me is that your webpage will be gone someday and I would like to incorperate your code directly into my project instead.

    Any chance that you are goin to relese the code as open source ?

    Featurewise I would suggest adding information about AKA for other countries as
    http://www.imdb.com/title/tt0808151/releaseinfo#akas

    and also if available information from
    http://www.imdb.com/title/tt0234215/dvd including releasedate , upc code etc.

    Br
    Jimmy

  2. September 11th, 2009 at 08:02 | #2

    @Jimmy
    I’m currently working on a new version of the API. As soon as that’s done I’ll make a new post about it.

    I’m thinking about going opensource…

    But what I can do for now is give you some hints about how to get the information from IMDB.

    1. Get the html source of the page you are interested in
    2. Determine what parts of information you find useful
    3. Build some function to get that information from the html source, these function s can use:
    – regular expressions
    – string between 2 other strings
    – string position
    – strip html tags
    – etc

  3. JImmy
    September 11th, 2009 at 10:40 | #3

    Hi ,

    Good news :)

    I have in the past used a few diffrent methods both my own code and others to parse information from Imdb , but noone of the as easy as yours.

    XML works very well and is used by MyMovies, ThemMovieDb , XBMC etc to store and handle metadata about movies and what Im trying to do is a tool ( as of now only for myself) to have the same meta data for all. Most of the times I can find it via MyMovies but for new/unreleased movies I rely on combo of imdb and TheMovieDb

    Br
    Jimmy

  4. Jimmy
    September 13th, 2009 at 19:54 | #4

    Hi again!

    Found that some movies doesen’t work with your service.

    for example : http://imdb.thumnet.com/xml/title/tt1176724
    http://www.imdb.com/title/tt1176724/

    Br
    Jimmy

  5. September 13th, 2009 at 20:42 | #5

    I’ll look into that!

    Put it on mu todo list, will tell you when I fixed it.

  6. Leonardo
    September 14th, 2009 at 17:06 | #6

    Hi, great job. Are you using google to search in Imdb? Is it possible to implement some kind of error message when the parameter of the search contains wrong values (like http://imdb.thumnet.com/xml/search/Moulin+rouge!/)? Would be very useful

  7. September 14th, 2009 at 18:12 | #7

    @Leonardo

    No, I’m not using google to search IMDB, it’s i direct request to imdb.com.

    About the error message: as stated earlier I’m currently working on a new version of the API and that will contain a summary block and a data block. In the summary block you have the possibility to check for errors that have occured.

  8. Jimmy
    September 16th, 2009 at 10:16 | #8

    Hi , found another little bug.

    when searhing for the movie tt1492645 the xml response is missing the ImdbID tag
    http://imdb.thumnet.com/xml/title/tt1492645

    I use the imdbId tag to validate that the response I get is the correct one so I hope this is a bug and not by design.

    Br
    Jimmy

  9. September 16th, 2009 at 11:09 | #9

    @Jimmy
    That indeed is a bug, thanks for the pointing it out.

    The bug occured because i search for the IMDB Pro link in the html
    http://pro.imdb.com/title/

    I thought that link would always be present in the html, but obviously it isn’t.

    I’ll change my code to look for the canonical link tag
    <link rel="canonical" href="http://www.imdb.com/title/tt1492645/" />

  10. September 22nd, 2009 at 11:51 | #10

    Hi,
    first: great work. Simple, but yet offers useful info from the site. Keep up the good work :)

    But I have a minor problem which is confusing me. Yesterday I started building a web app for the iPhone with some guidance from your demo on the API site. Everything went on fine: the JSON was correctly loaded and parsed, and in the end shown in the app. But when I uploaded my files to the server to test it on my device, it doesn’t work. I don’t get it; locally on my computer everything is fine, but not live from the webserver.

    I inspected the headers and I got a 200 OK, but the response says:
    “Failed to load source for: http://imdb.thumnet.com/json/search/star+wars“.

    Have you any idea at all what the problem lies? The web server is an IIS.

  11. September 22nd, 2009 at 11:52 | #11

    Forgot, maybe you wanna have a look at the site: http://elever.utb.sandviken.se/web/elev02/hippo/

  12. September 22nd, 2009 at 12:01 | #12

    @Johan

    I took a quick look at your site (with TamperData a Firefox plugin) and it appears you use the OPTIONS method to request the JSON. You should instead use the GET method to make the request.

    I hope this helps.

  13. September 22nd, 2009 at 13:01 | #13

    Thanks for the quick reply.

    I noticed the weird OPTIONS method too, but I can’t understand why that one is used! First I used jQuery’s $.getJSON() function, and now I tested the common $.get() function. These two shouldn’t produce the OPTIONS method, right? You’re using the $.getJSON() and that invokes the GET method correctly. I also noticed the headers are different. For instance, my “Content-Type” is “application/x-httpd-php5″ and yours is “text/x-json”. I’m a bit green on this stuff, but I find it strange that two so similar requests can be so different.

  14. September 22nd, 2009 at 13:08 | #14

    @Johan

    Maybe the server you are hosting the code on does something weird… I really can’t think of something else. What is the method and the Content-type when you test your app local?

  15. September 22nd, 2009 at 13:30 | #15

    Locally, the headers are like yours in the demo. Every single one. It must be as you’re saying; the server does something it’s not suppose to do. After all, it’s an old IIS I used in school.. I’ll try to move the app to a friend’s server and test everything there.

    Thanks for the support!

  16. September 22nd, 2009 at 14:48 | #16

    @Johan

    You’re welcome, please post your results as well.

  17. September 25th, 2009 at 00:35 | #17

    Hi again. Still haven’t got it together, even when I tested on a different web server. I can’t understand what’s wrong. Here’s the code to the necessary parts for retrieving data from the API, and that works fine locally, but not on the server.

    http://pastebin.com/m24560940

    Firebug keeps showing that it’s an OPTIONS request instead of GET. Why, oh why?!

  18. nico
    September 26th, 2009 at 13:46 | #18

    Hi there.

    Great project for sure, but is it legal? Since your software is public and not having any disclaimers (I couldnt find any), anybody could use your software for commercial and non-personal purposes.

    Take a look here:
    http://www.imdb.com/licensing/noncommercial

    I wouldn’t want you, or the users to get in trouble for this ;)

    Regards,
    nico

  19. September 26th, 2009 at 16:16 | #19

    @Johan

    Hi Johan, I don’t know why the request uses OPTIONS instead of GET, I also tried googling for similar problems but I couldn’t find a solutions.

    Maybe another reader can help Johan…

  20. September 26th, 2009 at 16:17 | #20

    @nico

    Hi Nico, you have got a really good point there, do you have any hints/tips for me?
    What should such a disclaimer contain…

  21. nico
    September 26th, 2009 at 19:17 | #21

    @ThumNet

    I’m not into legal stuff so I cant really help you with that. But bottomline is, users of your software should agree with your usage terms, which are something in the lines of not using it illegally and for personal non-commercial use only.

    But there’s enough information on the web on how to assemble a disclaimer. But at first I’d take a look at how much of you application is actually allowed following IMDB’s terms. Perhaps even by contacting them.

    And since you’re offering your software as a service providing someone else’s information, perhaps you should consider to provide it as a library. (That’s easier to cover in any disclaimer/using terms.)

    This atleast is my interpretation of IMDB’s imo well covered usage terms. Good luck with your application :)

  22. Jimmy
    October 5th, 2009 at 10:13 | #22

    Hi ,

    Any progress on sorting out the bugs ?

    Br
    Jimmy

  23. October 5th, 2009 at 21:11 | #23

    Hi, Jimmy within the upcoming days there will be a new post with details about the new version.

  24. Mayur
    October 16th, 2009 at 18:59 | #24

    Hey,

    great job with this. it’s a really useful tool. I’m just wondering what other ‘encoding’ rules are needed to use this flawlessly? More specifically, besides replacing blank spaces with ‘+’, what other changes should we watch out for in our search queries?

  25. Jimmy
    November 2nd, 2009 at 22:19 | #25

    Hi again , any news ?

  26. November 2nd, 2009 at 22:54 | #26

    @Jimmy
    Well there is an update available, sorry for the delay!

    It was ready a couple of weeks ago but….. I never to the time to blog about it.

  1. November 2nd, 2009 at 22:45 | #1