JSON API Live Data Updates into GUI?

Heya,

So i’m trying to form two things - one will create a separate post for.

I have a radio website that uses the API to update whenever shown a song title, artists and cover art. This is entirely done using JSON. I’m wondering if i could get any assistance with making this.

The website updates the song title, name etc whenever changed, is there a way to incorporate the link of the site into LUA tables, then proceeding to update the site info every few seconds?

At the moment the site displays: {“responder”:“cache”,“title”:“Porcelain”,“artists”:“Moby”,“art”:“https://i.scdn.co/image/ab67616d0000b273819d60e357ede92145defd88”}
However this changes upon song changes.
This runs of a https google link, which i cannot share for privacy reasons, however the website displays the message in the next message, but updates every so often.

I’d need a timer to run to check the site every few seconds, so that it updates with the song changes, however how would i go about doing this script to work with the website link?

From there i’d then want the artist, title and art to display on a UI that i have prepared.

Thanks in advance
CodingWorks.

Assuming the URL you’re using leads to a file containing raw JSON, you could do the following:

  1. Get the encoded JSON from the website using HttpService:GetAsync().
  2. With the JSON retrieved, you can now use HttpService:JSONDecode() to turn it into a readable lua table.
  3. Go crazy! You now have the information in a readable format and you can begin using it. To be sure, double check that nothing went wrong and wrap your :GetAsync() inside a pcall().

Just make sure that all image references are not direct links but Roblox AssetId’s, you don’t seem to taking that into account with the JSON you provided. If you’re not quite sure how to use HttpService, the words with highlighting lead to articles on the developer hub (which have code samples!).

2 Likes