AssedId type checking

Is there any way for me to get information on which an asset is a gamepass or a different asset ID, just from its asset ID? MarketplaceService:GetProductInfo() does not work because you have to specify the product type.

I looked on the developer hub page for this function, and in the “Parameters” section they do ask for a infoType Enum. However, in the example they show below, no such data is included.

This is the example on the developer hub page:

local Asset = game:GetService("MarketplaceService"):GetProductInfo(125378389)
print(Asset.Name .. " :: " .. Asset.Description)

I’ve also seen others use this function without the infoType included.

Have you already tried leaving it out completely, and seeing if it works without?

2 Likes

Providing no info type works, but the asset returned isn’t a gamepass, so for example requesting the pass ‘12345678’ would return a place instead of a game pass object.

If you want to return just gamepasses, then you could provide also the InfoType “Enum.InfoType.GamePass”.

local Asset = game:GetService("MarketplaceService"):GetProductInfo(125378389, Enum.InfoType.GamePass)
1 Like

If you need to dynamically get the ProductType from a AssetID - you will need to call a Roblox API web endpoint - which would require a external server.

The specific endpoint you will need to use is:

http://api.roblox.com/Marketplace/ProductInfo?assetId=

The specific thing to pay attention to is the AssetTypeId in the response - that will vary between specific asset types.

In Roblox alone there is no API unfortunately that can allow you to see this normally as far as I am aware.

2 Likes

Though you technically can’t seem to be able to do this directly as @Monofur said, you can use a proxy server to make the request, and return the result back to your roblox script.

Here is a great way to make a free proxy using Google Apps Script:

Using Google Apps As A api.roblox.com And www.roblox.com Proxy

What I wonder though, is why roblox would require input for assetType for their Lua function, especially when it doesn’t seem to be needed, but not for their public API.

But since we are working with AssetIds, there is only one asset per ID, right? If 12345678 is a place, then you couldn’t get a gamepass from it.

You can find out what the asset type is, but you shouldn’t be able to declare it since there is only one asset per AssetId.

I thought I’d need to do this, I just didn’t know which endpoint to use. Thanks