Currently going crazy over getting a user's inventory via cookie

Is there ANY way of getting a user’s inventory via Python with a cookie? ANY way?

i’ve been trying to use this for 60 minutes straight and i have only been getting 403 errors.
[excuse me coding, i don’t know python or http very well so i had to vibe code this a little im sorry]

def get_user_audio_inventory(user_id):
    """Legacy cookie-based inventory API: returns audio assets CREATED by the user."""
    audios = []
    cursor = None

    url = f"https://apis.roblox.com/cloud/v2/users/{user_id}/inventory-items"

    while True:
        params = {
            "assetTypeId": 3,          # Audio
            "limit": 100,
            "sortOrder": "Asc",
        }
        if cursor:
            params["cursor"] = cursor

        r = session.get(url, params=params)

        print("DEBUG", r.status_code, r.text)  # temporarily log

        if r.status_code != 200:
            print(f"Failed to fetch inventory for {user_id}: {r.status_code} {r.text}")
            return audios

        data = r.json()

        # Only keep items created by this user
        for item in data.get("data", []):
            creator = item.get("creator", {})
            if str(creator.get("id")) == str(user_id):
                audios.append(item)

        cursor = data.get("nextPageCursor")
        if not cursor:
            break

    return audios
2 Likes

the endpoint you are trying to use specifically requires an API key and will not work with a cookie as it is part of the new cloud APIs not the legacy APIs

these are the endpoints you were looking for, although they are deprecated and will definitely be purged soon like api.roblox.com was so make an API key and stick with the one you are using currently. there is no reason for you to stick with a cookie with the recent changes


https://create.roblox.com/docs/cloud/reference/features/inventories#inventory_get_v2_users__userId__inventory
https://create.roblox.com/docs/cloud/reference/features/inventories#inventory_get_v1_users__userId__items__itemType___itemTargetId__is_owned

you can make an API key here: https://create.roblox.com/dashboard/credentials

thanks, will try when i’m home

p.s. i am still using cookie because i am not going to be ID identifying to just use oauth2. i’m fine with cookie for now and i’ll only use an API key and no OAuth2

umm.. tried it, this is literally the same code i have been using??

if it helps, here’s the error i’ve been getting

you don’t need to id verify for an api key

because you’re stil using a cookie for an api that only allows an api key

this is relating to inventories, you cannot access a inventory using an api key

yes you can
https://create.roblox.com/docs/cloud/reference/features/inventories#Cloud_ListInventoryItems

did just realise i was a little dense :sob: i copied the new api instead of the old api

although one other thing


is “3” a valid asset type, per chance? on the api page it corresponds to audios
AssetType | Documentation - Roblox Creator Hub

but it returns an error here

def get_user_audio_inventory(user_id):
    """Legacy cookie-based inventory API: returns audio assets CREATED by the user."""
    audios = []
    cursor = None

    url = f"https://inventory.roblox.com/v2/users/{user_id}/inventory"

    while True:
        params = {
            "assetTypeId": 3,          # Audio
            "limit": 100,
            "sortOrder": "Asc",
        }
        if cursor:
            params["cursor"] = cursor

        r = session.get(url, params=params)

        print("DEBUG", r.status_code, r.text)  # temporarily log

        if r.status_code != 200:
            print(f"Failed to fetch inventory for {user_id}: {r.status_code} {r.text}")
            return audios

        data = r.json()

        # Only keep items created by this user
        for item in data.get("data", []):
            creator = item.get("creator", {})
            if str(creator.get("id")) == str(user_id):
                audios.append(item)

        cursor = data.get("nextPageCursor")
        if not cursor:
            break

    return audios

there is one other reason i’m using cookie, API keys can’t actually read it unless it’s set to “everyone”, its meant to be like some automated bot you friend tbh and it reads your audios

ok bruh i just checked the user id you used and you are literally trying to look at a private inventory :sob:

1 Like

umm
minor.. issue..

its set to “Connections”.

i didnt really copy-paste this part, but the bot, RebuildAudio, actually automatically accepts friend requests. it then checks inventory status to see if IT can access it, then tries to fetch
all of it works fine except for the checking the actual inventory part :sob:

for reference, here’s what happens when theres a priv inventory:

1 Like