How to get a limiteds BestPrice

Hello everyone,

I have currently got into the roblox API and its uses. For the past few days Ive been trying to find a good day to find a limited item’s BestPrice. I have found some resources such as this and this. But I havent been able to understand how each of them work.

In the post by @OptimisticSide , I seem to get an error which I have tried to troubleshoot but I seem to go nowhere.

Am I doing something wrong here, or am I missing something, or maybe is there any better way to find the BestPrice of an item? Any help would be appreciated here!

2 Likes

Could you show the script you are working on? seems that you got the data, I think its just that you are giving a nil value to the loop instead of a table, the rolimons warning its a table?

This is what I am currently using

local Rolimons = require(5168671797)
local Item = Rolimons.Get("Item")
local Itmid = 48545806

function GetLimitedPrice(AssetId)
	local item = Item.new(AssetId)
	print(item.BestPrice)
end

while true do
	task.wait(5)
	GetLimitedPrice(Itmid)
end

I dont understand why the module is not working, and its gonna take me long time to find the issue.

Instead of that, I prefered to create this code and finding the format function in the module, it works, it returns the table with the data, just grab the key you need, in this code Im printing whole table and warning the BestPrice in output:

local HttpService = game:GetService("HttpService")

local URL = "https://www.rolimons.com/item/"

function Request(url)
	return HttpService:RequestAsync({
		Url = url;
		Method = "GET";
	})
end

function GetVariable(JavaScript: string, Variable: string): string
	local Declaration = string.sub(JavaScript, string.find(JavaScript, Variable) + string.len(Variable))
	Declaration = string.sub(Declaration, 1, string.find(Declaration, "\n"))
	if string.find(Declaration, "=") then
		Declaration = string.sub(Declaration, string.find(Declaration, "=") + 2, string.find(Declaration, ";") - 1)
		return Declaration
	end
end

local HttpResponse = Request(URL.."48545806") -- the item id

if HttpResponse.Success then
	local Result = HttpResponse.Body
	local RawData = HttpService:JSONDecode(GetVariable(Result, "item" .. "_details_data") or GetVariable(Result, "item" .. "_details"))
	print(RawData) -- whole table
	warn(RawData["best_price"]) -- the best price
end

My output:
image

The item in Roblox Catalog:
image

Its just a basic example, just edit it to fit your needs.

Wouldn’t it be possible to use the catalog API to retrieve the same? I’ve been trying to figure that out aswell but cant figure to get it to work.

MarketplaceService you mean and GetProductInfo() ?

local data = game:GetService("MarketplaceService"):GetProductInfo(48545806)
warn(data)

That will only return this table, this is the table from the item Id you provided.
As you can see theres not BestPrice data in that table:
image

But, I dont see any issue with using HttpService and the code I did send. Works good, and seems like a good way to retrieve more data from Roblox website, which is not possible to access it from a Roblox game.

In that case, you you educate me a bit about your code and how it works because I havent worked with Http services that much, so that I am able to convert it into a function where when I pass on a variable I get the result returned.

A quick modification can be applied to be used as a function and get the best price, something like this:

local HttpService = game:GetService("HttpService")
local URL = "https://www.rolimons.com/item/"

-- do the request
function Request(url)
	return HttpService:RequestAsync({
		Url = url;
		Method = "GET";
	})
end

-- Filter the response
function GetVariable(JavaScript: string, Variable: string): string
	local Declaration = string.sub(JavaScript, string.find(JavaScript, Variable) + string.len(Variable))
	Declaration = string.sub(Declaration, 1, string.find(Declaration, "\n"))
	if string.find(Declaration, "=") then
		Declaration = string.sub(Declaration, string.find(Declaration, "=") + 2, string.find(Declaration, ";") - 1)
		return Declaration
	end
end

-- handle the response
local function GetBestPrice(id)
	local HttpResponse = Request(URL..tostring(id)) -- the item id

	if HttpResponse.Success then
		local Result = HttpResponse.Body
		if HttpResponse.Body then
			local RawData = HttpService:JSONDecode(GetVariable(Result, "item" .. "_details_data") or GetVariable(Result, "item" .. "_details"))
			--print(RawData) -- whole table
			--warn(RawData["best_price"]) -- the best price
			return RawData["best_price"]
		end
	end
end



--[[ HOW TO USE IT ON A WHILE LOOP ]]
local anID = 000000000

while true do
	local bestPrice = GetBestPrice(anID) -- ask the best price
	warn(bestPrice) -- do what you want with the best price
	task.wait(1)
end

Just call GetBestPrice(anID) whenever you want to get the best price at that moment. Change the ID from 00000 to the ID you want to check

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.