rcdn.net implements some
of bit.ly
API, shorten and expand, without authentication.
Contents
For a long URL, /api/shorten encodes a URL and returns a short one.
Parameters
- format (optional): indicates the requested response
format. supported formats: json (default), xml, txt.
- longUrl: is a long URL to be shortened (example:
http://betaworks.com/).
Notes
- Long URLs should be URL-encoded. You can not include a longUrl in
the request that has '&', '?', '#', ' ', or other reserved
parameters without first encoding it.
- Long URLs should not contain spaces: any longUrl with spaces will
be rejected. All spaces should be either percent encoded (%20) or
plus encoded (+). Note that tabs, newlines and trailing spaces are
all indications of errors. Please remember to strip leading and
trailing whitespace from any user input before shortening.
- Long URLs must have a slash between the domain and the path
component. For example, http://example.com?query=parameter is
invalid, and instead should be formatted as
http://example.com/?query=parameter
Output
- new_hash: always 0
- url: is the rcdn.info link (shortened info) that should be used.
- hash: is a path of the rcdn.info link.
- global_hash: same as hash.
- long_url: is an echo back of the longUrl request parameter. This
may not always be equal to the URL requested. That's because some
URL normalization may occur (e.g., due to encoding differences, or
case differences in the domain). This long_url will always be
functionally identical the the request parameter.
Examples
- json format: http://rcdn.info/api/shorten?longUrl=http%3A%2F%2Fbetaworks.com%2F&format=json
{
"status_code": 200,
"data": {
"url": "http://rcdn.info/cmeH01",
"hash": "cmeH01",
"global_hash": "cmeH01",
"long_url": "http://betaworks.com/",
"new_hash": 0
},
"status_txt": "OK"
}
- xml format: http://rcdn.info/api/shorten?longUrl=http%3A%2F%2Fbetaworks.com%2F&format=xml
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status_code>200</status_code>
<status_txt>OK</status_txt>
<data>
<url>http://rcdn.info/cmeH01</url>
<hash>cmeH01</hash>
<global_hash>cmeH01</global_hash>
<long_url>http://betaworks.com/</long_url>
<new_hash>0</new_hash>
</data>
</response>
- txt format: http://rcdn.info/api/shorten?longUrl=http%3A%2F%2Fbetaworks.com%2F&format=txt
http://rcdn.info/cmeH01
Given a rcdn.info URL or hash (or multiple), /api/expand decodes it
and returns back the target URL.
Parameters
- format (optional): indicates the requested response format. supported
- formats: json (default), xml, txt.
- shortUrl: refers to one or more rcdn.info URLs, (e.g.:
http://bit.ly/1RmnUT or http://j.mp/1RmnUT).
- hash: is a path of the rcdn.info link.
Note
- Either shortUrl or hash must be given as a parameter
- The maximum number of shortUrl and hash parameters is 15
Output
- short_url: this is an echo back of the shortUrl request parameter.
- hash: this is an echo back of the hash request parameter.
- user_hash: same as hash.
- global_hash: same as hash.
- error: indicates there was an error retrieving data for a given
shortUrl or hash. An example error is "NOT_FOUND".
- long_url: is the URL that the requested short_url or hash points to.
Examples
- json format:
http://rcdn.info/api/expand?shortUrl=http%3A%2F%2Ftcrn.ch%2Fa4MSUH&shortUrl=http%3A%2F%2Frcdn.info%2F1YKMfY&hash=j3&hash=a35.&format=json
{
"status_code": 200,
"data": {
"expand": [
{
"short_url": "http://tcrn.ch/a4MSUH",
"global_hash": "a4MSUH",
"long_url": "http://www.techcrunch.com/2010/01/29/windows-mobile-foursquare/",
"user_hash": "a4MSUH"
},
{
"short_url": "http://rcdn.info/1YKMfY",
"global_hash": "1YKMfY",
"long_url": "http://betaworks.com/",
"user_hash": "1YKMfY"
},
{
"long_url": "http://www.scotster.com/qf/?1152",
"global_hash": "lLWr",
"hash": "lLWr",
"user_hash": "lLWr"
},
{
"hash": "a35.",
"error": "NOT_FOUND"
}
]
},
"status_txt": "OK"
}
- xml format: http://rcdn.info/api/expand?shortUrl=http%3A%2F%2Ftcrn.ch%2Fa4MSUH&shortUrl=http%3A%2F%2Frcdn.info%2F1YKMfY&hash=j3&hash=a35.&format=xml
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status_code>200</status_code>
<status_txt>OK</status_txt>
<data>
<entry>
<short_url>http://tcrn.ch/a4MSUH</short_url>
<long_url>http://www.techcrunch.com/2010/01/29/windows-mobile-foursquare/</long_url>
<user_hash>a4MSUH</user_hash>
<global_hash>a4MSUH</global_hash>
</entry>
<entry>
<short_url>http://rcdn.info/1YKMfY</short_url>
<long_url>http://betaworks.com/</long_url>
<user_hash>1YKMfY</user_hash>
<global_hash>1YKMfY</global_hash>
</entry>
<entry>
<hash>lLWr</hash>
<long_url>http://www.scotster.com/qf/?1152</long_url>
<user_hash>lLWr</user_hash>
<global_hash>lLWr</global_hash>
</entry>
<entry>
<error>NOT_FOUND</error>
<hash>a35.</hash>
</entry>
</data>
</response>
- txt format: http://rcdn.info/api/expand?shortUrl=http%3A%2F%2Frcdn.info%2F31IqMl&format=txt
http://cnn.com/
|