HTTP API
The http table provides async HTTP client functions. Available in all Lua scripts — queries, procedures, and record/label scripts.
Methods
Section titled “Methods”All methods take a URL and an optional options table, and return a response table.
http.get(url, opts?)http.post(url, opts?)http.put(url, opts?)http.patch(url, opts?)http.delete(url, opts?)http.head(url, opts?)Options
Section titled “Options”The optional second argument is a table with:
| Field | Type | Description |
|---|---|---|
headers | table | Request headers as key-value string pairs |
body | string | Request body (ignored for GET and HEAD) |
Response
Section titled “Response”Every method returns a table with:
| Field | Type | Description |
|---|---|---|
status | integer | HTTP status code |
body | string | Response body text (empty string for HEAD) |
headers | table | Response headers as key-value pairs (lowercase keys) |
Examples
Section titled “Examples”-- Simple GETlocal resp = http.get("https://api.example.com/data")-- resp.status = 200, resp.body = "...", resp.headers["content-type"] = "application/json"
-- GET with custom headerslocal resp = http.get("https://api.example.com/data", { headers = { ["authorization"] = "Bearer token123" }})
-- POST with JSON bodylocal resp = http.post("https://api.example.com/hook", { body = '{"key": "value"}', headers = { ["content-type"] = "application/json" }})
-- PUT, PATCH, DELETE, HEAD follow the same patternlocal resp = http.put(url, { body = data, headers = { ... } })local resp = http.patch(url, { body = data, headers = { ... } })local resp = http.delete(url, { headers = { ... } })local resp = http.head(url)
