What is an API? Application Programming Interface

Introduction to APIs

if you work in Tech or in anything adjacent attack you’ve probably heard the abbreviation API being thrown around so let’s talk about APIs what are and why we need them’s start with what is an API.

What is an API?

API stands for application programming interface fancy words so let’s break it down.

Application

Application in this context just means any software that has a specific functionality or purpose.

Interface

interface refers to a contract or a protocol that dictates how two applications talk to each other using requests and responses.

put together an API is simply a way for different systems or applications to communicate with each other okay cool.

what is api

Why do we need APIs

Let’s start with a non-technical analogy first let’s say you have a dinner reservation for tonight for three people but you want to change it to six because some friends decided to join you at the last minute so you call the restaurant then if it’s possible to do that and the customer service person puts you on hold takes a minute but they finally come back and they say yes simple you called someone made a request and you got a response yes or no now.

Let’s say that there was no customer service person and that it was up to you to figure out how many people have made reservations for the same time at this restaurant how many tables do they have free at that time what’s their kitchen capacity what’s their weight staff capacity to figure out whether you can add three more people to your reservation that’s a lot of unnecessary work on your artwork that you the customer have expertise in and it means that the restaurant has to reveal a lot of data to you may be even private data about who’s eating there that night and who works there Etc in this analogy, the restaurant is an application that provides a specific service or function which is to feed you you are an application that is trying to get fed with a group of friends the customer service rep from the restaurant is the restaurant’s API that is the interface through which you can communicate with the restaurant and make requests like changing the number on a reservation and you can do that without having to dive into the messy detailsabout how restaurant reservations workor anything like that.

for a more technical example now think about Apple’s weather app do we think that Apple decided to set up weather-monitoring stations around the world’s a really expensive Endeavor and if it was super critical to the business model then maybe we could see that happening but there are already Services out there that meticulously collect global weather data-services like weather.com

Api examples

So ifweather.com creates an API through which anybody can access their data but only in the ways that weather.com allows the nipple could just use that API to populate their weather app so how does work let’s use the example of web apps that are the type of APIs that deliver client requests and return responses via JSON or XML usually over the internet each request and response cycle is an API call a request typically consists of a server endpoint URL and a request method usually through HTTP or hypertext transfer protocol the request method indicates the desired API action the HTTP response contains a status code a header and a response body

Api Examples with graph

the response varies depending on the request and could be the server resource a client needs to access or any application messages one status code you might be familiar with when you’ve tried to visit a website that might be down and doesn’t exist anymore is the error 404 code URL does not found and that’s it request response.

How APIs Work

How do APIs work let’s use the example of web apps which are the type of APIs that deliver client requests and return responses via JSON or XML usually over the Internet each request and response cycle is an API call a request typically consists of an server endpoint URL and a request method usually through HTTP the request method indicates the desired API action the HTTP response contains a status code a header and a response body the response body varies depending on the request and it could be the server resource a client needs to access or any application-specific messages one status code you might be familiar with when you’ve tried to visit a website that might be down or doesn’t exist anymore is the error 404 code URL not found and that’s it request response.

Types of APIs

  • RESTful APIs
  • SOAP APIs
  • GraphQL APIs

What is an API endpoint

Simply put an endpoint is one end of a communication channel when an API interacts with another system the touch points of this communication are considered endpoints for APIs an endpoint can include the URL of a server or service the place that is sent requests and where the resource lives are called an endpoint

API Authentication

if you use rest APIs then you should know these ways of authenticating them number one using the HTTP authentication scheme this has two ways of authenticating the clients with rest APIs one is basic other one is a better token basic authentication scheme uses the user’s username and password encoded with some encoding scheme like base64 and sent in the request headers better token is an encrypted string which is generated by the server in response to the client’s login request it is then sent back to the client so that client can include it in the request headers of the subsequent request to get the access number two using API Keys can be thought of as a string that is uniquely assigned by the server to every client in most of the cases servers have their API management portal where clients can log in and generate their API Keys these API keys can be sent in HTTP headers like X-API-keys by the clients to access the resources.

Comments to: What is an API? Application Programming Interface

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

Attach images - Only PNG, JPG, JPEG and GIF are supported.

Login

Welcome to SaifoPedia
Brief and amiable onboarding is the first thing a new user sees in the theme.
Join SaifoPedia