Volt

request

Makes an HTTP request.

Syntax

request(options: table) -> table

Parameters

ParameterTypeDescription
optionstableRequest configuration

Options Table

FieldTypeDescription
UrlstringThe URL to request
Methodstring?HTTP method (GET, POST, etc.)
Headerstable?Request headers
Bodystring?Request body

Returns

Response Table

FieldTypeDescription
SuccessbooleanWhether the request succeeded
StatusCodenumberHTTP status code
StatusMessagestringHTTP status message
HeaderstableResponse headers
BodystringResponse body

Example: GET Request

local response = request({
    Url = "https://httpbin.org/get",
    Method = "GET"
})

if response.Success then
    print("Status:", response.StatusCode)
    print("Body:", response.Body)
end

Example: POST Request

local HttpService = game:GetService("HttpService")

local response = request({
    Url = "https://httpbin.org/post",
    Method = "POST",
    Headers = {
        ["Content-Type"] = "application/json"
    },
    Body = HttpService:JSONEncode({
        username = "player",
        score = 100
    })
})

if response.Success then
    local data = HttpService:JSONDecode(response.Body)
    print(data)
end

Error Handling

local success, response = pcall(request, {
    Url = "https://example.com/api",
    Method = "GET"
})

if success and response.Success then
    print("Got data:", response.Body)
elseif success then
    warn("HTTP Error:", response.StatusCode, response.StatusMessage)
else
    warn("Request failed:", response)
end

Aliases

  • http_request
  • http.request

On this page