Skip to content
mlemos edited this page Sep 13, 2010 · 19 revisions

Welcome to the Zapt.In API wiki!

Introduction

Zapt.In is a free URL shortening service. It was initially developed focusing the Brazilian Twitter community and was inspired by Bit.Ly and Migre.Me.

The Zapt.In API allows developers to interact with the Zapt.In website and it’s services. The API is designed with RESTful orientation and has the goal to be simple and to empower the developers community.

The API is compatible (on JSON and XML formats) with the Bit.Ly API. So, if you have already integrated your system with Bit.Ly, you can do the integration with Zapt.In with just a few modifications.

The current API version is 1.0.

Authentication

Authentication required for all interactions with the API.

To perform an authenticated request you need to provide both the user login and user api key as query arguments.

login=user_login&key=user_api_key

Every registered site user has an unique user api key. To grab or renew his key, a logged user has to go to the “Perfil” menu in the top right menu bar.

Shared Parameters

Besides to the optional authentication parameters, API calls may request or accept some other query parameters:

API Version

All API calls requires a version identifier to be present.
Current version is 1.0.

version=1.0

Response Format

All API calls accepts an optional response format.

format=json
  • Options: json | xml | text
  • Default: json

Remember that the JSON and XML formats are compatible with the Bit.Ly API.

Rate Limit

Currently the API usage has a default rate limit of 100 requests per hour for authenticated users or 100 requests per hour. In general, if you’re planning to be a higher volume user of the API, please contact us at [email protected] and we’ll try to help you.

Error Codes

When any error occurs while handling your request, you’ll get a response error with the error code, error message and status code.

The status code for errors is always ERROR.

The available error codes and respective error messages are:

  • 1, %s
  • 201, Missing parameter %s.
  • 203, You must be authenticated to access %s.
  • 206, You specified an invalid version number. Valid versions are [1.0].
  • 207, There was a problem posting your request. Please try again.
  • 999, Method %s is not implemented yet.
  • 1213, We could not find a long URL for that short URL.

Error Response Formats

JSON

{"statusCode":"ERROR","errorCode":203,"errorMessage":"You must be authenticated to access shorten."}

XML

<zaptin>
	<errorCode>@respond_error_code</errorCode>
	<errorMessage>@respond_error_message</errorMessage>
	<statusCode>@respond_status_code</statusCode>
</zaptin>

TEXT

203, You must be authenticated to access shorten., ERROR

Method: shorten

The shorten method is used to shorten a given URL.
This method requires a unique parameter longUrl.

example:

http://zapt.in/api/links/shorten?format=json&version=1.0&login=fulano&key=Z_73904ea9ffdf121223f81743dce73777&longUrl=http://google.com

Shorten response

The data you need from the response are the shortUrl and the userHash. Those two values refers to the new short URL you created with the request and they represent the user specific short URL. The hash parameter refers to the global short URL for the original URL. This is just like Bit.Ly.

JSON

{"errorCode":0,"errorMessage":null,"results":{"http://google.com":{"hash":"9","shortKeywordUrl":null,"shortUrl":"http://zapt.in/8J","userHash":"8J"}},"statusCode":"OK"}

XML

<zaptin>
  <errorCode>0</errorCode>
  <errorMessage></errorMessage>
  <results>
    <nodeKeyVal>
      <userHash>8J</userHash>
      <shortKeywordUrl></shortKeywordUrl>
      <hash>9</hash>
      <nodeKey>
        <![CDATA[http://google.com]]>
      </nodeKey>
      <shortUrl>http://zapt.in/8J</shortUrl>
    </nodeKeyVal>
  </results>
  <statusCode>OK</statusCode>
</zaptin>

TEXT

http://zapt.in/8J

Method: expand

The expand method is used to retrieve the long URL for a given shortUrl or hash.
This method requires one of two parameters: shortUrl or hash.

example:

http://zapt.in/api/links/expand?format=json&version=1.0&login=fulano&key=Z_73904ea9ffdf121223f81743dce73777&shortUrl=http://zapt.in/8J

Expand response

JSON

{"errorCode":0,"errorMessage":null,"results":{"8J":{"longUrl":"http://google.com"}},"statusCode":"OK"}

XML

<zaptin>
  <errorCode>0</errorCode>
  <errorMessage/>
  <results>
    <Wp>
      <longUrl>http://asdasd</longUrl>
    </Wp>
  </results>
  <statusCode>OK</statusCode>
</zaptin>

TEXT

http://google.com