In order to allow easy integration of this service with other websites, and to allow other developers to make great use of this service in their scripts and applications, tny.im offers a public API that doesn't need any authentication to work.
You need to send parameters to http://tny.im/yourls-api.php
either via GET
or POST
. These parameters are:
action
: "shorturl" (get short URL for a link), "expand" (get long URL of a shorturl) or "url-stats" (get stats about one short URL).url
to shortenkeyword
for custom short URLstitle
for custom titlehitlimit
for when an short link shouldn't redirect more than a certain amount of hits. Don't specify or set to 0 (zero) for unlimited hits.timelimit
to set the longevity of the link in seconds. Don't specify or set to 0 (zero) to disable the time limit.format
: either "json", "xml" or "simple"shorturl
to expand (can be either 'abc' or 'http://site/abc')format
: either "json", "xml" or "simple"shorturl
for which to get stats (can be either 'abc' or 'http://site/abc')format
: either "json" or "xml"format
: either "json" or "xml"<?xml version="1.0" encoding="iso-8859-1"?> <result> <url> <keyword>shortie</keyword> <url>http://longlonglong.org/long.php/longestever/verylong.long.long.php</url> <title>A page with a very long URL</title> <date>2013-07-30 07:11:49</date> <ip>tny.im does not make public the IP address of the creator of a short url</ip> <hitlimit>20</hitlimit> <price>0</price> <payoutaddr></payoutaddr> <passcode>yuAg0Y</passcode> </url> <status>success</status> <message>http://longlonglong.org/long.php/longestever/verylong.l[...] added to database</message> <title>A page with a very long URL</title> <shorturl>http://tny.im/shortie</shorturl> <statusCode>200</statusCode> </result>
The price and payoutaddr fields are part of the output for discontinued features and should be ignored.
To see a PHP script that works with the YOURLS API (and thus, the tny.im API), click here.