Application Programming Interface (API)

Swathi
3 min readApr 27, 2021

What is an API?

Application Programming Interface also known as API, is defined as a specification of possible interaction with software components. In simple words, API is a software connector between two applications to communicate each other using a set of rules. It’s a software-to-software interface, not an user interface.

For example, to make a fresh glass of watermelon juice, you simply add watermelon chunks into the blender and turn it on. Here the blender (acts as an API) doesn’t have to explain what happens inside the motor when you turn it on.

Let’s see another example, we use WhatsApp to send messages to our friends and family. If you want to share your location in WhatsApp, then you simply select the share location and send. But behind the scene, WhatsApp gets the request from Google maps API and shares the location. Here, WhatsApp is integrated with Google Maps to share location. This shows, with the help of API’s, application can talk to each other without any user knowledge or intervention.

API PRINCIPLES:

Even though, your API connects to the third-party application. It cannot access all the data from the database. Security is enhanced when sites use APIs. Whenever you send a request, you aren’t directly linked to a server. You send small amounts of information, the API delivers it, and the server sends it back. This minimizes the risk of a breach or someone accessing the backend of a server.

Types of API Protocols:

  • REST
  • SOAP
  • JavaScript
  • XML and RCP

Most commonly used API protocols are REST (Representational State Transfer) and SOAP (Simple Object Access Protocol).

REST is basically an architectural style of the web service, which request from the client to the server.In RESTful APIs, communication between applications is done using HTTP protocol (HyperText Transfer Protocol). HTTP is widely used on the internet.In fact, this is the reason why all web address start with either HTTP or HTTPS. The simplest HTTP request you can actually make is simply opening any website in your browser, which would send a HTTP request to that address. This means that opening up a web page is just the most public facing version of making a HTTP request. However, RESTful APIs can also use the protocol to interact with Program Interfaces.

There are five major HTTP request methods:

  • GET — Read from Database
  • PUT — Update/replace row in Database
  • PATCH-Update/modify row in the Database
  • POST — Create a new record in the Database
  • DELETE — Delete from the Database

For example, if you want to search for a person in the Facebook. Then you send HTTP request and wait for the response. In the HTTP request, it is specified which function of the API the application would like to use (return profile information). Here using the GET method, it fetches the data and the Facebook server will process the given request. REST APIs uses multiple standards like HTTP, JSON, URL, and XML

SOAP or Simple Object Access Protocol is a standard communication protocol system that permits processes using different operating systems like Linux and Windows to communicate via HTTP and its XML.It provides a reliable and trusted way to send and receive messages between systems (and within enterprise applications).

SOAP provides four distinct dimensions to the API protocol:

  • Envelope: Defining the structure of the message.
  • Encoding: Rules for expressing the type of data.
  • Requests: How each SOAP API request is structured.
  • Responses: How each SOAP API response is structured.

SOAP uses XML as the data format for messages being sent and received by an API client.XML (or Extensible Markup Language) is a text format that establishes a set of rules to structure messages as both human- and machine-readable records.

Originally published at https://www.numpyninja.com on April 27, 2021.

--

--