Skip to main content

Http

Http is a static class used for HTTP communications and requests.

Each server has a rate limit of 90 requests per minute.
The place ID is sent along with the request under the header named PT-Game-ID.
When using the Http :Post, :Put, or :Delete methods, parameters are formatted in query form like this: key1=value&key2=value

Summary

Methods


Methods

Get

Http:Get(url: string, callback: function, headers: array)

Parameters:

ParameterTypeDefaultDescription
urlstring-
callbackfunction-
headersarray-

Sends a GET request to the specified URL.

Example

Http:Get("https://api.polytoria.com/v1/store/25272", function (data, error, errmsg)
if not error then
script.Parent.Color = Color.New(1, 1, 1)
script.Parent.Text = data
else
script.Parent.Color = Color.New(1, 0, 0)
script.Parent.Text = errmsg
end
end,{})

Post

Http:Post(url: string, parameters: string, callback: function, headers: array)

Parameters:

ParameterTypeDefaultDescription
urlstring-
parametersstring-
callbackfunction-
headersarray-

Sends a POST request to the specified URL.

Example

Http:Post("https://example.com/api/post", "id=1&name=Hello" , function (data, error, errmsg)
if not error then
script.Parent.Color = Color.New(1, 1, 1)
script.Parent.Text = data
else
script.Parent.Color = Color.New(1, 0, 0)
script.Parent.Text = errmsg
end
end, {})

Put

Http:Put(url: string, parameters: string, callback: function, headers: array)

Parameters:

ParameterTypeDefaultDescription
urlstring-
parametersstring-
callbackfunction-
headersarray-

Sends a PUT request to the specified URL.

Example

Http:Put("https://example.com", "id=1&content=Hello" , function (data, error, errmsg)
if not error then
script.Parent.Color = Color.New(1, 1, 1)
script.Parent.Text = data
else
script.Parent.Color = Color.New(1, 0, 0)
script.Parent.Text = errmsg
end
end)

Delete

Http:Delete(url: string, parameters: string, callback: function, headers: array)

Parameters:

ParameterTypeDefaultDescription
urlstring-
parametersstring-
callbackfunction-
headersarray-

Sends a DELETE request to the specified url.

Example

Http:Delete("https://example.com/api/delete", "id=1" , function (data, error, errmsg)
if not error then
script.Parent.Color = Color.New(1, 1, 1)
script.Parent.Text = data
else
script.Parent.Color = Color.New(1, 0, 0)
script.Parent.Text = errmsg
end
end)