Introduction

Everything is online nowadays. From grocery website to online medical services, we can do anything and everything right from our home with the help of any electronic device such as laptop, PC or mobile. Have you ever wondered that how the App or the website you visit understands you and processes your payment. This all happens with the help of different APIs. In this article, we will learn all about APIs. All the OData servies are also an example of APIs.

What is an API

An API stands for Application Programming Interface. As the name suggest, an API is an interface between two applications. These are the programs written in such a way that they accept certain inputs, process them and returns an output.

E.g. We can create an API which can accept two numbers and return their sum. It sounds crazy to do such basic job, but it is just an example.

How APIs Works

To better understand this flow, we will illustrate the same using step by step process, as shown below:

How API Works

The API is triggered by a script code in UI, in our case UI5/FIORI App. The call is in the form of either of any CRUD operation. In case of Read calls, the returning response consist of JSON data. In case of Create, Update and Delete operations, the response is just a status where 200/201 represents success. We will study more about API Response codes in upcoming article.

An API is in the form of a URL i.e. Uniform Resource Locator.

Example: https://service_name/payload

An API contains the following:

  • HTTP Request: It defines which CRUD operation is being called. E.g. GET is for Read call and POST is for Create call
  • Service Name: It can be your website name or any other registered service name. In case of OData it varies with the OData name.
  • Payload: In case of Create, Update and Delete call, payload is an object sent to the API
  • Response: This is a status with response data. The status represents if the API call was successful or not.

Example:

In real world, we can take an example that the API accepts Credit Card details with an amount to deduct, process deduction and returns success status. These types of APIs are widely used by payment gateway industries. The same is illustrated in the GIF below:

APIs

Advantages of an APIs

  • It helps in abstraction of Data between two systems
  • It reduces the duplication of code and architecture and enhances modularity
  • It reduces the coding language dependency as any two systems using different coding languages can be connected via an API
  • It reduces rework and enhances code quality as well as readability

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Translate »