API bugged or just me

Hi, I was creating a modulescript which gets data, and nothing seems to work. every api has failed, saying https: sslconnectfail. I am pretty sure it’s from the api, but maybe it’s my code as well. Any help would be appreciated.

--// Type Definitions.

type Array<Type> = {[number] : Type};
type Dictionary<Type> = {[string] : Type};

--// Plugin Initalization.

local DataFetcher = {};

local HttpService = game:GetService("HttpService")
local MarketplaceService = game:GetService("MarketplaceService")

local UniverseFetchRootUrl = "https://apis.roproxy.com/universes/get-universe-containing-place?placeid=%s"
local GamepassFetchRootUrl = "https://games.roproxy.com/v1/games/%s/game-passes?sortOrder=Asc&limit=100"
local GamepassFetchAltUrl = "https://inventory.roproxy.com/v1/users/%s/inventory/GamePass?itemsPerPage=100"
local GamesFetchRootUrl = "https://games.roproxy.com/v2/users/%s/games?sortOrder=Asc&limit=50"

--// Plugin Actions.

function DataFetcher:GetUniverseIdFromPlaceId(PlaceId)
	local Url = UniverseFetchRootUrl:format(PlaceId)
	local OperationSuccessful = false
	local UserFrontfacingMessage = ""
	local UniverseId = nil
	local ReturnData = nil
	
	local Success, ErrorMessage = pcall(function()
		ReturnData = HttpService:GetAsync(Url)
	end)
	
	if Success then
		if ReturnData then
			local FormattedReturnData = HttpService:JSONDecode(ReturnData)
			
			if FormattedReturnData.Errors then
				local Error = FormattedReturnData.Errors[1]
				
				UserFrontfacingMessage = Error.message
				warn(Error.message)
			else
				OperationSuccessful = true
				
				UniverseId = FormattedReturnData.UniverseId
			end
		else
			UserFrontfacingMessage = "There was an error. Try again!"
			warn("No return data in fetching universe id")
		end
	else
		UserFrontfacingMessage = "There was an error. Try again!"
		warn("No success in fetching universe id")
		warn(ErrorMessage)
	end
	
	return OperationSuccessful, UserFrontfacingMessage, UniverseId
end

function DataFetcher:GetGamepassesFromUniverseId(UniverseId)
	local Url = GamepassFetchRootUrl:format(UniverseId)
	local OperationSuccessful = false
	local UserFrontfacingMessage = ""
	local Gamepasses = nil
	local ReturnData = nil

	local Success, ErrorMessage = pcall(function()
		ReturnData = HttpService:GetAsync(Url)
	end)

	if Success then
		if ReturnData then
			local FormattedReturnData = HttpService:JSONDecode(ReturnData)

			if FormattedReturnData.Errors then
				local Error = FormattedReturnData.Errors[1]

				UserFrontfacingMessage = Error.message
				warn(Error.message)
			else
				OperationSuccessful = true

				local GamepassData = FormattedReturnData.data
				Gamepasses = {}

				for _, GamepassInfo in GamepassData do
					if GamepassInfo.price and GamepassInfo.price > 0 then
						Gamepasses[#Gamepasses + 1] = {
							Id = GamepassInfo.id,
							Name = GamepassInfo.displayName,
							Price = GamepassInfo.price,
						}
					end
				end
			end
		else
			UserFrontfacingMessage = "There was an error. Try again!"
			warn("No return data in fetching gamepasses")
		end
	else
		UserFrontfacingMessage = "There was an error. Try again!"
		warn("No success in fetching gamepasses")
		warn(ErrorMessage)
	end

	return OperationSuccessful, UserFrontfacingMessage, Gamepasses
end

function DataFetcher:GetGamesFromPlayer(Player)
	local UserId = Player.UserId
	local Url = GamesFetchRootUrl:format(UserId)
	local OperationSuccessful = false
	local UserFrontfacingMessage = ""
	local Games = nil
	local ReturnData = nil

	local Success, ErrorMessage = pcall(function()
		ReturnData = HttpService:GetAsync(Url)
	end)

	if Success then
		if ReturnData then
			local FormattedReturnData = HttpService:JSONDecode(ReturnData)

			if FormattedReturnData.Errors then
				local Error = FormattedReturnData.Errors[1]

				UserFrontfacingMessage = Error.message
				warn(Error.message)
			else
				OperationSuccessful = true

				local GameData = FormattedReturnData.data
				Games = {}

				for _, GamepassInfo in GameData do
					Games[#Games + 1] = GamepassInfo.id
				end
			end
		else
			UserFrontfacingMessage = "There was an error. Try again!"
			warn("No return data in fetching games")
		end
	else
		UserFrontfacingMessage = "There was an error. Try again!"
		warn("No success in fetching games")
		warn(ErrorMessage)
	end

	return OperationSuccessful, UserFrontfacingMessage, Games
end


function DataFetcher:GetGamepassesFromPlayer(Player)
	local Success, Error, Games = self:GetGamesFromPlayer(Player)
	
	if not Success then
		return Success, Error, nil
	end
	
	local AllGamepasses = {}
	
	for _, GameId in Games do
		local Success, Error, Gamepasses = self:GetGamepassesFromUniverseId(GameId)
		
		if not Success then
			return Success, Error, nil
		end
		
		for _, GamepassInfo in Gamepasses do
			table.insert(AllGamepasses, GamepassInfo)
		end
	end
	
	return true, "", AllGamepasses
end

--// Plugin Finalization.

return (DataFetcher);```
1 Like

Just to make sure, did you turn on the “Allow HTTP Requests” security setting in the Game Settings?

Yes, I don’t think the api is the right endpoint, although there are no lists about roproxy endpoints.

Have you tried accessing the URLs in a browser to see what you get? It could be the way that you are forming the URLs. Your code looks ok. Try placing print statements after the HttpService requests. Also, are there any errors that you are getting?

The errors are httpsserviceerror: sslconnectfail. One part of the problem which I fixed was that roproxy was blocked on my wifi network. I did team test, and it worked, but now the actual https links are failing. I think it’s because of the wrong roproxu endpoint.

1 Like

You could try the different end points by putting them in a web browser and see what you get back. Just make sure to use valid data.

Maybe you can try this. Just paste this into the command bar:

local GamesFetchRootUrl = "https://games.roproxy.com/v2/users/%s/games?sortOrder=Asc&limit=50"
local userId = game.Players.icrdev.UserId
local Url = GamesFetchRootUrl:format(userId)
local page = game:GetService("HttpService"):GetAsync(Url)
print(page)

It returned the page correctly for me with no API issues.