Understanding How API Works

Understanding How API Works

ยท

3 min read

Meaning of an API

An API is an acronym for Application Programming Interface. It is a software intermediary that allows two applications to communicate with themselves. It is a set of functions that allows applications to access data and interact with external software components, operating systems, or micro services. In simple terms, an API allows users to update, create, collect and delete data from a server. An API makes use of endpoints to communicate with the user. There are different types of API but the most common one is the Representational state transfer (REST) API.

REST API

A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services.

How an API works

An API listens to your requests and comes back with a response. For instance, you enter a bookshop and you need a particular book. You tell the bookstore owner the title of the book you need and he goes into the store and brings the book for you. Likewise when you bring or donate a book to the bookstore. The bookstore owner collects the book from you and places it on a shelf in the bookstore. The bookstore owner in this case is the API. An API uses endpoints to communicate with both ends.

What is an API endpoint?

An endpoint is the URL for a server or a service. It is simply one end of the communication channel between the server and user.

Making an API request

An API has four basic request methods: the GET method, the POST method, the PUT method, and the DELETE method.

The GET method

The GET method is used to collect information from a user. The GET method receives a request from a user and collects the requested information from the server and returns the response to the user.

The PUT method

The PUT method allows a user to update a certain piece of information that is already on the server. It is used to modify the data already on the server.

The POST method

The POST method is used to create a new data on the server. It accepts data in the body of the request that is to be stored in the server. It is used when uploading a data to the server.

The DELETE method

The DELETE method is used to delete information from a server. It is used to delete a specified data from the server.

Scenarios of API usage

  • Weather apps make use of weather APIs to relay weather forecast.
  • Banks make use of an API to retrieve customer information.
  • Schools make use of API to handle students' information.

A little tip:

The best way to understand how an API works is to play around with it.

Resources

Google ๐Ÿ˜

Api Vectors by Vecteezy