Coming soon toSteam
Modding docsAPI 1

Module · Engine

http

Send and receive data from websites over HTTPS. Each site must be named in mod.json as "http:site.com" (or "http:*.site.com") and the player agrees to it before the mod runs. The site sees the player's IP address. Only public sites, port 443, no redirects; answers are text up to 4 MB.

http.get(url: string, callback: function, headers?: any): HttpRequest

Fetches a page. callback(response) gets { ok, status, body, error, contentType }. headers may set Accept, Authorization, If-None-Match and X-… headers.

http.get("https://api.example.com/scores?top=10", function(r)
  if not r.ok then return log.warn("scores:", r.error) end
  local scores = json.decode(r.body)
end)

http.post(url: string, body: string, callback: function, contentType?: string, headers?: any): HttpRequest

Sends data. contentType is "application/json" (the default), "text/plain" or "application/x-www-form-urlencoded"; the body may be up to 1 MB.

http.post("https://api.example.com/scores", json.encode({ name = players.me().name, score = 120 }), function(r)
  log.info("saved:", r.status)
end)