avatarGerald Nguyen

Summary

APIs, or Application Programming Interfaces, serve as the intermediaries that allow different software components to communicate, analogous to a kitchen's menu in a restaurant, providing a list of available services and data that can be accessed by front-end applications or directly by users.

Abstract

The web content explains APIs using a non-technical restaurant analogy where APIs are likened to a kitchen's offering of dishes. In this context, the front-end is the waitstaff that interacts with customers, providing a user-friendly interface, while the back-end, or the kitchen, is where APIs reside. These APIs define how other components can interact with the back-end services, such as retrieving a list of available dishes or submitting an order. The article emphasizes that APIs are not limited to being accessed by front-end applications; they can also be directly called by users or external systems. The analogy extends to illustrate how APIs can function without a traditional front-end, similar to customers ordering directly from a menu. The content also clarifies that APIs are not just limited to local software components but can be services accessible over a network or the internet, facilitating interactions with popular websites that may involve numerous API calls to distant servers. The article concludes by emphasizing the ubiquity of APIs, noting their role in providing data or services to external entities, and suggesting that this concept extends beyond software to encompass any goods or services offered by one entity to another.

Opinions

  • APIs are compared to a kitchen's menu, offering a clear and structured way for front-end components or users to understand what services and data are available.
  • The front-end is responsible for providing a pleasant user experience, akin to a waiter's role in a restaurant, while APIs in the back-end handle the fulfillment of requests.
  • The article posits that APIs can be simple to interact with, even when there is no front-end interface, by directly calling the API endpoints.
  • The author suggests that modern APIs often involve remote interactions over the internet, distinguishing them from traditional local software libraries or modules.
  • APIs are described as more than just service providers; they also return valuable data, enriching the user experience with dynamic content such as social media feeds or video streams.
  • The author's perspective implies that the concept of APIs is universal and not confined to the digital world, as it represents the exchange of goods or services between entities.

What Are APIs?

A non-technical explanation of APIs and where they belong

Are APIs the waiters?

Source: Reddit and LinkedIn

No — The waiters are part of Frontend.

They are responsible for creating a nice visual and interactive experience such as greeting customers, arranging the tables, present the dishes — like what React or Angular codes do.

They will take your orders — like how HTML forms accept your inputs, auto-complete your sentences, or apologize that certain dishes aren’t available.

And they send your orders to the kitchen. Like what Fetch API or Axios library does to invoke APIs in the Backend.

APIs belong in the Backend

With the Kitchen being Backend, APIs are the kitchen’s offering of available dishes to waiters and customers. For example, the API GET /kitchen/dishes tells its consumers what they can order today, the GET /kitchen/dishes/hawaian-pizza returns a detailed description of that delicious food, or POST /kitchen/tables/123/orders accepts a new order.

Fulfillment of API requests is of course completed in the Kitchen. The chef determines the menu, set out the recipe for each dish, and cooks all customer orders.

There may not be a Frontend

Photo by Anthony Fomin on Unsplash

It’ll be you calling the API directly. Fret not, it is simple.

If you are one of the queuing customers in the above photo, I’m sure you know how to order. Just browse the menu, look at the pictures (and their prices), then says the name of your favorite ice cream or point to it.

It’s mostly the same with APIs. You call GET /ice-creams/ to learn what is available, then GET /ice-creams/chocolate-special to check out its picture, price, sizes…, and finally POST /orders/ to request your well-deserved treats.

What are APIs?

API stands for Application Programming Interface. It refers to how software components should publicly appear to each other. When one component needs another to do some specific work, it calls a specific service defined in the other component’s API. In our restaurant example above, when a Waiter needs the Kitchen to cook an Order, the Waiter calls the cook(Order) service defined in the Kitchen’s API.

API originally applies to software codes or libraries that are packaged with the invoker in a single .exe file or deployed to a program folder. It still does.

But API nowadays also applies to software separated over a network or even the internet. When we open any of the popular websites such as Facebook, Youtube, The Guardian, etc…, chances are there are dozen, even hundreds of API calls made to servers hundreds of miles or even halfway across the globe every minute. At such distance, these software are no longer called libraries or modules like their former cousin but take the name services or APIs themselves.

API does more than perform a service. It can also return data. Facebook APIs do not just log you in, it returns dozen of posts from your friends and relatives to fill up your feed. Youtube APIs don’t just help you like a video, it returns the frames that make up the video itself.

In conclusion:

APIs are the data or services that some software codes, modules, libraries, or websites have to offer to outsiders

If we are to go beyond the realm of software, APIs are the goods or services that someone or something has to offer to outsiders. APIs are thus everywhere. Does this competitor to Amazon have a chance?

Photo by HamZa NOUASRIA on Unsplash

Extra: https://geraldnguyen.medium.com/list/api-development-interview-a17c1f9ee5b7: My articles related to API development and interview

If you like this article, please follow me for more quality content.

Thank you.

Technology
API
Frontend
Backend
Illumination
Recommended from ReadMedium