Getting NBA player pictures for you application

Avinash Sarguru
2 min readApr 1, 2020


Let me tell you a story about how II had to delay a whole day on my NBA application just to figure out how to get NBA player pictures.

While working on any NBA application it is just a matter of time before you will need a resource to get current photos of every player. The first thought may be to individually search each player and get their picture and add it to your project files. If you’re like me you’re lazy and want a better way to do that.

So I did the next best thing I went the NBA website and thought I might as well use their pictures.What came next was the trial of finding how they stored their pictures and the API i had to use to get them.

First and foremost let us talk about the pattern uses as the src of their pictures. For example the url of a picture of Giannis Antetokounmpo will be:

The url for Ja Morant will be:

We can see a pattern of From experience creating databases we can figure out that the number that changes from each player is some sort of id identifier that we need to figure out.

The next challenge we run into is the finding these numbers. The logically thing to look for would be some sort of API of the NBA database to access different player ids.

These id’s can be found at

This is a documentation of the NBA stats API, while this may look intimidating we have a task that only requires one endpoint. The players endpoint will get us a list of ever single player that played in any year and their id in the NBA database.

To use the endpoint though requires an input of a year and each season is determined by the year it started in. The current year (as of now is the Corona season) would be indicated by the year 2019. The endpoint as of now would be defined as:

The list is long, but it is a list of every person that has played the current season, along with useful information.

With all this it should be relatively easy to get a picture for any player since you have resource to add an NBA reference id to any player in a database you make. Next time I will go over a way to actually display each player with this information.