NextPageCursor is nil - trying to figure out the catalog API

It pulls the data properly, but the next page is registered as nil, so it’s not updating the URL.

Code:

local Http = game:GetService("HttpService")
local url = "https://catalog.roproxy.com/v1/search/items/details?Category=13&PageNumber="
local pages = 25

local assets = {}

for i = 1, pages do
	local urlPage = url
	local data = Http:JSONEncode(Http:GetAsync(urlPage))
	data = Http:JSONDecode(data)
	print(data)
	local nextPageCursor = data.nextPageCursor
	print(data.NextPageCursor)
	if nextPageCursor ~= nil then --page detected, go for it
		url = url..nextPageCursor
		print(url)
	end
	wait(2)
end

This print below is related to line print(data.NextPageCursor):
image

PageNumber is not a valid query. Use cursor and if you don’t have one leave it blank for the first page.
It should look like this.

https://catalog.roproxy.com/v1/search/items/details?Category=13&cursor=(cursor here or blank)

2 Likes

Is that what you need?

local Http = game:GetService("HttpService")
local url = "https://catalog.roproxy.com/v1/search/items/details?Category=13&PageNumber="
local pages = 25

local assets = {}

for i = 1, pages do
	local urlPage = url
	local data = Http:JSONEncode(Http:GetAsync(urlPage))
	data = Http:JSONDecode(data)
	print(data)
	local nextPageCursor = data.nextPageCursor
	if nextPageCursor ~= nil then --page detected, go for it
		print(data.NextPageCursor) -- Put the check here since its not NIL
		url = url..nextPageCursor
		print(url)
	end
	wait(2)
end

Thanks! I didn’t notice that at all. Problem resolved!

1 Like