What is an API and how does it work?
Published: 2022-10-31 12:30:49

---
title: What is an API and how does it work?
published: true
date: 2022-09-28 08:00:45 UTC
tags: 
canonical_url: https://pmuhire.hashnode.dev/what-is-an-api-and-how-does-it-work
---

Software development has numerous technologies and complex concepts. API is the one that goes hand in hand with engineers during their work. This concept is something that a lot of near-technical people have heard of but dont understand its meaning.

**So whats an API?**

API stands for Application Programming Interface. An API is a software intermediary that allows two applications to talk to each other. In other words, an API is the messenger that delivers your request to the provider that youre requesting it from and then delivers the response back to you.

APIs are the little pieces of code that make it possible for digital devices, software applications, and data servers to talk with each other, and theyre the essential backbone of so many services we now rely on.

## How do APIs work?

APIs work by sharing data and information between applications, systems, and devices making it possible for these things to talk with each other.

Sometimes the easiest way to think about APIs is to think about a metaphor, and a common scenario that a lot of folks use is that of the customer, a waiter, and a restaurant kitchen: A customer talks to the waiter and tells the waiter what she wants. The waiter takes down the order and communicates it to the kitchen. The kitchen does their work, creating the food, and then the waiter delivers the order back to the customer.

In this metaphor, a customer is like a user, who tells the waiter what she wants. The waiter is like an API, receiving the customers order and translating the order into easy-to-follow instructions that the kitchen then uses to fulfill that orderoften following a specific set of codes, or input, that the kitchen easily recognizes. The kitchen is like a server that does the work of creating the order in the manner the customer wants it, hopefully! When the food is ready, the waiter picks up the order and delivers it to the customer.

## TYPES OF APIs

The most common discussion youll hear about APIs tends to focus on web technologies, but APIs arent limited to web services. Heres a roundup of common (and not so common) APIs.

### REST APIs

If youve heard people talk about **JSON (javascript object notation),** chances are theyre talking about REST APIs. Over 70% of all public APIs use REST, because of its fast performance, reliability, and ability to scale by reusing modular components without affecting the system as a whole.

### How do REST APIs work

REST, or representational state transfer, is a type of software design that gives access to data (aka web resources) by using a uniform and predefined set of operations. The payload - the data to be delivered - defined in the request itself, will be formatted in a language such as HTML, JSON, or XML. The set of operations are the methods available to **HTTP** , which is the underlying protocol for how browsers retrieve websites from servers. These methods include **GET** , **POST** , **PUT** , **DELETE** , and others.

#### There are four parts of a REST API request:

1. **URI** (uniform resource identifier, which is the URL address, also known as an endpoint)
2. **HTTP method** (most commonly either GET or POST)
3. **Headers** (which include authentication tokens, define the data format of the response, impose rate limits, and perform other administrative tasks)
4. **Body** (the actual part of the request)

## Frequently Asked Questions

1. **What is an API**

> An API serves as a data transmitter between two different pieces of software. It includes the following ;
> 
> - Type of operations users can perfom
> - Type of input data
> - Type of output data

2. **What does API stand for?**

> Application Programming Interface