One of the great outgrowths of the Web 2.0 phenomenon has been an increased availability of Web APIs – Internet-based services with an HTTP-based programming interface. Gone are the days when developers would furtively “scrape” HTML pages for data or useful information. Now major Web services make easier, stabler, and more open ways to read and modify data on their servers.
Many APIs are simply formalized interfaces to a user-centric application. The Flickr API, for example, is an elegant and convenient interface that's a great example for anyone thinking of providing an API. But for developers, if you're not making a Flickr client or building a Flickr mashup, it's not really that useful.
< See a slide show of the screen shots: Slideshow>
< Glossary of terms: Glossary>
Here are some of the more interesting and important APIs that you can use for real programming problems, either in Web applications or in desktop or server software.
It's possible to use competitors to the API, including Yahoo's Map API and Microsoft's Virtual Earth. In time we'll see more alternatives, such as integrating the cool OpenLayers map widget with data services that support the standardized Open Geospatial Consortium APIs. But today Google Maps is the best of the mapping APIs. If you're interested in future-proofing your application, you can use Mapstraction, a toolkit that gives a single interface layer to Google and Yahoo as well as the OpenStreetMap user-generated mapping service.
One of the key parts of any geographical application is geocoding -- turning feature names like “Mountain View, California” or “Lake Baikal” into latitude/longitude pairs that can be put on a map or compared with other map points. Google and Yahoo both have geocoding APIs, but they have some heavy restrictions on use and confusing copyright rules.
I prefer the data from Geonames.org, which has a simple REST service for geocoding names, finding locations close to each other, and some other great geographical backend calculations. The Geonames database is one of the best available, based on multiple data sets, and it uses a liberal Creative Commons Attribution license for its data output. It's also quick and responsive.
No, Web APIs aren't just about maps and map data – they can be about people, too. OpenID is a new service created by blogging company Six Apart and adopted by many other sites. The API lets you offload the tasks of registering and managing user accounts from your application to an identity provider. Users like it because they can use one user account on several different Web sites. Conversely, identity providers can use the API so their users can use other Web sites without having to maintain separate accounts.
The API is interesting in that it depends on HTTP redirects to and from the identity provider Web site. This allows logon systems that depend on browser state, such as cookies or certificates. Parameters are passed back and forth through URL parameters, including digital signatures for validation. A great set of open source libraries in Perl, Python, Ruby and PHP from JanRain, makes integrating this API relatively painless.
4. Amazon S3
One clever system for off-loading tedious Web development tasks is the Simple Storage Service (S3) from Amazon's Web Services. S3 lets you store and manage files on a Web server in Amazon's data center, and you can use the API to secure certain files from the public. S3 has both a REST and a Simple Object Access Protocol (SOAP) interface, and Amazon charges a few pennies for each gigabit of data stored or transferred.
S3 is a really convenient way to scale storage of data, and there are applications from simple backup services to rich Web applications. The photo-sharing service SmugMug, for example, uses S3 as the backend storage for all its images, saving the time and effort of provisioning dozens of Web servers.
5. Amazon EC2
In a similar vein to S3, Amazon has a distributed computing service called the Elastic Compute Cloud (EC2). EC2 is a Web service that lets you build virtual servers for any purpose – you get a Xen instance for each one – and turn them on or off as needed. It's a server farm rental service, expandable to as many servers as you need, controlled with a simple interface.
Amazon provides a set of command-line tools for the service, but it will be interesting to see how other tools integrate this service. Building the API into a server watchdogs, failover tools or load-balancing systems are some exciting applications. Although this service is still in beta, it has the capacity to change the way we build data centers.
6. Atom API
One of the most tedious tasks in Web development is importing and exporting data to and from content management systems and other dynamic Web sites. The pioneering work in creating desktop user interfaces and command-line tools for publishing was with the Blogger, MetaWeblog and Movable Type APIs, but this work has been generalized and expanded for other kinds of Web sites to the newer Atom API 0.3.
Atom is a REST-like API that uses Post requests to create new resources on the target site, and Get, Put and Delete requests to manipulate existing pages. There's also an optional SOAP interface, although it seems to be only rarely supported. The Atom API is supported by many blogging services and a number of open source content management systems (CMS). The API's uptake has been slower than its sibling Atom feed standard (a replacement for RSS), but it's rapidly displacing proprietary blogging and posting APIs.
When Amazon's A9 search service and aggregator launched in 2004, the company took a new tack on search aggregation. Instead of running its own spiders, unilateral database licenses, or running screen scrapers on other search engines, the company developed and promoted an open standard API. Called OpenSearch, this simple REST-based API is a convenient back-channel for retrieving search results from a number of OpenSearch-enabled sites.
Its most basic configuration is a discovery system – using HTML headers – to find search engines for sites and determine the order and names of URL parameters for sending a REST-like search request with HTML output. A more sophisticated level returns an Atom feed of multiple results, leaving it up to the client to display or analyze each result. OpenSearch has been integrated into the search bars for Mozilla Firefox 2.0 and Internet Explorer 7.0, which has given the standard a considerable boost.
The Web itself is a pretty impressive data-interchange mechanism, but it operates at a coarse-grained level of files. Exchanging pieces of objects, structured objects, or collections of objects can be kind of tricky, and marking up metadata can also be hard. There have been a number of efforts to make it easier to interchange marked-up data, such as Google's GData and Yahoo's MediaRSS. At the launch of its new Vox blogging service, Six Apart also launched a new media-exchange API, the Open Media Profile.
The Open Media Profile is based on OpenSearch's REST-like interface, but adds key output extensions for exchanging richer data types than Atom feeds usually handle. It supports embedded and linked objects and licensing metadata. Although its data interchange tools are better than competing standards, it lacks the unification of data exchange and update found in GData. There's still not a clear lead in this area.
9. MediaWiki API
With almost 6 million Wikipedia articles in all the various languages, managing the corpus of wiki work from Wikimedia Foundation is a huge task. Programmatic interfaces to MediaWiki and other wikis has always been through scraping HTML pages, and some “bot” creators have raised it to a fine art. But the development of a new API for MediaWiki Web sites – including Wikitravel, Wiktionary, and WikiNews – will make that considerably easier and less error-prone.
The MediaWiki API is a REST query mechanism that returns XML, YAML or JSON results. Although it's currently read-only, existing mechanisms for writing articles still work. Other wiki engines, including SocialText and PbWiki, are also building APIs. A nascent cross-engine standard, Amo, might provide a unified API for wikis the way that Atom has for blogs and CMSs.
There's an important future for this kind of quick, configurable widget that offloads tedious tasks for Web site developers. The Microapps project is building some similar open source tools for Web features such as tagging and search. Hopefully more large-scale application components will be delivered as Web APIs in the future.
One feature that all of these APIs have in common is their helpful, even evangelical, developer documentation. At the sites in the Related Links section, you'll find instructions and sample code for integrating this powerful functionality into your own Web application. Instead of rewriting, next time give a Web API a try.
This story, "Ten Web 2.0 APIs you can really use" was originally published by LinuxWorld-(US).