-
Notifications
You must be signed in to change notification settings - Fork 888
Polr PaaS API Documentation
All API calls should be directed to /api.php
.
You will need to request an API key from a developer in order to use the Polr
API. Once you have one, send it as the GET or POST variable apikey
. This is
required for every API call. If the API key is not sent, or is invalid, the API
will return with the status code 401 (Unauthorized).
Request an API key by joining our IRC channel (freenode, #polr), or by emailing us ([email protected]).
Actions are passed in the GET or POST variable action
. There are currently
two actions implemented:
-
shorten
- shortens a URL -
lookup
- looks up the destination of a shortened URL
Actions take arguments, which are passed as GET or POST parameters.
The shorten
action takes a single argument: url
. This is the URL to
shorten. The API will return with a plain text response containing a
shortened URL.
Example: GET http://polr.cf/api.php?apikey=key&action=shorten&url=http://google.com
Remember that the url
argument must be urlencoded (unless it is passed as a
POST parameter).
The lookup
action takes a single argument: url
. This is the URL to
lookup. If it exists, the API will return with the destination of that URL. If
it does not exist, the API will return with the status code 404 (Not Found).
Example: GET http://polr.cf/api.php?apikey=hunter2&action=lookup&url=3
Remember that the url
argument must be urlencoded (unless it is passed as a
POST parameter).
The API will respond in plain text. For lookup
and shorten
, it will reply with a URL, e.g http://polr.cf/123
or http://alookedupurl.com
.
<?php
$shortenedurl = file_get_contents('http://polr.cf/api.php?apikey=key&action=shorten&url=http://google.com');
echo "The shortened version of http://google.com is $shortenedurl";
?>
import urllib2
response = urllib2.urlopen('http://polr.cf/api.php?apikey=key&action=shorten&url=http://google.com')
short = response.read()
print "Polr Shortened Google URL "+short
or use our Python wrapper (by skasturi):
First, install the wrapper through PyPi. pip install polr
. then, import the module, then:
import polr
polr.apikey = "yourkeyhere"
url = polr.shorten("http://google.com")
You may perform a GET request to Polr's servers in order to shorten a URL, or use our Node.js wrapper (by fwilson).
Install the wrapper npm install polr
, then docs needed. https://www.npmjs.org/package/polr