API
Application Programming Interface, which is a software intermediary that allows two
applications to talk to each other
When you use an application on your mobile phone, the application connects to the
Internet and sends data to a server. The server then retrieves that data, interprets it,
performs the necessary actions and sends it back to your phone. The application
then interprets that data and presents you with the information you wanted in a
readable way. This is what an API is - all of this happens via API.
To explain this better, let us take a familiar example.
Imagine you’re sitting at a table in a restaurant with a menu of choices to order from.
The kitchen is the part of the “system” that will prepare your order. What is missing is
the critical link to communicate your order to the kitchen and deliver your food back
to your table. That’s where the waiter or API comes in. The waiter is the messenger
– or API – that takes your request or order and tells the kitchen – the system – what
to do. Then the waiter delivers the response back to you; in this case, it is the food.
Here is a real-life API example. You may be familiar with the process of searching
flights online. Just like the restaurant, you have a variety of options to choose from,
including different cities, departure and return dates, and more. Let us imagine that
you’re booking you are flight on an airline website. You choose a departure city and
date, a return city and date, cabin class, as well as other variables. In order to book
your flight, you interact with the airline’s website to access their database and see if
any seats are available on those dates and what the costs might be.
However, what if you are not using the airline’s website––a channel that has direct
access to the information? What if you are using an online travel service, such as
Kayak or Expedia, which aggregates information from a number of airline
databases?
The travel service, in this case, interacts with the airline’s API. The API is the
interface that, like your helpful waiter, can be asked by that online travel service to
get information from the airline’s database to book seats, baggage options, etc. The
API then takes the airline’s response to your request and delivers it right back to the
online travel service, which then shows you the most updated, relevant information.
Your phone’s data is never fully exposed to the server, and likewise the server is
never fully exposed to your phone. Instead, each communicates with small packets
of data, sharing only that which is necessary—like ordering takeout. You tell the
restaurant what you would like to eat, they tell you what they need in return and then,
in the end, you get your meal.
APIs have become so valuable that they comprise a large part of many business’
revenue. Major companies like Google, eBay, [Link], Amazon, and
Expedia are just a few of the companies that make money from their APIs. What the
“API economy” refers to is this marketplace of APIs.
enabling applications to exchange data and
functionality easily and securely.
An application programming interface, or API, enables companies to open up their
applications’ data and functionality to external third-party developers, business partners,
and internal departments within their companies. This allows services and products to
communicate with each other and leverage each other’s data and functionality through
a documented interface. Developers don't need to know how an API is implemented;
they simply use the interface to communicate with other products and services. API
use has surged over the past decade, to the degree that many of the most popular web
applications today would not be possible without APIs.
How an API works
An API is a set of defined rules that explain how computers or applications
communicate with one another. APIs sit between an application and the web server,
acting as an intermediary layer that processes data transfer between systems.
Here’s how an API works:
1. A client application initiates an API call to retrieve information—also known
as a request. This request is processed from an application to the web server
via the API’s Uniform Resource Identifier (URI) and includes a request verb,
headers, and sometimes, a request body.
2. After receiving a valid request, the API makes a call to the external program
or web server.
3. The server sends a response to the API with the requested information.
4. The API transfers the data to the initial requesting application.
While the data transfer will differ depending on the web service being used, this process
of requests and response all happens through an API. Whereas a user interface is
designed for use by humans, APIs are designed for use by a computer or application.
Why we need APIs
Whether you’re managing existing tools or designing new ones, you can use
an application programming interface to simplify the process. Some of the main benefits
of APIs include the following:
Improved collaboration: The average enterprise uses almost 1,200 cloud
applications (link resides outside of IBM), many of which are disconnected.
APIs enable integration so that these platforms and apps can seamlessly
communicate with one another. Through this integration, companies can
automate workflows and improve workplace collaboration. Without APIs, many
enterprises would lack connectivity and would suffer from informational silos
that compromise productivity and performance.
Easier innovation: APIs offer flexibility, allowing companies to make
connections with new business partners, offer new services to their existing
market, and, ultimately, access new markets that can generate massive returns
and drive digital transformation. For example, the company Stripe began as an
API with just seven lines of code. The company has since partnered with many
of the biggest enterprises in the world, diversified to offer loans and corporate
cards, and was recently valued at USD 36 billion (link resides outside of IBM).
Data monetization: Many companies choose to offer APIs for free, at least
initially, so that they can build an audience of developers around their brand
and forge relationships with potential business partners. However, if the API
grants access to valuable digital assets, you can monetize it by selling access
(this is referred to as the API economy). When AccuWeather (link resides
outside of IBM) launched its self-service developer portal to sell a wide range of
API packages, it took just 10 months to attract 24,000 developers, selling
11,000 API keys and building a thriving community in the process.
Added security: As noted above, APIs create an added layer of protection
between your data and a server. Developers can further strengthen API security
by using tokens, signatures, and Transport Layer Security (TLS) encryption; by
implementing API gateways to manage and authenticate traffic; and by
practicing effective API management.
Common API examples
Because APIs allow companies to open up access to their resources while maintaining
security and control, they have become a valuable aspect of modern business. Here are
some popular examples of application programming interfaces you may encounter:
Universal logins: A popular API example is the function that enables people to
log in to websites by using their Facebook, Twitter, or Google profile login
details. This convenient feature allows any website to leverage an API from one
of the more popular services to quickly authenticate the user, saving them the
time and hassle of setting up a new profile for every website service or new
membership.
Third-party payment processing: For example, the now-ubiquitous "Pay with
PayPal" function you see on ecommerce websites works through an API. This
allows people to pay for products online without exposing any sensitive data or
granting access to unauthorized individuals.
Travel booking comparisons: Travel booking sites aggregate thousands of
flights, showcasing the cheapest options for every date and destination. This
service is made possible through APIs that provide application users with
access to the latest information about availability from hotels and airlines. With
an autonomous exchange of data and requests, APIs dramatically reduce the
time and effort involved in checking for available flights or accommodation.
Google Maps: One of the most common examples of a good API is
the Google Maps service. In addition to the core APIs that display static or
interactive maps, the app utilizes other APIs and features to provide users with
directions or points of interest. Through geolocation and multiple data layers,
you can communicate with the Maps API when plotting travel routes or tracking
items on the move, such as a delivery vehicle.
Twitter: Each Tweet contains descriptive core attributes, including an author, a
unique ID, a message, a timestamp when it was posted, and geolocation
metadata. Twitter makes public Tweets and replies available to developers and
allows developers to post Tweets via the company's API.
Types of APIs
Nowadays, most application programming interfaces are web APIs that expose an
application's data and functionality over the internet. Here are the four main types
of web API:
Open APIs are open source application programming interfaces you can
access with the HTTP protocol. Also known as public APIs, they have defined
API endpoints and request and response formats.
Partner APIs are application programming interfaces exposed to or by strategic
business partners. Typically, developers can access these APIs in self-service
mode through a public API developer portal. Still, they will need to complete an
onboarding process and get login credentials to access partner APIs.
Internal APIs are application programming interfaces that remain hidden from
external users. These private APIs aren't available for users outside of the
company and are instead intended to improve productivity and communication
across different internal development teams.
Composite APIs combine multiple data or service APIs. These services allow
developers to access several endpoints in a single call. Composite APIs are
useful in microservices architecture where performing a single task may require
information from several sources.
Types of API protocols
As the use of web APIs has increased, certain protocols have been developed to
provide users with a set of defined rules that specifies the accepted data types and
commands. In effect, these API protocols facilitate standardized information exchange:
SOAP (Simple Object Access Protocol) is an API protocol built with XML,
enabling users to send and receive data through SMTP and HTTP. With SOAP
APIs, it is easier to share information between apps or software
components that are running in different environments or written in different
languages.
XML-RPC is a protocol that relies on a specific format of XML to transfer data,
whereas SOAP uses a proprietary XML format. XML-RPC is older than SOAP,
but much simpler, and relatively lightweight in that it uses minimum bandwidth.
JSON-RPC is a protocol similar to XML-RPC, as they are both remote
procedure calls (RPCs), but this one uses JSON instead of XML format to
transfer data. Both protocols are simple. While calls may contain multiple
parameters, they only expect one result.
REST (Representational State Transfer) is a set of web API architecture
principles, which means there are no official standards (unlike those with a
protocol). To be a REST API (also known as a RESTful API), the interface must
adhere to certain architectural constraints. It’s possible to build RESTful APIs
with SOAP protocols, but the two standards are usually viewed as competing
specifications.
SOAP stands for Simple Object Access Protocol
REST, short for Representational State Transfer,
API documentation is only useful when an API consumers can access
your docs, and obtain the necessary information for working with the
API