Follow

Follow
What is an API?

What is an API?

Let's try to understand what an API is (pov: you're a budding software developer or just a curious person).

Harshit Budhraja's photo
Harshit Budhraja
ยทFeb 9, 2023ยท

3 min read

Play this article

Table of contents

  • Okay, but what exactly is an API? ๐Ÿค”
  • Ah, that was a bouncer for me ๐Ÿคฏ
  • Wow, I think I get it. But what do they look like? ๐Ÿ˜
  • Final Notes (for now) ๐Ÿ“

Before we get into this, if you're new here or don't know me - I'm Harshit, and I'm a Software Engineer currently working at Postman (postman.com), an API Development Platform.

This is a new series that I've started - Demystifying APIs, and it aims to promote API Literacy in the tech community. Feel free to ask me any questions around APIs in the comments below or by tweeting to me (twitter.com/harshitbudhraja) - I'll be happy to answer each one of those.

Also, don't forget to subscribe to my newsletter, so that you don't miss any of the further posts in this series.

Well, nothing fancy here. Let me start by telling you that most (actually, ALL) modern software use APIs in one way or the other.

Okay, but what exactly is an API? ๐Ÿค”

API stands for Application Programming Interface. Don't stress too much over it (just remember it for your interviews though ๐Ÿ˜›).

Breaking it down for you:

  1. Application - This could be anything from a mobile app, web app, or desktop app to apps that run on your smartwatch to even browser extensions.

  2. Programming - To make them (i.e. the apps) work according to your requirements.

  3. Interface - Any tool/library/software/hardware that helps you complete your task (in this case, helps you program your apps).

Ah, that was a bouncer for me ๐Ÿคฏ

Haha, no big deal. Let's understand it using a simple example:

Your smartphone shows you weather updates, right? Do you think companies like Oppo, Vivo, Xiaomi, Micromax or Samsung own satellites that relay this information to them for them to deliver it to you on that home screen? Well, they don't.

Then, where do they get these weather updates from?

The answer to this question is simple - from organizations that have satellites and specialize in meteorology.

But how?

Here's a little diagram to understand how this communication takes place:

Satellites owned by meteorological organizations relay the weather data to them, who in turn relay this to the requesting companies - like Samsung, and they further make this data available to their users on their smartphones.

But, where do APIs come into the picture?

Simply putting, everywhere you see blue arrows in the above diagram :p

Wow, I think I get it. But what do they look like? ๐Ÿ˜

Beautiful ๐Ÿฅฐ

Just kidding (well, not really).

Okay, so there are many different types of APIs: SOAP APIs, RPC APIs, REST APIs, Websocket APIs etc. of which REST APIs are the most commonly used ones. You'll find them almost everywhere. They generally use a universally recognized data interchange format/language like JSON (Javascript Object Notation) or XML (Extensible Markup Language) which are typically both machine-readable and human-readable to exchange data.

For example, if you'd like to see a real-world weather API, you can check this out: https://open-meteo.com/en/docs. Whenever anyone requests weather data from them, they return a response that looks something like this:

{
  "latitude": 52.52,
  "longitude": 13.419,
  "elevation": 44.812,
  "generationtime_ms": 2.2119,
  "utc_offset_seconds": 0,
  "timezone": "Europe/Berlin",
  "timezone_abbreviation": "CEST",
  "hourly": {
    "time": ["2022-07-01T00:00", "2022-07-01T01:00", "2022-07-01T02:00", ...],
    "temperature_2m": [13, 12.7, 12.7, 12.5, 12.5, 12.8, 13, 12.9, 13.3, ...]
  },
  "hourly_units": {
    "temperature_2m": "ยฐC"
  },
  "current_weather": {
    "time": "2022-07-01T09:00",
    "temperature": 13.3,
    "weathercode": 3,
    "windspeed": 10.3,
    "winddirection": 262
  }
}

This, by the way, is the JSON format.

Final Notes (for now) ๐Ÿ“

Don't worry if you don't understand a word in that ๐Ÿ˜… We'll take this slow and step-by-step. And by the end of this series, you would have a fair understanding of everything you need to know about APIs.

With that, I hope you have an idea of what APIs are ๐Ÿคž๐Ÿป In the upcoming posts in this series, we'd be talking more about APIs and their types in detail.

Cheers!

Did you find this article valuable?

Support Harshit Budhraja by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
ย 
Share this