I’m trying to use the Roblox Marketplace API to get the latest UGC items but I’m having trouble with the query parameters not working.
I am using the example URL from the documentation which can be found below along with an explanation.
The following URL will search for the first 10 “Gear” items sorted by all-time (“SortAggregation”) and relevance (“SortType”) created by Roblox (“CreatorTargetID”):
When I visit the URL using my browser it works fine and returns the expected. Still, when I try to access it from cURL it ignores all query parameters and shows all items ignoring the subcategory, sort, and creator target ID.
I tried changing the user agent but the same issue persists.
curl -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" https://catalog.roblox.com/v2/search/items/details?Subcategory=5&CreatorTargetId=1&SortType=0&SortAggregation=5&Limit=10
After lots of troubleshooting and researching, I’ve found most of the answer.
The documentation lists the queries to be used with the endpoint provided. The queries inside the article list the ones you can use for the v1 endpoint, not the v2 endpoint. The v2 endpoint is what AvatarEditorService:SearchCatalog() uses.
You’d need to put the category as 11 because Gears have been categorized as accessories for a while now. The article is very outdated.
Here’s the confusing thing though. Even after searching and experimentating for a while, I have no idea why curl returns different results. I made an HTTP request through JS code with accurate results, with the browser showing similar results. I cannot find out why curl is not properly parsing the queries.