Sign in
Log inSign up
APIs the first step

APIs the first step

Ebuka Achonwa's photo
Ebuka Achonwa
·May 12, 2020·

6 min read

Every developer and most non-developers have used an application that interacts with (APIs) at least once every 7days. The reason being that 70% of applications we use get pieces of information from APIs to bring us what we need to see at a given period of time. So in this series, we are going to build a weather App and a Newsletter app that will make use of various APIs but first, let talk about API.

Table of contents

  1. Introduction to APIs
  2. How APIs works
  3. Conclusion
  4. Resources

Introduction to APIs

What is API? Application Programming Interface (API) is a set of commands, functions, protocols, and objects that programmers can use to create software or interact with an external system. Ok, the definition has a lot of words in it, let break words down.

If you take a closer look at your smartphone, tablet, or computer at the weather section you will notice it changes the current weather of the city you are in automatically every day if not every few hours once you are connected to the internet, constantly updating you with the latest weather forecast.

weather on phone.jpeg
Now how did they do that and how could we build something like this, is it that they go around the world every day and collect wind speed, temperature all weather information, and update? NO. They use weather data service like Openweathermap where their job is to collect all weather data and do the complicated things, all we have to do is to use their API to tap into the live weather data and we will be able to get all update of weather condition as shown in the image above.

How API works

Now to tap into there life sever and use their API, what does that even mean? let us illustration it with a restaurant, you go to a restaurant first they will offer you a menu to see the things they are serving and secondly, you might want to go inside the kitchen by yourself to dish out what you want to eat. newimagemenu.jpegRestaurant Menu

kitch.jpgRestaurant Kitchen

No one needs to tell you that not all restaurants will be happy about that. This simply means that there are somethings they offer to people and there are some things that are off-limit, So the best way to get something in a restaurant is from there menu as indicated in the above image but for a service like weather API, the menu looks something like the image below.

newimagemenu.jpegWeather API Menu

In API some people will consider it to be a contract, it will be a contract between a data provider and Company or developer ready to use the providers API. The contract will have somethings the developers will access, the methods objects protocols that they will use to access them, and things they cant access, then the data provider will try to not change any of these methods without notifying the developer.

So if you have used Tinder or Instagram and signed in with your Facebook account, is one of the apps that also show API interaction, because Tinder has access to Facebook API they can easily pull data(users) you have or know from Facebook as shared friends or shared interests on your Tinder. this is using Facebook API to interact with external system and is the Facebook database e.g

tinder.jpgAPIs Interacting with an external server

The action that triggered the shared friends and shared interests in the Tinder image is simply a request from tinder application to Facebook API and a response from the Facebook Database.

WhatsApp Image 2020-05-11 at 20.38.02.jpeg Request and Response via an API

Conclusion

The significance of understanding what is API and how it works cannot be overemphasized and I hope this tutorial was helpful enough to encourage the need to study the API further, in the future blog we will learn API in a more fun way and build some amazing app that will make use of APIs.

Resouces

This article only covers how the elementary part of API so I curated a list of useful resources to help you learn more about the API.