Riot API How to get summoner profile icon image

Viewed 1096

I found out i can get Summoner Icon image using this url:

https://ddragon.leagueoflegends.com/cdn/11.14.1/img/profileicon/934.png

The basic form of this is:

https://ddragon.leagueoflegends.com/cdn/{version}/img/profileicon/{profileIconId}.png

i know i can get the second value of {profileIconId} through Riot API but how do i know when i should update the version value? I don't want my app to crash when the version should be changed.

2 Answers

You should not be referencing ddragon for displaying icons or images. In fact, DataDragon specifically requests that you download the archive (.tgz) for each patch/version and host the assets locally or on your own CDN.

Websites like op.gg do this for all of the assets and host the images on their own CDN. They have to update their CDN every patch. You can automate updating the CDN using scripts, but for most small projects the work to automate this process may not be worth it.

Generally, it is considered rude to piggyback off of someone else's CDN without explicit permission to do so. Riot goes a step further and explicitly asks that you do not do this.

If someone is using the data dragon (ddragon) cdn, you can know the latest version looking at this json that they provide:

https://ddragon.leagueoflegends.com/api/versions.json

Just take the first element of the array and you are good to go without any scripting.

Related