Http¶
Static Class
This object is a static class. It can be accessed by using it's name as a keyword like this Http
.
Additionally, it cannot be created in the creator menu or with Instance.New()
Http is a static class used for HTTP communications and requests.
This is only available to the server. It can only be accessed within server scripts.
Each server has a rate limit of 15 requests per minute.
The place ID is sent along with the request under the header named PT-Game-ID
.
When using Http :Post
, :Put
, or :Delete
parameters are formatted in query form like this: key1=value&key2=value
Methods¶
Get → void
¶
Parameters
url [ string
]
callback [ function
]
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 → void
¶
Parameters
url [ string
]
parameters [ string
]
callback [ function
]
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 → void
¶
Parameters
url [ string
]
parameters [ string
]
callback [ function
]
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 → void
¶
Parameters
url [ string
]
parameters [ string
]
callback [ function
]
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)