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
6 Things To Do If You Lose Your Wallet | Bankrate
How to plan a dream trip on a budget: 7 tips ‹ EF GO Blog | EF Global Site (English)
Netr Aerial Viewer
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Roblox Developers’ Journal
Self-guided tour (for students) – Teaching & Learning Support
Doby's Funeral Home Obituaries
Select Truck Greensboro
Colts Snap Counts
How To Cut Eelgrass Grounded
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Saritaprivate
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Walmart Pharmacy Near Me Open
Dmv In Anoka
Umn Biology
Obituaries, 2001 | El Paso County, TXGenWeb
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Colin Donnell Lpsg
One Credit Songs On Touchtunes 2022
Weekly Math Review Q4 3
Iban's staff
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Raising Canes Franchise Cost
Busch Gardens Wait Times
Skip The Games Grand Rapids Mi
Verizon Outage Cuyahoga Falls Ohio
Electric Toothbrush Feature Crossword
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Marcal Paper Products - Nassau Paper Company Ltd. -
Holzer Athena Portal
Hampton In And Suites Near Me
Costco The Dalles Or
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Marion City Wide Garage Sale 2023
Used Curio Cabinets For Sale Near Me
San Pedro Sula To Miami Google Flights
What Responsibilities Are Listed In Duties 2 3 And 4
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.