Skip to content

http

HTTP request helpers (http.* namespace) plus the Roblox-mirror HttpService global for GET/POST, JSON encode/decode, GUID generation and URL encoding.

http.Request(options: {Url: string, [Uri]: string, [Method]: string, [Body]: string, [Headers]: table}) -> {Success: boolean, StatusCode: number, StatusMessage: string, Body: string, Headers: table}

Performs an HTTP request described by an options table and returns a Roblox-style response table.

local res = http.Request({Url = "https://example.com/api", Method = "POST", Body = "{}", Headers = {["Content-Type"] = "application/json"}})
print(res.StatusCode, res.Body)

http.Get(url: string) -> string

Issues an HTTP GET request and returns the raw response body.

local body = http.Get("https://example.com")

http.Post(url: string, body: string?, contentType: string?) -> string

Issues an HTTP POST request with an optional body and Content-Type header (default application/json), returning the raw response body.

local body = http.Post("https://example.com/api", "{\"x\":1}", "application/json")

HttpService:JSONEncode(value: any) -> string

Encodes a Lua value as a JSON string.

local json = HttpService:JSONEncode({a = 1, b = "two"})

HttpService:JSONDecode(json: string) -> any

Decodes a JSON string into a Lua value (table, string, number, boolean or nil).

local data = HttpService:JSONDecode("{\"a\":1}")

HttpService:GenerateGUID(wrapInCurlyBraces: boolean?) -> string

Generates a random version-4 UUID string, optionally wrapped in curly braces (defaults to true, matching Roblox).

local id = HttpService:GenerateGUID(false)

HttpService:GetAsync(url: string) -> string

Issues an HTTP GET request and returns the raw response body. Also callable as HttpGet or HttpGetAsync.

local body = HttpService:GetAsync("https://example.com")

HttpService:PostAsync(url: string, body: string?, contentType: string?) -> string

Issues an HTTP POST request with an optional body and Content-Type header (default application/json), returning the raw response body. Also callable as HttpPost or HttpPostAsync.

local body = HttpService:PostAsync("https://example.com/api", "{}")

HttpService:UrlEncode(str: string) -> string

Percent-encodes a string for safe use in a URL.

local enc = HttpService:UrlEncode("a b&c")

HttpGet(url: string) -> string

Alias for HttpService:GetAsync, recognized on any instance exposing it.

local body = game:HttpGet("https://example.com")

HttpGetAsync(url: string) -> string

Alias for HttpService:GetAsync.

local body = game:HttpGetAsync("https://example.com")

HttpPost(url: string, body: string) -> string

Alias for HttpService:PostAsync.

local res = game:HttpPost(url, data)

HttpPostAsync(url: string, body: string) -> string

Alias for HttpService:PostAsync.

local res = game:HttpPostAsync(url, data)

Helpers for building Roblox launch URLs, listing public game servers, and joining a place or a specific server by relaunching the game client.

server.MakeLaunchUrl(placeId: number, jobId: string?) -> string

Builds a roblox://experiences/start launch URL for a place, optionally targeting a specific server job id.

local url = server.MakeLaunchUrl(123974602339071, "job-guid-here")
print(url)

server.FetchPublic(placeId: number, cursor: string?, sortOrder: string?) -> table

Fetches a page of public servers for a place from the Roblox games API and returns the decoded JSON as a table (up to 100 per page; pass the returned nextPageCursor as cursor to page further). sortOrder “Asc” lists the emptiest servers first, “Desc” the fullest; the default order is fullest-first, so ask for “Asc” when you want low-population servers.

local page = server.FetchPublic(123974602339071, nil, "Asc")
for _, s in ipairs(page.data) do
print(s.id, s.playing .. "/" .. s.maxPlayers)
end

server.Join(placeId: number, jobId: string?)

Switches the running client to a place, or to a specific server when a job id (gameInstanceId) is given. Sober hands a roblox:// URI to its existing instance instead of teleporting, so Join cold-launches: it closes Sober, waits for the instance to exit, then reopens the deep link. The engine Conduit was attached to dies during the switch, so the dmdaemon re-acquires the relaunched client and running scripts rebind game on the new session.

-- join any public server for a place
server.Join(123974602339071)
-- join a specific server (job id from server.FetchPublic)
local page = server.FetchPublic(123974602339071, nil, "Asc")
server.Join(123974602339071, page.data[1].id)