ProjectArea51 URL Shortener
This is our short url/memo service which runs at a51.li.
An earlier incarnation got hacked by spammers so for the last few years this service has been locked down.
Please do not ask for access to this service as you'll almost certainly be declined. These instructions are here just incase I do allow external access to this service.
Calling the service
Access to any of the endpoints on this service requires an Authorization request header included with the API key included.
curl -H 'Authorization: {{key}}' http://api.area51.onl/shorturl/{{endpoint}}
Generating a unique ID
The genid endpoint generates a unique ID used by the service. This ID is unique so one generated by this endpoint will never be reused by another part of the service.
$ curl -H 'Authorization: {{key}}' http://api.area51.onl/shorturl/genid "nUarQuLd"
Generating a short URL
This endpoint generates a short URL and makes it available on a51.li.
To use you need to make a http POST request with the request body containing a JSON object with one key url which contains the url to shorten.
$curl -H 'Authorization: {{key}}' -d '{"url":"{{url}}"}' http://api.area51.onl/shorturl/shorten {"surl":"http://a51.li/nUarQuLd","token":"nUarQuLd","dest":"http://maidstoneweather.com/","type":"link"}
The returned JSON object describes the details of that URL
Key | Value |
---|---|
dest | The destination URL |
surl | The shortened URL |
token | The generated ID used in the shortened URL |
type | Always link for results from this endpoint |
Recipes
Shorten a url within a bash script
sudo apt-get install jq
This recipe will shorten a URL from within a bash script:
$ URL='http://area51.onl/' $ SURL=$(curl -s -H 'Authorization: {{key}}' \ -d "{\"url\":\"$URL\"}" \ http://api.area51.onl/shorturl/shorten |\ jq -r 'select(.surl!=null)|.surl') $ echo $SURL http://a51.li/nUafcFpK
The bash variable SURL will either contain a url or be empty if there was a failure.