3.13 Web Services, Mashups, Widgets
“Design for ‘hackability’
Instead of reinventing the wheel with every new project,
developers can use existing companies’ web
services to create feature-rich applications. Incorporating
web services into new programs allows people to develop new applications
(Application Programming Interfaces) provide applications
with access to external services and databases. For example, a traditional
programming API, like the Sun’s
Java API, allows programmers to use already-written
methods and functions in their programs. Web
services APIs are now offered by some websites as ways of
sharing some of their functionality and information across the Internet.
Unique databases are central to Web 2.0; “data is
the next Intel Inside.”2 Whether data is obtained from a proprietary source or collected
over time from users, much of a site’s value is in its databases.
Many major Web 2.0 companies (e.g., eBay, Amazon, Google, Yahoo! and Flickr) provide APIs to encourage use
of their services and data in the development of mashups, widgets and
combine content or functionality from existing web services, websites
and RSS feeds to serve a new purpose. For example, Housingmaps.com is a mashup of Google
Maps and real-estate listings from Craigslist. Mashups with maps
are particularly popular, as are mashups using RSS feeds (see
“RSS and Atom” in Section 3.15) created by using
services such as Yahoo! PipesTM—a
tool that enables you to aggregate and manipulate many data sources.
Using APIs can save time and money (some great mashups
have been built in an afternoon); however, the mashup is then reliant
on one or more third parties. If the API provider experiences downtime,
the mashup will be unavailable as well (unless the mashup is programmed
to avoid sites that are down). Always check the “terms of service”
for using each company’s web services. Many API
providers charge usage fees based on the mashup’s number
of calls made to the server. Some sites require you to ask permission
before using their APIs for commercial purposes, and others (e.g., Google) require that mashups
based on their web services be free. Also, while mashups add value to
data, there is always the question of who owns the data, and thus who
should profit from the mashup.
Figure 3.4 lists
some popular mashups. The site Programmable Web catalogs APIs
and mashups and offers a “Mashup Matrix” (http://www.programmableweb.com/matrix)
detailing which APIs have been combined to form each mashup. As more
companies offer APIs, the only limitation on mashups (and the businesses
built on them) is the developer’s creativity. More complex mashups,
using programs like Google
Earth and Second Life, could be coming
Widgets and Gadgets
Widgets, also referred to as gadgets, are mini applications designed
to run either as stand-alone applications or as add-on features in web
pages. Newsweek called 2007 the
“Year of the Widget” because of the huge increase in popularity
of these applications.4 Widgets can be used to personalize your Internet experience by
displaying real-time weather conditions, aggregating RSS feeds, viewing maps, receiving
event reminders, providing easy access to search engines and more. The
availability of web
services, APIs and various tools makes it easy even for beginner
programmers to develop
widgets. There are many catalogs of widgets online—one
of the most all-inclusive is Widgipedia, which provides an extensive
catalog of widgets and gadgets for a variety of platforms.
Amazon Web Services
is a leading provider of web services. The site provides historical pricing data and E-Commerce Services (ECS), which
enable companies to use Amazon’s systems to sell their own products.
Amazon also offers hardware and communications infrastructure web services that
are particularly popular with companies, providing economical web-scale
computing. Amazon’s Elastic Compute Cloud (EC2), Simple Storage Service (S3) andSimple Queue Service (SQS) enable
businesses to pay for only the processing or storage space needed during
any given period. This makes it possible for companies to save money
(by not having to buy and maintain new hardware, software and communications
equipment) while still being able to scale their storage and computing
power to handle traffic surges (or reduce loss when the site’s
popularity declines). This is extremely significant in the Internet
world, where a site’s traffic can explode or crash overnight.
also provides “artificial artificial intelligence” with
its unique Mechanical
Turk. This web service allows applications to call on people
to perform tasks (such as identifying pictures) that are easier for
humans to do than computers. People can sign up to become part of the
Mechanical Turk web service and bid on jobs (called Human Intelligence
Tasks or HITs). This creates a competitive market, driving down developer
costs, creating opportunities for people worldwide and allowing more
applications to become feasible.
REST (Representational State Transfer)-Based Web
Representational State Transfer
(REST) (originally proposed in Roy Thomas Fielding’s doctoral
dissertation5) refers to an architectural style for implementing web services.
Though REST is not a standard, RESTful web services are implemented
using web standards. Each operation in a RESTful web service is easily
identified by a unique URL. So, when the server receives a request,
it immediately knows what operation to perform. Such web services can
be used in a program or directly from a web browser. In some cases,
the results of a particular operation may be cached locally by the browser.
This can make subsequent requests for the same operation faster by loading
the result directly from the browser’s cache.6 Amazon’s S3 is RESTful, and many other Web 2.0 web services
provide RESTful interfaces.7
RESTful web services are alternatives
to those implemented with SOAP (Simple Object Access Protocol).
(We discuss both REST-based and SOAP-based web services in Chapter 28,
Web Services.) With SOAP-based web services, the request
and response are hidden (in entities known as a SOAP “envelopes”).
SOAP requests must be deciphered as they are received at the server
to determine the operation to perform and the arguments required to
perform that operation. Similarly, the responses are encoded and deciphered
on the client to obtain the result of the operation. SOAP does not currently
provide a mechanism for caching results.