Our Blog

RAAK.it API documentation


Posted by
7 October 2010
11:39
2 comments

RAAK.it API documentation

Here are the calls in the raak.it URL shortener API:

The API is a RESTful API, ie each call is implemented as a URI.
All calls return JSON strings as output.

register.php

http://raak.it/register.php?url=your url

your url: The URL you want to shorten.

output:

  • code: 0 on success, a negative value on error, translating to:
    • -1: No URL was entered
    • -2: URL could not be resolved
    • -3: URL returned an error
    • -4: Cannot connect to the database
    • -5: Cannot select the database
    • -6: Cannot query the database
    • -7: URL was stored before, but it can not be fetched
    • -8: URL was not stored before, and it can not be entered into the database
    • -9: URL’s page title could not be updated
  • result: only on success, the short URL that will redirect to the given URL
  • error: only on error, a message describing the error
  • http_code: only on error code -2, the HTTP code returned
  • mysql_error: only on error codes -4 to -9, a message describing the database error

retrieve.php

http://raak.it/retrieve.php?shorturl=short url

short url: The short URL whose long URL you want to retrieve.

output:

  • code: 0 on success, a negative value on error, translating to:
    • -1: No short URL was entered
    • -4: Cannot connect to the database
    • -5: Cannot select the database
    • -6: Cannot query the database
    • -8: Cannot update this retrieval stat (still returns URL)
    • -9: URL can not be found
  • result: only on success, or error code -8, the long URL that will be redirected to by the given short URL
  • error: only on error, a message describing the error
  • mysql_error: only on error codes -4 to -8, a message describing the database error

stats.php

http://raak.it/stats.php?[url=long url][shorturl=short url]

long url (optional): The long URL whose stats you want to retrieve.
short url (optional): The short URL whose stats you want to retrieve.
default (no args): Basic stats (no ip addresses) for all URLs.

output:

  • code: 0 on success, a negative value on error, translating to:
    • -1: No short URL was entered
    • -4: Cannot connect to the database
    • -5: Cannot select the database
    • -6: Cannot query the database
    • -9: URL can not be found
  • urls: a list of URL stats
    • url hash: The hash part of the short url, acts as a key
      • url: The long URL
      • title: The page title of the URL
      • count: The amount of hits on the URL
      • ips: (only when shorturl or url have been provided) A list of IP address that visited this URL
  • error: only on error, a message describing the error
  • mysql_error: only on error codes -4 to -8, a message describing the database error

Posted by

2 Trackbacks

  • By How do URL shorteners work? – RAAK on October 7, 2010 at 12:22 pm

    [...] We’ve implemented this idea as a URL shortener here, with an API, which is documented here. [...]

  • By RAAK - Putting you in touch with your crowds on October 11, 2010 at 10:00 am

    [...] you ever wonder exactly how URL shorteners work? So did we, so we built one (with an API). This week's tech insight explores the problem of mapping long URLs into short ones, and the [...]

Leave a Comment

Your email is never shared. Required fields are marked *