Welcome to the official documentation for rURL. This guide provides an in-depth look at all the functions available in the rURL library.
rURL is a powerful, cURL-inspired HTTP library for Roblox developers. It aims to provide a more reliable, feature-rich, and user-friendly interface than the default HttpService. Whether you're sending data to a webhook, interacting with a complex web API, or just fetching web content, rURL simplifies the process.
Check if your copy of rURL is legitimate
There may be copies of rURL distributed around Roblox (and some other websites). This can post a safety risk to your game if you run a malicious script, as the modified code may take your accound data, game files, and more...
The game will scan for any rURL scripts in your game and check if they are legitimate or not. If they are not legitimate, immediately remove it and import it from here, the official website.
Installation
To get started, you first need to get rURL into your experience. There are three recommended methods, from a quick one-liner to a manually inserted module.
A robust function to encode a Lua table into a JSON string.
Parameters
tbl (table): The Lua table to encode.
Returns
(string) The resulting JSON string.
local myTable ={ name ="David", score =100}local jsonString = rURL:EncodeToJSON(myTable)-- jsonString is '{"name":"David","score":100}'print(jsonString)
rURL:DecodeJSON
A robust function to decode a JSON string into a Lua table.
Parameters
jsonString (string): The JSON string to decode.
Returns
(table) The resulting Lua table.
local jsonString ='{"name":"David","score":100}'local myTable = rURL:DecodeJSON(jsonString)print(myTable.name)-- Prints "David"
rURL:MIME_Type
Detects the MIME type of a file based on its URL/URI extension.
Parameters
url (string): The URL or filename (e.g., "image.png", "https://example.com/doc.pdf").
Returns
(string) typeShort, (string) typeFull
local typeShort, typeFull = rURL:MIME_Type("httpsauto.lol/image.png")print(typeShort)-- "png"print(typeFull)-- "image/png"
Advanced
Custom Headers
All API methods accept an optional headers table. This is essential for authentication (e.g., Bearer Tokens) or specifying content types.
local rURL =require(game.ReplicatedFirst.rURL)local url ="https://api.example.com/me"local myAuthToken ="YOUR_SECRET_TOKEN"local headers ={["Authorization"]="Bearer ".. myAuthToken,["Content-Type"]="application/json"}local response = rURL:GET(url, headers)if response.ok thenprint("My user data:", response.json)end
Error Handling
While all rURL functions are wrapped in a pcall internally to prevent them from erroring your script, it's still good practice to wrap them yourself. This allows you to catch any potential issues and check the response.ok field.
local rURL =require(game.ReplicatedFirst.rURL)local url ="https://api.example.com/data"local success, response =pcall(function()return rURL:GET(url)end)ifnot success thenwarn("pcall failed:", response)-- 'response' is the error message from pcallreturnend-- At this point, 'response' is the rURL Response Objectif response.ok thenprint("Got data:", response.json)elsewarn("HTTP request failed (".. response.statusCode .."):", response.error)end