Getting A Games Thumbnail Through Python

I am currently developing a script in python that gets stats for a game and I was wondering if I could get such things as a games thumbnail, icon, players online, etc.

This is a quick question so thanks if you could help <3

A get request to this url should do it.

https://www.roblox.com/asset-thumbnail/image?assetId=1818&width=768&height=432&format=png

1818 being the place’s ID.

import requests
placeId = 0000

r = requests.get(url = "https://www.roblox.com/asset-thumbnail/image?assetId=" + placeId + "&width=768&height=432&format=png")

And here is a doc for python requests library in order to make requests.

For the other ideas, you would get them from this Roblox API
https://games.roblox.com/docs#!/v1

1 Like

There is a problem with the request not being able to get the thumbnail. Do you know how I would fix this? It always returns with <Response [200]> but when I do it in my browser it works perfectly fine.

Try this, changed the request url.

import requests
import json

placeId = "1818"

r = requests.get(url = "https://thumbnails.roblox.com/v1/games/icons?universeIds=" + placeId + "&size=50x50&format=Png&isCircular=false")

print(r.json()['data'][0]['imageUrl'])

Basically, we’re getting the imageUrl value from the result’s data.
{'data': [{'targetId': 1818, 'state': 'Completed', 'imageUrl': 'https://t0.rbxcdn.com/d6e8bbd6d987a3b7e4aaa41026c0d375'}]}

I’m an amateur at Python, just trying out things.

I updated and ran the code and it returns an index error that the list index is out or range referring to this:

                --HERE ↓
print(r.json()['data'][0]['imageUrl'])

And it’s getting this error because when the request gets the URL it returns <Response [200]>. I don’t know if this is a Roblox bug or just a request bug but I would love to know what you would think. Thanks for the help.

what if i use javascript


I’m not an expert at this, but try using a python module that can pull content off of websites. Hopefully this could give you an idea of what to do. Cheers!

Thanks for the reply!

The module, request is a module that does exactly that. I just ran into a few errors.

I’m really not sure, on the docs it’s saying you need to have the data in JSON then get the value from there. The 200 is the status code obviously, but I’m not too sure since I’m more of a julia programmer.

The response from there is giving me this.

Did you update to the new url I sent?

So I assumed it would be the same for you? Perhaps try updating the module or use Python 3.9?

@p49p0 I have no clue on how web requests work with JavaScript. But it shouldn’t be that far complicated from what I know. Same idea but with another module I am unsure of.

I have updated my code including the URL. In the link I saw that it said universeId instead of asset id so do I have to put the games unverseId in the link instead?

Could you show me what you mean? I got confused there too when going on the page.

Here are some images:


Causes: