DEV Community

Sospeter Mongare
Sospeter Mongare

Posted on

APIs, WHAT ARE THEY AND HOW THEY WORK

Introduction
APIs **— that is, **Application Programming Interfaces — play a bigger role in today’s economy than ever before. They allow us to share important data and expose practical business functionality between devices, applications, and individuals and although we may not notice them, APIs really are everywhere, powering our lives from behind the scenes. To help us better understand, I will share What APIs are and how they function as well as examples.

*Definition *
-An *API * can be defined as the Middle Layers that makes communication possible between these two systems
-It can also be defined as a standard way for developers to share pieces of functionality.

BENEFITS of APIs

  1. It’s meant to give developers an easy and standard way to build functionality without having to write all of their own code.

  2. APIs allows companies or developers to expose the functionalities of an app so that other apps can interact with it efficiently. Let’s say I’ve written 7 thousand lines of code to do something complex, I can expose it as an API, and you can consume my API without you having to write the code.

How APIs Work
Example 1: Waiter scenario
Waiter receives order (request) from the source (user, app, etc.), takes request to kitchen for processing. Kitchen takes order (request) and prepares food (response). Gives to the waiter which then delivers response to you. In this case, The
Waiter = API, Menu = API docs and Kitchen = Data store or server

Example 2: Language translator
You speak English, Other speaks French, you want them to understand you but instead of learning French or force them to learn English, you provide a translator English - French... the translator is the API in this case, now imagine that persons are programs.

The most common API you'll encounter is a RESTful API. It can create (POST), retrieve (GET), update (PUT), delete (DELETE) resources. A resource is a "thing", generally some data stored in a database. Like a medical record. The API lets you do all of those things to it.

One reason you'd use an API to do that, and the medical association wouldn't just give you a database password, is because they can apply logic and restrictions to what you can do to that data. So, the API will stop you from Deleting that medical record. But you can GET it.

Example of real-world APIs Implementation
-Facebook. Whatever people say about it, the fact remains it is the social networking giant in the planet and outside (if can work in mars as well). Companies can make use of data to analyze and deliver targeted ads.
-AccuWeather API gives detailed, accurate weather data for literally every location on the planet

  • MPESA Daraja API- This is the API by Safaricom PLC, a telecommunication company in Kenya that provides B2B, C2B, REVERSAL Apis used by financial institutions i.e., banks to track, verify and manage checking accounts. E-commerce sites integrates their payment using this API. Other Apis include and not limited to:
  • **Google maps, WhatsApp, pay with PayPal **and other payment gateways etc.

Final Thoughts
APIs are everywhere, they form an integral part of our daily digital lives.

Feel free to share your thoughts about the blog.

Top comments (0)