Ajay Babu Singineedi
Ajay Babu Singineedi

Reputation: 195

Getting movie image from TMDb

Just started working with the TMDb API and need to know how to get movie poster. I am having movie id, posterid also but not knowing proper URL for fetching the image poster.

Upvotes: 5

Views: 17967

Answers (2)

aniket biswal
aniket biswal

Reputation: 41

url = "https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id)
data = requests.get(url)
data = data.json()
poster_path = data['poster_path']
full_path = "https://image.tmdb.org/t/p/w500/" + poster_path

Upvotes: 4

Rony
Rony

Reputation: 51

I've been playing with this great API.

To get the poster use the following URL:

https://image.tmdb.org/t/p/w185/SPECIFICMOVIEPOSTERPATH

The poster path is one of attributes you receive from the request.

So for example, if you add tvSlBzAdRE29bZe5yYWrJ2ds137.jpg to that url, it will give you A new hope's poster.

You can see this working CodePen http://codepen.io/ronywan/pen/zBZZdN?editors=1010.

<script id="result-template" type="text/x-handlebars-template">
      <div class="jumbotron">
        <span>Movie Title: {{movies.title}}</span></br>
        <span>Overview: {{movies.overview}}</span></br>
        <!-- <span>Release date: {{movies.release_date}}</span></br> -->
        <img src="https://image.tmdb.org/t/p/w185/{{movies.poster_path}}"></br>
        <!-- <span>Rated: {{movies.Rated}}</span></br> -->
        <span>Release date: {{movies.release_date}}</span></br>
        <span>Popularity: {{movies.vote_average}}</span></br>
      </div>
    </script>

I am using handlebars to show them. Will move it to angular soon.

Make sure to add your own APIKEY in the script.

Upvotes: 5

Related Questions