Need Help with API / HTTPS (RequestAsync Data) Script

Hello, im using the Hyra Service and wanted to make Screens ingame to show the Sessions that are starting soon. I already got the Session Data in Roblox but now i wanna also use the Data. I already tried much stuff and the support from Hyra said im not far from finishing but helping me with that is not their Support Stuff. Please help me someone

for I, V in pairs(Screens:GetChildren()) do
	if V:IsA("Part") and V.Name == "Screen" then
		local Response = HTTPService:RequestAsync({
			Url = "https://api.hyra.io/activity/sessions/"..WorkspaceID.."/upcoming",
			Method = "GET",
			Headers = {
				["Authorization"] = "Bearer "..ApiKey
			},
		})
		
		for _, Session in pairs(Response) do
			print(Session)
			print(Session.data)
		end
	end
end

That is the data formatted:

[
  {
    "_id": "PRIVATE",
    "schedule": {
      "_id": "PRIVATE",
      "name": "Allgemeine Grundausbildung",
      "public_start_offset": -10,
      "public_slock_offset": 10,
      "publish_to_discord": false,
      "game_link": "PRIVATE"
    },
    "start": "2025-04-01T15:00:00.000Z"
  },
  {
    "_id": "PRIVATE",
    "schedule": {
      "_id": "PRIVATE",
      "name": "Allgemeine Grundausbildung",
      "public_start_offset": -10,
      "public_slock_offset": 10,
      "publish_to_discord": false,
      "game_link": PRIVATE"
    },
    "start": "2025-04-01T17:00:00.000Z"
  }
]

What exactly do you mean by this? I need specifics.

I think I understand what you meant.

The response of the HTTP request is a JSON object, not a luau table. Use JSONDecode.

Script:

		local Decode = HTTPService:JSONDecode(Response)
		print(Decode)

Output:

argument #1 expects a string, but table was passed  -  Server - ScreenHandler:30

I wanna get the name “Allgemeine Grundausbildung” and start:

Is this Response? Char limit.

Yes it is (Character Limt yes yes yes)

[
  {
    "_id": "<string>",
    "schedule": {
      "_id": "<string>",
      "name": "<string>",
      "public_start_offset": 123,
      "public_slock_offset": 123,
      "publish_to_discord": true,
      "game_link": "<string>"
    },
    "start": "<string>",
    "host": {
      "exists": true,
      "id": "<string>",
      "username": "<string>",
      "display_name": "<string>"
    },
    "co_host": {
      "exists": true,
      "id": "<string>",
      "username": "<string>",
      "display_name": "<string>"
    }
  }
]

That is btw the full response you can get

Based on previous replies, you want just the name and start offset, right? So something like this:

Response = HTTPService:JSONDecode(Response.Body)
for _, Session in Response do
	local Name, Start = Session.schedule.name, Session.schedule.public_start_offset
	-- ...
end

Note that, as your code doesn’t already have it, you might want to add additional error checking and assertion. HTTP requests, even (probably) JSONDecode can sometimes fail, so it’s good practice to wrap them in pcalls and catch the errors.

Ah, right Response.Body this should work.

Now nothing prints out

Code:

	local ResponseDecode = HTTPService:JSONDecode(Response.Body)
	for _, Session in ResponseDecode do
		local Name = Session.schedule.name
		print(Name)
	end

That should’ve worked, I believe. Can you try printing ResponseDecode?

{}  -  Server - ScreenHandler:33

Perhaps this is a problem in the API, the response shouldn’t be completely empty. I don’t use Hyra so I can’t really help you here.

I had no Session thats why :sob:. Now it prints out this

20:56:01.841   â–Ľ  {
                    [1] =  â–Ľ  {
                       ["_id"] = "67eae512ae24bcbc0b7da571",
                       ["schedule"] =  â–¶ {...},
                       ["start"] = "2025-04-05T17:00:00.000Z"
                    }
                 }  -  Server - ScreenHandler:33
  20:56:01.841  Allgemeine Grundausbildung  -  Server - ScreenHandler:37

Great, this means it works. Now you can start indexing other parts of the session like you would do in a regular table.

Similarly to the name, the start offset is at Session.schedule.public_start_offset.

Then you can embed the data you have onto the screens.

One last Question. Maybe you know how i can transfer this to date and time?

2025-04-01T05:00:00.000Z

this would be 01.04.2025 07:00AM

For this, DateTime exists, which allows you to construct dates from this format (an ISO date).

> print(DateTime.fromIsoDate("2025-04-01T05:00:00.000Z"))
  1743483600000

You can then call the ToUniversalTime or ToLocalTime method to get the information in a dictionary.

> print(DateTime.fromIsoDate("2025-04-01T05:00:00.000Z"):ToLocalTime())
â–Ľ  {
                    ["Day"] = 1,
                    ["Hour"] = 7,
                    ["Millisecond"] = 0,
                    ["Minute"] = 0,
                    ["Month"] = 4,
                    ["Second"] = 0,
                    ["Year"] = 2025
                 }
1 Like

Thank you very much. You were really helpful!