Are you New Here ? You might want to:

                    1. Take a look at some of the most popular posts 
                2. Subscribe to the RSS Feed
                3.
about StartupDunia
                4. Leave me a
tip by email

Design and develop API for your website

October 12, 2007 · Posted in India Web 2.0, Tech tidbit 

API’s have prevailed for quite some time now - Amazon, eBay, Yahoo, Google - everyone provides one. API’s are the one that fueled the ‘mashup revolution’ a few years back. Lately however, its all been about the Facebook platform. Since Facebook released their API, thousands of applications have popped up, generating traffic and buzz like never before.

In this multi part post, I’ll try to address some of the details about designing and implementing your own API and what options you have.

What are API’s ?

For the benefit of the non-techies, lets first begin with defining what API’s are and the concept behind API’s. API’s are an abbreviation for Application Programming Interface. API is a set of functions that a computer program/software makes available to other programs so that they can directly talk to the program without actually accessing the source code. For the application developer, the API provider is like a black-box - he has no clue into the implementation of the API. All he knows is about the various functions / queries he can invoke and what results to expect.

api.jpg

Image from xml-rpc.com

So, What are some of the options for implementing your API ?

There are 3 common options for implementing your API - SOAP, XML-RPC and REST.

1) SOAP

Simple Object Access Protocol (SOAP) is a protocol for sending XML messages over HTTP/ HTTPS / JMS / SMTP etc.. The specification for this protocol is maintained by W3. SOAP encapsulates the message in a SOAP ‘envelope’ and expects messages to be sent and received in a particular format. As a result of this, a SOAP toolkit is generally required to create the outgoing messages from the client (application developer) to the API provider.

The pros for using SOAP are: (i) SOAP is not tied to HTTP (although SOAP over HTTP is the most popular combo) (ii) it is easier to pass complex data types using SOAP

However, detractors of SOAP argue that SOAP adds unnecessary complexity to the API implementation. This complexity also contributes additional overhead and greater message size.

Google has one of the most famous API implementations using SOAP.

2) XML-RPC

XML Remote Procedure Call is one of the oldest means of invoking methods on remote servers. The specification is maintained at xmlrpc.com and implementations are available for most of the popular languages. XML-RPC provides a means to invoke a remote call / procedure and make changes and - or retrieve data. At the core, XML-RPC is a HTTP POST with an XML request in the body. The response is also received as a XML message as part of the body.

While XML-RPC is very simple to learn and implement, some developers find this over-simplicity severely limiting at times - for example, XML-RPC doesnt provide the ability to pass an object as an argument to a function.

The most famous XML-RPC API implementations are the blog ping services.

3) REST

Representational State Transfer (REST) has emerged as one of the most popular mechanisms for implementing APIs. Amongst the listed benefits, REST is not only simple but also most closely resembles the intended architecture of the Internet. REST is not a protocol or a specification, but rather a software architecture. The concept of REST revolves around resources, where each resource is uniquely addressable. All resources share the same constrained interface for state transfer. For example, take the Internet - URI’s are used to uniquely address each resource while HTTP methods (GET,POST, PUT etc.) provide a common constrained interface to transfer the state to the client (application developer).

Other than the above listed benefits, REST is cacheable, fast and requires no client side toolkits.

Any non-RPC interface using XML over HTTP, in response to HTTP GET requests is technically called ‘Relaxed REST’. Most of the PHP applications have this ‘Relaxed REST’ API implementation.

So that was a brief summary of the 3 options you have for implementing your API. Next we’ll look into designing and implementing your API. In the meanwhile, I’d like to hear your feedback about this post — it will give me a good idea into how to structure the next post.


1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Similar Posts

Comments

2 Responses to “Design and develop API for your website”

  1. Evangelist on October 17th, 2007 8:46 am

    Nice post. I’d like it more if some links for further reading were also added.

    Thanks

  2. pranav on October 17th, 2007 11:01 pm

    Evagelist,

    I’ll include links as part of the 2nd post that should be coming up soon