What even is HTTP Service?

I’ve been scripting for a long time now, but something I can find little to no mention on is HttpService. I have pretty much no clue what it is, how to use it, and what it is useful for. If you guys could help me, and probably loads of others who see this thread understand what HttpService is, that would be awesome!

HttpService Is where you can get data from websites making stuff easier like a calendar API, Calculator API, …

You only need to learn 2 functions for HttpService, and here is how I use the functions


GetAsync

GetAsync

GetAsync is the easiest function to use on HttpService ( for me ), I always use this function for getting a request on a website

Code:

For example, I want to get the games a group has, I found [ Game API v1 ]

And then found the one I need


The first thing I will do is I will fill in the parameters

If you scroll a bit, You will find Parameters, And fill them

After filling in the parameter, Click try it out

You will get this, Ignore Curl, And copy the Request URL

After copying the Url, You can paste it on the Link url

local HttpService = game:GetService("HttpService")

local Link = "https://games.roproxy.com/v2/groups/7399520/games?sortOrder=Asc&limit=10"
local Data = HttpService:GetAsync(Link)

print(Data)
JSONDecode

JSONDecode

I use this function after getting data from GetAsync, After getting the data you will get a string instead of a table, For example like {"BirdieI90":"1772642486"}

And so convert this as a table

Code:

local HttpService = game:GetService("HttpService")

local Link = "https://games.roproxy.com/v2/groups/7399520/games?sortOrder=Asc&limit=10"
local Data = HttpService:GetAsync(Link)
local DecodedTable = HttpService:JSONDecode(Data)

print(DecodedTable)
1 Like

HttpService allows you to make requests to websites that are NOT a Roblox website.
The most common use I see the use of PostAsync to a Discord webhook so you can send messages from it (however, through proxy as Discord isn’t very fond of this). It can be useful for many things though. I personally use it to make GET requests to an API dump of Roblox that’s hosted on GitHub.

HttpService (Hypertext Transfer Protocol) lets you request sites for information. This could also be used to send information to a site. For example you could create a paste bin and make a script that takes the information from the paste bin you created and set a text labels text to the text/info from that paste bin site. However this could also be used to send information to a site. You could make a text box and whatever is in the input of that textbox will be sent to a Discord Server. This is just a example on how to use it. There are a variety of ways to use it. But just like Ping said you only need 2 functions to use HttpService. Those two functions are GetAsync and JSONDecode. I hope this article helped you. And informed you on what HTTP Service is.

1 Like

As the name says, HTTP Service (HyperText Transfer Protocol Service) is a service that is used to allow us to make HTTP requests to 3rd party servers.

Now, you need a little knowledge to know how requests and servers work. HttpService allows your running game instance/server to request/upload/update data from/to/of a web handler.

HttpService is mostly used to access APIs (Application Programming Interfaces) of 3rd party online apps/programs that have a designed set of public endpoints for you to use.

A good example is Discord’s webhooks. We can send a POST request to Discord’s API endpoint and upload a JSON (JavaScript Object Notation) to their server, which will tell Discord to trigger your webhook. (We obviously need a proxy, but these are details)

Here is something about web requests; IBM Documentation

HTTP service simply allows you to grab data from an endpoint(url for an api and not an actual website). Urls can have different things in them that allow extra data to be packed with them. Then there is headers and cookies which get confusing quick. One way to see APIs and play with them is to open your dev tools and switch to the network tab. Then you can see all the APIs that are used for a website.

HTTP Service is a service that allows you to send web requests. This can be to an API/Webhook. Sometimes while making something you might need to use outside resources to achieve something, or just to make it easier. Using HttpService, you can send Get and Post requests to either Get information from an API or to Post to it and have it run its task.

Another use case for HttpService is one that actually doesn’t necessarily need to deal with API or web requests. This HttpService method (JSONEncode, JSONDecode) will need to be used when dealing with web requests but can also be used for many other things. Fun Fact, when saving to a datastore, Roblox automatically runs the JSONEncode (and runs Decode when retrieving data)

I personally haven’t used HttpService for an actual game, really just for side projects as of now.

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