Skip to content
GAMPEONCreate
New project
Preview: this works today, but details can still change.

HTTP requests

server.lua
PerformHttpRequest('https://api.example.com/status', function(status, body, headers, errorData)
if status == 200 then
local data = json.decode(body)
print(data.message)
else
print('request failed', status, errorData)
end
end, 'GET', '', { ['Accept'] = 'application/json' })
  • Only server scripts can make HTTP requests.
  • Methods: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.
  • status is 0 when there was no answer, for example on a timeout or a blocked address.
  • body is set for successful answers. For errors, errorData holds the error text or the error body.
  • Pass { timeout = 5000 } as the sixth argument to change the timeout (default 30 s).
  • Requests to private and local addresses (127.0.0.1, 10.x, 192.168.x, localhost and similar) are blocked. Your server’s own network stays out of reach of scripts.
  • URLs with a user name or password are refused. Send credentials in a header.
  • Request bodies are limited to 1 MB and responses to 16 MB. At most 32 requests per resource run at the same time.

Report a problem with this pageOther ways to give feedback