PublicRest is a set of publicly accessible RESTful APIs.
The request rate is limited to 50 requests per second.
The root url is publicrest.co
. It supports both HTTP
and HTTPS
, HTTPS
is preferred.
Get the ip of the client.
Example: https://publicrest.co/util/loc/ip
Output:
{"ip":"xxx.xxx.xxx.xxx"}
By default, the time is in epoch(unix) format. Changing formats are possible by specifying the format using the query param format
.
Possible formats are:
- epoch
- iso8601
Get the current timestamp (NOW) in UTC.
Query param days
can be used to get a timestamp shifted by the number of days relative to NOW. The default value is 0.
Example: https://publicrest.co/util/time/now?days=-1
Output:
{"format":"epoch","time":1487386371}
Get yesterday's timestamp (exactly 1 day before NOW) in UTC.
Output:
{"format":"epoch","time":1487300560}
Get tomorrow's timestamp (exactly 1 day after NOW) in UTC.
Output:
{"format":"epoch","time":1487473371}
The cache service is backed by a redis instance, and the maximum TTL is 3600.
Save a value to the cache.
Input:
{"value":"Hello","ttl":60}
Output:
{"token":"897b9e50ab","ttl":60}
Save a value to the cache. This is the GET
analog of the above POST
request.
Example: https://publicrest.co/util/cache/set?value=Hello&ttl=60
Output:
{"token":"897b9e50ab","ttl":60}
Get the value cached on the server using the token returned by the POST
call.
Output:
{"value":"Hello"}
Get the user agent from the request.
Output:
{"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"}
Get all headers from the request.
Output:
{
"Connection": "keep-alive",
"Accept": "text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8",
"Accept-Language": "en-US, en;q=0.8",
"Accept-Encoding": "gzip, deflate, sdch, br",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
}