What is a Web API?

According to Wikipedia, an application programming interface (API) is a specification intended to be used as an interface by software components to communicate with each other. A web API, or a Web service, is typically a set of defined HTTP requests and responses.

For example, the URL below returns the Whois information for facebook.com in XML format using EnClout Whois API.

http://www.enclout.com/whois/show.xml?auth_token=JPbbCaVFYdnpm2xY9aq1&url=facebook.com

A web API typically consists of the following parts:

  1. URL, this is the URL to invoke the API
  2. Authentication, this is how the caller identifies itself to the API.
    In many cases, the authentication is done by specifying a token parameter in the URL.
  3. Input(s).
  4. Output, typically expressed in JSON or XML format.
    In many cases, caller can specify the output formats by calling the appropriate URLs.
NOTE: Web APIs are usually capped to avoid abuse.