About API

About API

Introduction

API is around everywhere, from booking a ticket, Twitter bots, weather snippets google maps, etc. are done using API only. API acts as a messenger between the two systems or applications.

API stands for 'Application Programming Interface'. API is generally a program or software using these two systems or software that can interact with each other. It acts as a bridge between the software and devices. Just like in a restaurant, the waiter takes an order from the customer and delivers it to the chef, takes the response(taking a meal) from the chef and lastly delivers it to the customer. API also works similarly, whenever a user or one software makes a request, it passes to the API which acts as a waiter and takes our responsibility to the server or the other software and comes back with the status of the request.

Every online software has frontend and backend both of which are developed using different programming languages and frameworks. APIs are developed to help these two communicate and work in conjunction.

What Is an API? How APIs Improve Application Development

Types of API

Generally, two types of API are in use today.

  • SOAP API

    SOAP stands for Simple Object Access Protocol.

    It transports data in standard XML format.

    It is a platform-independent protocol.

    It is an open standard protocol so anyone can use it.

    It is by default stateless, but it is possible to make this API stateful.

    It requires more bandwidth and computing power.

  • REST API

    REST stands for Representational State Transfer.

    It is stateful, i.e. no server-side sessions occur.

    It is data-driven, meaning that data is available as resources.

    Requires more coding compared to SOAP.

    It is fast and light.

    It supports HTTPS and SSL (Secure Sockets Layer).

    SOAP vs. REST: A Look at Two Different API Styles | Upwork

API consists of

  1. Method: An API method defines the kind of method request and method response. Some of the methods are GET, POST, PATCH, PUT, and DELETE.

  2. Endpoint: It is one end of a communication channel. When an API interacts with another system, the touchpoints of this communication are considered endpoints. For APIs, an endpoint can include a URL of a server or service. Each endpoint is the location from which APIs can access the resources they need to carry out their function.

  3. Header: The job of the header section in API is to represent the metadata associated with the request and response.

  4. Body: It contains contents or data. The request body contains data sent by the client to API. A response body is the data sent by API to the client.

  5. Parameters: Parameters are the options that can be passed with the endpoint to influence the response.

  6. Status Code: Status and error codes refer to a code number in the response header that indicates the general classification of the response — for example, whether the request was successful (200), resulted in a server error (500), had authorization issues (403), and so on.

API Security

API security is the practice of preventing threats or attacks to API. API is responsible for the communications of data between the two software, hence it is important to protect the sensitive data they transfer.

  • Always use HTTPS as it comes with SSL security.

  • Always hash all passwords.

  • Never expose your API key on the URL.

  • Always add timestamps and parameter validations.