Python Forum

Full Version: Communicating Roblox's Inventory API with python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am new to python so I dont know how to make http requests.

My goal is to get the json object and covert it to a list.

Roblox Inventory API - https://inventory.roblox.com/docs#!/Inve..._inventory

Url I want to fetch - "https://inventory.roblox.com/v2/users/654357401/inventory?assetTypes=Animation&limit=10&sortOrder=Asc"

Please guide me,
thank you.
Requests is what you should use in Python for this.
There usually some documentation for an API.
Not looking at doc just using you address can build a requests like this.
import requests

params = {
    'assetTypes': 'Animation',
    'limit': '10',
    'sortOrder': 'Asc',
}

response = requests.get('https://inventory.roblox.com/v2/users/654357401/inventory', params=params)
So if look at response get 403 and the json back that's not authorized,you may have a API key or the requests may now be wrong.
>>> response.status_code
403
>>> 
>>> json_data = response.json()
>>> json_data
{'errors': [{'code': 4,
             'message': "You are not authorized to view this user's inventory.",
             'userFacingMessage': 'Something went wrong'}]}
>>> 
>>> json_data['errors'][0]['message']
"You are not authorized to view this user's inventory."