API

 
 
Urlsaf.com offers a powerful API to interact with other sites.

Simple API

  • GET requests: http://urlsaf.com/api.php?url=YOUR-LONG-URL&custom=YOUR-CUSTOM-NAME
        http://urlsaf.com/P
      


Write API Endpoints:

  • GET requests: http://urlsaf.com/API/write/get
  • POST requets: http://urlsaf.com/api/write/post

Variables:


You can pass up to 8 variables to control the response or your application.
  • URL: The URL you want to shrink. required.
  • custom: Custom name. optional.
  • type: Response type (json|xml). optional, default: json.
  • private: Set URL to private (not listed). optional
  • password: Set URL password. optional (max 10 chars)
  • uses: Number of uses for the URL. optional
  • expire: date in format MM/DD/YYYY to expire URL. optional
  • via: Adds a signature to track your application. optional

Example:


http://urlsaf.com/API/write/get?url=http://youtube.com&custom=mycustomname&type=xml

XML Response example:


        <response>
        <success>1</success>
        <data>
        <id>mycustomname</id>
        <url>http://urlsaf.com/mycustomname</url>
        <full>http://youtube.com</full>
        <hits>0</hits>
        <status>custom_new</status>
        <via>api</via>
        <date>1330715001</date>
        <last>1330719941</last>
        </data>
        </response>
      


Read API Endpoints:

  • GET requests: http://urlsaf.com/API/read/get
  • POST requests: http://urlsaf.com/api/read/post

Variables:


You can pass up to three variables to control the response or your application.
  • id: ID of the URL you want to access. required.
  • password: password for URL (if protected). optional.
  • type: Response type (json|xml). optional, default: json.

Example:


http://urlsaf.com/API/read/get?id=P&password=0000&type=xml

XML Response example:


        <response>
        <success>1</success>
        <data>
        <id>P</id>
        <hits>101</hits>

        <hits>0</hits>
        <full>http://google.com</full>
        <created>1334239095</created>
        <last>1334241124</last>
        </data>
        </response>
      

Tags:

  • success: (true|false) for request success.
  • data:
    • id: Unique identifier of URL.
    • url: Shortened URL.
    • full: Full URL before shortened.
    • uses: Clicks left to inactivate URL.
    • hits: Number of hits to the link.
    • date: Timestamp where the URL was making.
    • last: Timestamp for the last click.
    • last: Timestamp to inactivate link.


XML Error example:


        <response>
        <success>0</success>
        <error>
        <code>0</code>
        <msg>domain not allowed</msg>
        </error>
        </response>
      


Tags:

  • success: (true|false) for request success.
  • error:
    • code: Error code: 0, 1 and 2.
    • URL: Error msg.