Sep 282007

Twitter has been arguably most cloned startsups in recent times. It has the reputation of a startup that has been cloned in most languages across the globe. Amazingly simple idea, and outstanding execution have been drivers behind its success. Simplicity has helped it evolve in multi dimensions as well. However, an important factor behind twitters growth has been the APIs, which have been used by hackers to build multifaceted, useful and interesting applications. You can easily estimate a coarse number of “powered by twitter” apps by the fact that twitter api receives more than 10X traffic than twitter website (as told by twitter co-founder Biz Stone to ReadWriteTalk earlier this month. Click here for the interview transcript). Certainly, APIs have helped twitter to reach every corner of web in form of various interesting applications, and the list is increasing day by day rapidly. No wonder, it has become developer’s darling.

Twitter API scores for its simplicity, ease of use, diversity, multiple data formats, and above all simple REST architecture. Since twitter was much simpler service with its veins powered by text messages, the existing RSS feeds laid a good foundation for first API set. The API is as simple as firing HTTP requests and receiving responses in any of the four formats, plain old XML, JSON, RSS and Atom. Out of these formats, RSS and Atom are most easy to use as they already have matured parsers on almost every platform being used today. But since RSS and Atom have a predefined DTD, it has a limited footprint and does not capture much information. XML and JSON provide a better and complete view, but you need to take help of third party abstractions in order to use them efficiently. For example, twitter request for obtaining public timeline in XML is http://twitter.com/statuses/public_timeline.xml. A typical response looks like this

<status>
<created_at>Thu Sep 27 18:42:18 +0000 2007</created_at>
<id>297192592</id>
<text>i just want to know what they are doing at all times</text>
<source>im</source>
<truncated>false</truncated>
<user>
<id>8697452</id>
<name>bluecat34</name>
<screen_name>bluecat34</screen_name>
<location />
<description/> <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/ 24378882/ mommy_marissa_normal.jpg</profile_image_url>
<url />
<protected>false</protected>
</user>
</status>

The same response in RSS, ATOM and JSON is like

RSS

<item>
<title>cc_chapman: scheduled to slide into PME around 5 – can’t wait</title>
<description>cc_chapman: scheduled to slide into PME around 5 – can’t wait</description>
<pubDate>Thu, 27 Sep 2007 18:52:26 +0000</pubDate>
 <guid>http://twitter.com/cc_chapman/statuses/297208942</guid>
 <link>http://twitter.com/cc_chapman/statuses/297208942</link>
</item>

ATOM

<entry>
   <title>petestone: longest day ever</title>
   <content type=”html”>petestone: longest day ever</content>
 <id>tag:twitter.com,2007-09-27T18:53:17+00:00:http://twitter.com/petestone/statuses/297210002</id>
   <published>2007-09-27T18:53:17+00:00</published>
   <updated>2007-09-27T18:53:17+00:00</updated>   <linktype=”text/html” href=”http://twitter.com/petestone/statuses/297210002” rel=”alternate”/>
</entry>

JSON

{“user”:{“name”:”Jessica”,”profile_image_url”:”http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/23719302\/JeffDIcon_normal.jpg”,”description”:”",”location”:”",”url”:null,”screen_name”: “MissJess”,”id”:8610542,”protected”:false},”truncated”:false,”text”:”@limespinkles: good luck, Bestie!!”,”created_at”:”Thu Sep 27 18:54:20 +0000 2007″,”source”:”web”,”id”:297211822}

You must have realized that information conveyed by different formats varies. JSON and XML give additional info, whereas RSS and ATOM just provides the messages. Now it is upto you on which format to use. My recommendation for browser based apps is JSON, as it nicely works with javascript, and XML, in case you wish to use it on server side. RSS and ATOM are not information rich, so should be use only when your requirements are fulfilled with mere message and timestamp.

REST powered API is easy to understand and all you need is a browser to play around with it. Although Twitter seems curl territory, but i feel your browser is a good place to begin with. The APIs are nicely documented on twitter wiki and twitter fan wiki. In case you are a “flashy” developer, then start using their actionscript libraries as mentioned on twitter blog. In case you speak Java, Python, .NET, Runy on Rails, php or perl, and find HTTP/XML/JSON/ATOM/RSS too basic/cryptic/unfriendly/, then there is enough juice for you to get started with twitter APIs here.

There are lots of “Powered by Twitter” apps. TwitterGram, and TwitterEarth  are significantly better ones. The most recent interesting app is twiddeo. You can feel twitter power when you go through a really loooong list of twitter apps on twitter fan wiki. No wonder how 10x traffic emerged.

Twitter is a slowly maturing into a robust communication platform. It provides a scalable message delivery system which can be utilized in number of ways other than sending statuses. Many apps utilize twitter for email/blog notifications(EmailTwitter), website monitoring(MoniTwitter), server monitoring(ServerMojo), news delivery (BBC News, Manchester United News). Some pundits even talk of twitter as a publishing platform.

Twitter API is a useful tool to have. It has built a mature and versatile message delivery network over a period of time, which can be utilized nicely provided it is integrated with other useful services. It can deliver weather forecasts, stock quotes, new arrivals in a store, public address messages, school notices etc. Time will tell where it will head, but this is for sure that it will continue to power better and useful apps each day.

ashish

blog comments powered by Disqus

Switch to our mobile site