HTTP ​
The http library provides asynchronous HTTP GET and POST requests. Requests run on background threads and deliver responses via callbacks on the next tick, so they never block your script.
Useful for fetching player or Steam data, calling external APIs, integrating with AI services, or anything that needs network access.
Kill switch ​
HTTP can be disabled entirely from the menu via the Allow Lua HTTP Requests toggle in the Lua Scripts section (default: on). When disabled, all http.get and http.post calls fail immediately with error = "http requests are disabled". The check can't be bypassed from inside a Lua script, useful when running scripts from untrusted sources.
http.get(url, opts, callback) ​
Performs an asynchronous HTTP GET request.
Parameters:
url(string). The URL to request.opts(table). Optional configuration:headers(table). Key-value pairs of request headers.user_agent(string). Custom User-Agent string. Default:"TsukiLua/1.0".timeout(number). Request timeout in milliseconds. Default:5000.
callback(function). Called with a response table when the request completes.
Example:
http.get("https://api.example.com/data", {
headers = {
["Authorization"] = "Bearer my_token",
["Accept"] = "application/json"
},
timeout = 3000
}, function(res)
if res.ok then
print("Got:", res.body)
else
print("Failed:", res.status, res.error)
end
end)http.post(url, opts, callback) ​
Performs an asynchronous HTTP POST request.
Parameters:
url(string). The URL to request.opts(table). Optional configuration:headers(table). Key-value pairs of request headers.body(string). The request body content.user_agent(string). Custom User-Agent string. Default:"TsukiLua/1.0".timeout(number). Request timeout in milliseconds. Default:5000.
callback(function). Called with a response table when the request completes.
Example:
http.post("https://api.example.com/submit", {
headers = {
["Content-Type"] = "application/json"
},
body = '{"username": "player1", "score": 100}'
}, function(res)
if res.ok then
print("Submitted successfully")
else
print("Error:", res.status, res.error)
end
end)Response table ​
The callback receives a single table with the following fields:
| Field | Type | Description |
|---|---|---|
status | number | HTTP status code (200, 404, etc.). 0 if the connection failed entirely. |
body | string | Response body as a string. Truncated to 1 MB if larger. |
ok | boolean | true if status is in the 200-299 range. |
error | string | Error message if the request failed. Empty string on success. |
Limits ​
- Maximum 4 concurrent in-flight requests. If exceeded, the callback fires immediately with
error = "too many concurrent requests". - Default timeout is 5 seconds. Configurable per-request via
opts.timeout. - Response bodies are capped at 1 MB.
- Requests are fully asynchronous. They never block
on_tick. - Callbacks always fire on the Lua thread (safe to call any Lua API inside them).
- SSL verification is enabled by default.
Notes ​
- Callbacks are delivered at the start of the next tick after the request completes, not during
on_tick. Your script does not need to yield or wait. - If a script is disabled or reloaded while a request is in flight, the callback may not fire.
- Use
http.postwithContent-Type: application/jsonfor JSON APIs. Thebodyfield is sent as-is, format it as needed.