Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get data from OMDb API web service

I want to fetch and display a list of movies. I use this API called OMDb API. But it seems I need to create an API key for that. On their site they explain:

Send all data requests to:

http://www.omdbapi.com/?

Poster API requests:

http://img.omdbapi.com/?apikey=[yourkey]&

In this I'm a little confused, as I am new to iOS. Which one of the above methods should I use to fetch all data and display them? If I need to create an API key, where can I get it from their page?

like image 383
mark Avatar asked Nov 23 '15 06:11

mark


People also ask

How do I get a list of movies from OMDb API?

You can't get all the movies from OMDb API, even if you use * it will return an error Too many results. But you can return multiple results using s parameter. Look at the code sample below using jQuery. Check your browser console to view the result.

What is OMDb API key?

The OMDb API is a RESTful web service to obtain movie information, all content and images on the site are contributed and maintained by our users. If you find this service useful, please consider making a one-time donation or become a patron.

How do I find my IMDb API key?

You can find your API key in an email from a member of IMDb staff.


2 Answers

Try the values in parameters table in their website by making use of the examples section. Use different parameters for different responses.

For example, to request for a movie with title "inception", just put in this entry and hit search in the text field and it generates the link for you.

I will attach the link here so that you will get the idea http://www.omdbapi.com/?t=inception&y=&plot=short&r=json

Hit the above link and it will generate the required response. So this is the link pattern that you should use in your iOS project.

Have fun with iOS..

Update:

Currently, omdbapi requires an api key for getting the correct response, which can be acquired by either signing up like @appy-sharma describes in his answer or using their free key(which has a limit).

like image 87
iSeeker Avatar answered Oct 12 '22 06:10

iSeeker


You have to sign up from their website and then you will receive a link with your api key. The link in the email will look something like this:

http://www.omdbapi.com/?i=tt3896198&apikey=k83ue93

If you will notice, in the end of the link you will find &apikey=k83ue93, save it. (Don't worry it's not a valid api key)

Going back to their site and reading the documentation you can see by using parameters you can look for the movie. For a simple example, lets say you want to get the data of the movie JOKER then your url will look like this:

http://www.omdbapi.com/?t=joker&apikey=k83ue93

this is when you will search a movie with their title name using ?t=titlename

http://www.omdbapi.com/?i=tt7286456&apikey=k83ue93

this is when you will try to fetch the movie with its id using ?i=idnumber

Check their documentation. They are really simple. Check the parameters and play with them. Whoever reading this, don't worry. If you are new and if you think this is scary, dont worry! you already came this far dealing with apis, you will reach there.

Happy coding.

like image 20
Appy Sharma Avatar answered Oct 12 '22 06:10

Appy Sharma