Need help with catalog API

Can anyone who can understand Catalog API better then me help me out here?

local httpserv = game:GetService("HttpService")
local CatalogUrl = "https://catalog.RoProxy.com/v1/search/items/details?Category=11"
local GetItem = httpserv:GetAsync(CatalogUrl)
print(GetItem)

I am getting the table back from roblox here, but I am not able to get the components of the table here. I have tried to use .find and tried some other solutions on devforms aswell but still I am not able to go through the id of any of the returned values.

1 Like

When i try to decode instead of getting the lua form of the table I instead recieve this:

table: 0x09ec8b78382f4376

My current code is:

local httpserv = game:GetService("HttpService")
local CatalogUrl = "https://catalog.RoProxy.com/v1/search/items/details?Category=11"
local GetItem = httpserv:GetAsync(CatalogUrl)
local xyz = httpserv:JSONDecode(GetItem)
print(xyz)
1 Like

That’s the table’s memory address (its location in memory), you need to iterate over it in order to read its contents, i.e;

for i, v in pairs(xyz) do
	print(i, v)
end
2 Likes

Ok a few questions, I am fairly new to this so might seem as dumb questions but when I decode a Json format shouldn’t it provide directly with the lua format? And secondly right now with your help I am able to print the first 2 parts of the table, but from what I understand from looking at this is that the actual ids of the items are inside a table which is inside another table. Am I looking at it wrong, if not how will I be able to access the second table contents.

1 Like
for i, v in pairs(xyz) do
	for i2, v2 in pairs(v) do
		print(i2, v2)
	end
end

You can use nested for constructs to traverse over the members of nested tables. A ‘nested table’ is what you described (a table inside a table).

I am receiving a error, It requires a table where as v is providing a string instead.

1 Like

That means you’ll need to verify the value is a table before attempting to iterate over it, you can achieve that with the ‘type()’ global function.

for i, v in pairs(xyz) do
	if type(v) == "table" then
		for i2, v2 in pairs(v) do
			print(i2, v2)
		end
	end
end

Just had to tweak a few changes but works well now! Thanks for the help.
New code:

for i, v in pairs(xyz) do
	if type(v) == "table" then
		for i2, v2 in pairs(v) do
			for i3, v3 in pairs(v2) do
				if i3 == "productId" then
					print(i3, v3)
				end
			end
		end
	end
end
1 Like