Application Programming Interface: A P I in Bits

5 min read
Cover Image for Application Programming Interface: A P I in Bits

Oftentimes, you hear different terms from developers and those in the tech space. These terms may seem ambiguous when you barely understand them and shyness may not allow you to ask questions even after trying to do research. It's fine not to understand things especially when they're new to you but don't worry, you'll get to know and understand better after reading this piece.

This article is for beginners and indeed everyone who wants a grasp of what API is all about. I'm sure of clearing your doubts while ensuring that confusion is eradicated.

API for Beginners

When you go to a store down the street, the seller ensures you get what you want to buy. S/he becomes the connector between you and what you wish to buy. In like manner, an API is a connector between applications or computers.

Oh my bad!

API stands for Application Programming Interface. Now, let's understand how these words work together

  • Application- In this context, an application is a type of computer software for carrying out specific tasks. It could be mobile, desktop or Web. Applications could range from your music player to your weather checker and the likes. Each of these applications have been programmed i.e instructed with some lines of codes to do a specific task for you the user.
  • Programming- Programming is the process of writing instructions known as codes for a computer to work with. In other words it is the set of rules (written in a language that the computer understands)telling the computer what to do and how to do it. Applications are developed using programming languages.
  • Interface - Having programmed your application, it begins to work based on what you defined it to do. Now, interacting with other applications, computers or even server requires more than what you have done on your own side. Hence, your application needs to communicate with the outside world to get data, post data and do other operations. This is where the need for an interface comes in.

APIs are created with respect to the platform involved i.e web or mobile. For mobile, there are APIs for Android and iOS respectively. Each Operating system provides its APIs that developers can work with.

What is an API used for?

An API provides the needed communication within applications, databases, computers etc. In one sentence, it is the intermediary between a client and a server which could be computers or software. As a developer, it saves you the stress and time of hardcoding every functionality of your application. Rather you get the desired API and tweak it to your choice.

Classes of API

  • Private APIs: A private API is an API that is visible only to the developer or specifically designed for a company's use alone. It simply means that access to such APIs remains within the company. External use would require a certain key or gateway given by the company to the intended user.

  • Public APIs: Public APIs are free APIs made available for general use. Like an open source, it is accessible and can be consumed into your application. These kinds of APIs can be found on GitHub and the likes with a "read me" text file on how to use it in your application.

The major difference between the public and private APIs is that one is free and easily accessible while the other isn't, in some cases payments are made to access private APIs.

Types of API

There are various types of APIs but for this article, we would talk about the commonly used ones.

  • REST API: This is an API based on Representational State Transfer (REST) architecture which is often used in web development services. In its simplest form, a REST API receives request from the client, sends it to the server and returns the required response back to the client in an understandable format i.e Java Script Object Notation(JSON) or Extensible Markup Language(XML).

REST API is known for being:

  • Stateless
  • Cacheable
  • Simple

REST APIs executes the following requests :

  • Get: for accessing data from the server.
  • Post: In this operation, you are sending data is being sent to the server.
  • Put: This operation involves updating data on the resource.
  • Delete: The delete operation removes data from the resource

image.png

  • SOAP API: Simple Object Access Protocol (SOAP) API is a structured communication architecture between computers or web services. SOAP is XML based only, lightweight and provides requests and responses using a message structure like an envelope. Each SOAP protocols is independent and performs tasks by:

    1. Defining the mode of data transfer and the data types involved
    2. Using the contained instructions in the envelope for processing the message sent

SOAP.PNG

Choosing the best API

When selecting an API for your project, it's normal to get carried away by the available APIs especially the open-source ones (public APIs). You should bear these three factors in mind in your search for API:

  • The task you want to perform with the API
  • The kind of API you intend to use (Public or Private)
  • The desired endpoint, that is the response format you wish to get

What next?

This article has done justice in explaining the fundamentals of APIs. Each programming language has its own format for consuming APIs. Kindly search for resources on how to apply APIs in your preferred programming language or I may put up another article on one of the languages soon.