What the hell is an API ? (2024)

If you have just begun your journey into web development, you’ve probably heard and read the acronym “API” a lot. It’s short for Application Programming Interface. You hear it in the tutorials, courses, you read it in the articles but still fail to deeply understand what it really means.

Being a righteous web developer you take the trouble to google the term “API”, and Wikipedia gives you this…

An application programming interface is a computing interface exposed by a particular software program, library, operating system or internet service, to allow third parties to use the functionality of that software application.

I mean, that’s a really elegant and accurate textbook definition. But it’s a bit out of grasp for the newbie dev.

What the hell is an API? (3)

Let’s imagine a restaurant.

Restaurants provide us with food. So if you think about it, the kitchen is essentially the core service that keeps the restaurant running, the Executive Chef manages the kitchen in his/her own ways. All the fellow chefs work together to present the delicacies we demand. We go in as customers, we sit down, and we ask the waiter for a menu, we finalise the dishes and give the order. The waiter takes the order to the kitchen and within some time we have the food on our table.

The waiter here acts as an interface between the customers and the kitchen, a way that customers can communicate with the chefs. If we map this analogy to a software system…

Kitchen is the Service

Customers are the Third Parties that need the Service

The Waiter is the API

API’s are interfaces that expose a particular software system, and allow third parties to use the system without dealing with its internal complexity. It helps present a simple abstraction over a particular system. All that third parties need to care about is making appropriate requests and the API will provide them with the data they need. In a nutshell, that’s what an API is, an interface.

When we create web services, we create interfaces known as HTTP APIs, i.e they are APIs that can communicate via HTTP requests. That’s how the internet works, browsers make HTTP requests to the APIs and we get to use the required services. Google Maps, YouTube, Twitter, Instagram all these services have external APIs that developers can use to embed these services in their products. For example, Uber uses the Google Maps API to implement navigation in their apps.

APIs are not just restricted to the Web, all kinds of software systems have APIs. The Linux Kernel gives a comprehensive API which you can use to create a full operating system on top of the kernel. It usually has functionality like, allocating memory, fetching a partition etc.

Let’s have a look at the implementation.

This is how you would implement the simplest HTTP API in go

If you run this file, a server will constantly listen for requests on the specified port.

$ go run server.go
Starting server on port 3000

Here"/" is what we call an API endpoint. "/" is the default endpoint (the one that’s hit when you don’t mention any while making the request). If we had "/home" as an endpoint, we would be sending requests to http://localhost:3000/home

And then you can make requests via the browser or the terminal.

What the hell is an API? (4)

If we use the curl command to make the request via the terminal, we would have the request details with the output.

$ curl -i localhost:3000
HTTP/1.1 200 OK
Date: Wed, 18 Mar 2020 07:28:30 GMT
Content-Length: 8
Content-Type: text/plain; charset=utf-8
Hi there

So we just wrote a piece of code that is able to listen to requests and provide us with the necessary information. We built a single endpoint for simplicity sake, developers design the endpoints as per the requirement. You could for example build a flight booking service that did the heavy lifting of requesting data from multiple airlines and then sorted the data according to price, availability etc. and later expose a clean and simple API with a few endpoints so that your front-end react application just puts in source and destination in the request and can just have all the data as a response.

Real world APIs are much complicated with many endpoints, if you look up the documentation on any of the APIs you will find many endpoints that we came make HTTP requests to and get the data we need.

There exist different types of APIs, for example in web dev we have REST APIs and SOAP APIs. Sometimes we use a more hybrid approach depending on the needs of the system we are building.

I hope this cleared up your notion of what exactly is an API. It’s just an interface that helps software systems communicate

Resources and Further Reading

APIs are a vast topic, this article was meant for the beginners, you can have a look at the following links if you have an insatiable curiosity regarding the topic 👻

  1. https://en.wikipedia.org/wiki/Application_programming_interface
  2. Restful Web Services by Leonard Richardson & Sam Ruby
  3. https://www.kernel.org/doc/htmldocs/kernel-api/
  4. https://www.youtube.com/watch?v=s7wmiS2mSXY
  5. https://developers.google.com/apis-explorer
  6. https://en.wikipedia.org/wiki/Remote_procedure_call
  7. https://grpc.io/

Thanks for reading.

Do drop a 👏 if you liked this article.

What the hell is an API ? (2024)
Top Articles
Ask Us
Dividend Dynamics Based on S&P 500 Dividends Index Points
Preggophili
Shemales In Irvine
North Jersey Creiglist
SCDOR | Sales Tax
Amazing Lash Bay Colony
Waifu Fighter F95
De beste uitvaartdiensten die goede rituele diensten aanbieden voor de laatste rituelen
Ervaringen met de website van Abcstore.nl
Mywinners Wager Online
Smith And Wesson Nra Instructor Discount
Anime Feet Blogspot
855-409-4227
Word Cookies Pepper 17
O'reilly's Chillicothe Missouri
4 Pm Edt
Walkthrough - Summertime Saga Wiki
Hummul Carving Company
Is Mcdonald's Open 24/7 Near Me
Whisk Recipe Calculator
Uhaul Used Trailer Sales
Sunnyside Kaiser Pharmacy Hours
Joann Employee Pay Stub
R Guildwars2
Insidious 6 Breaks A Blumhouse Promise That Was Only Made 10 Months Ago
Walmart Tire And Lube Center Near Me
Www. Lowe's.com
Gas Station Near Santa Barbara Airport
Fredericksburg Free Lance Star Obituaries
Craigslist Com San Luis Obispo
Florida (FL) Powerball - Winning Numbers & Results
Tamilblasters.click
Giant Glimmer Fish Wow
Urban Blight Crossword Clue
Ritz Carlton San Antonio Riverwalk
Wild West Western Wear Surfside Beach Photos
Omniplex Cinema Dublin - Rathmines | Cinema Listings
Juicy Deal D-Art
About Us | Full Suite of Products, Personal Service
Netgear Outage
Miami vs Fort Lauderdale: Which is better?
Racing Champions Diecast Car Values 1997
Anthem Bcbs Otc Catalog 2022
Why rivalry match between Pitt and Penn State volleyball is bigger than the Xs and Os
The Telegram Births - March 2000
Sport Clip Hours
How Moneybagg Yo Achieved a Net Worth of $4 Million
Www Getelate.com
Menteri LHK terbitkan aturan yang larang pejuang lingkungan dipidana, akankah menghentikan kriminalisasi? - BBC News Indonesia
Ups Printing Services
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 6195

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.