How to use the Avatar API

  1. What do you want to achieve?
    I am trying to make an in-game catalog. That we can search for accessories.

  2. What is the issue?
    I searched in the developer hub but the link given does not work. https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=9&Limit=30 Its says in the output : Trust Check failed
    Also i don’t understand the Cursor. I want to get the items in a certain page, how can i do it.

Heres the script (Server) that returns the result.

local http = game:GetService("HttpService")
local remote = game.ReplicatedStorage.Remotes.HttpRequest
function remote.OnServerInvoke(plr,page)
	local url = "https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=9&Limit=30"
	local get = http:GetAsync(url)
	local json = http:JSONDecode(get) -- Into a lua table
	return json
end

The local script has nothing in. All i want, is to know how to get the items in a page and get the data of it.

Thanks for reading :smiley:

You can’t make requests to roblox.com directly. Make your requests to a proxy instead, either one you create + maintain or something like https://rprxy.xyz/.

3 Likes

Thanks but how do i get the items in a page?

1 Like

Just change your URL:

local http = game:GetService("HttpService")
local remote = game.ReplicatedStorage.Remotes.HttpRequest
function remote.OnServerInvoke(plr,page)
	local url = "https://catalog.rprxy.xyz/v1/search/items/details?Category=11&Subcategory=9&Limit=30"
	local get = http:GetAsync(url)
	local json = http:JSONDecode(get) -- Into a lua table
	return json
end
3 Likes

Yeah, i know, how do i get it from a certain page like in page 2 , 3 ect…
If i do it, i will give me only the items in the first page.

Ah gotcha I just did some experimenting and looked at the requests roblox makes when you go on the catalog:

You can’t ask for “page 1”, “page 2”, etc. – the API doesn’t seem to support that. However, you CAN move forward pages by adding a &cursor= parameter to the end of the URL, and set it to the nextPageCursor value you got from the first page. For example:

local url= "https://catalog.rprxy.xyz/v1/search/items/details?Category=11&Subcategory=9&Limit=30"

local firstPage = http:JSONDecode(http:GetAsync(url));

local nextCursor = firstPage["nextPageCursor"]

local secondPage = http:JSONDecode(http:GetAsync(url .. "&cursor=" .. nextCursor));

local thirdPage = http:JSONDecode(http:GetAsync(url .. "&cursor=" .. secondPage["nextPageCursor"]));

local sameAsFirstPage = http:JSONDecode(http:GetAsync(url .. "&cursor=" .. secondPage["previousPageCursor"]));

edit: I should also mention that if there’s no page to go back to (like on the first page), previousPageCursor will be nil

3 Likes