4

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.

Braiam
  • 1
  • 11
  • 47
  • 78
  • Have you already taken a look at how these libraries works? https://github.com/JaviLorbada/JLTMDbClient/ ; https://github.com/WatchApp/ILMovieDB – Nicola Giancecchi Mar 22 '16 at 19:35

2 Answers2

5

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.

Rony
  • 51
  • 1
  • 4
  • 1
    Note that `w185` in the URL given above is where you specify the `width`, and it appears it can (at least) be 300, 400, 500 besides 185. – miyalys Oct 31 '21 at 00:11
3
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
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Sep 01 '21 at 00:09