An Application Programming Interface (API) is a computer-readable set of programming instructions, used to access a Web-based application. Software companies release their APIs to the public so that other developers can create products based on their code, while others allow you to integrate with their systems.
For example, Amazon and Facebook have released their APIs so that other developers can plug into their systems. Amazon's API gives third-party websites easier access to their product database, allowing them to showcase products with "Buy Now" links and up-to-date prices.
Web services are a group of protocols that applications use to communicate over the Internet. HTML and XML are two programming languages used in Web services.
API calls are transported between applications using these Web services.
While APIs are great for automation, they can't do everything by themselves. You will still need to construct the URL for each API call.
Twitter is one of the large companies that has released its API library to the public. One of the simplest API calls is the GET users/show function. This function returns all the available information about a specific Twitter user.
Let's break that URL down into its components so that we can understand each step:
|http://api.twitter.com/1||Version 1 of the Twitter API|
|users||Specify the 'users' section of the API.|
|show.xml||display the output as XML.|
|screen_name=angelameadon||The user you want information about (angelameadon).|
Because APIs allow access to a system, software companies take security very seriously. There are various authentication options, but they are beyond the scope of this article.
An important facet of API authentication is the API key. The API key is a secret token which is passed with the API calls to identify the origin of the request. This key may seem like a string of random characters to you or me, but it is constructed in a specific way. The receiving system will recognise the construction, if it is valid, and process the request passed with the key.
An API key used with Basic Authentication might look something like this:
An API endpoint defines the address of the web service. It is represented by an HTTP URL string.
Everlytic has two endpoints available: REST, and XML-RPC.
REST (or Representational state transfer) is an architectural style that simplifies the design of Web Services. It's based on the concept that everything is a resource, and that each resource can be identified by and accessed at a uniform resource identifier (URI). Using this URI, the resource can be acted upon using various HTTP methods. Typically, the methods are mapped to actions taken on the resource.
XML-RPC is a protocol specification which defines how Remote Procedure Calls can be made by sending XML to a Web Service using the HTTP protocol. The definitions for the different calls can be found by navigating to the different requests. Each call has its unique structure which needs to be followed.
With XML-RPC, the programmer will use an external library to connect to the API, so any implementation details will be based on the library they choose to use.
POST /api/2.0/xmlrpc/ HTTP/1.1
<member><name>email@example.com</name><value><string>Test from name</string></value></member>
<member><name>firstname.lastname@example.org</name><value><string>Test to name</string></value></member>
<member><name>html</name><value><string>Email Body Here</string></value></member>
<member><name>text</name><value><string>Please view in a html compatible viewer</string></value></member>
Requests are the individual API instructions that you use to integrate with a web service. Each API will have different requests, depending on which functions the developers choose to allow external users access to.
There are many different ways that you can use an API, depending on the application or website you are connecting to.
The Facebook Social Plugins are a range of tools which allow you to share your experiences off of Facebook with your contacts on Facebook.
Many news and blog sites have 'Like' and 'Share' buttons on their content which allow you to connect with and post content to your Facebook profile. This is done using API calls.
These plugins appear on other websites, but the information comes directly from Facebook.
The Google Maps API lets you combine Maps data with your own data. You can use this for reports, directions, or with Street View.