You are currently viewing API for everyone (Serie 1)

API for everyone (Serie 1)

  • Post last modified:June 8, 2023

API is an abbreviation for Application Programming Interface, consider an API as a contract that allows a piece of code/ software/program to talk to another piece of code/ software/ program or a set of rules that define how applications or devices can connect to and communicate with each other. APIs are the building blocks of modern software as they allow sharing of resources and services across applications, organizations and devices.

API History

The term API was first mentioned in a 1951 book written by Maurice Wilkes and David Wheeler called ‘The Preparation of Programs for an Electronic Digital Computer.’ During this era APIs were simple command-line interfaces that enabled programmers to interact with computers. In the 1960s APIs evolved to a single application interacting with the rest of a computer system and in the 70s APIs were introduced to the world of databases. In the 80s with the introduction and growth of computer networks, APIs enabled Remote Procedure Calls that enabled cross-platform compatibility allowing developers to create applications that could run on multiple platforms. In the 90s came the birth of the Internet and API was a way for applications to exchange data with the use of a standard set of protocols and this just took off in the 2000s facilitating new business models to date.

API Analogy

To clearly understand an API, let’s use a restaurant Analogy.

Credit: Postman

You could think of an API as a waiter/waitress in a restaurant who intermediates between a customer and a chef. In this case, consider the waitress as our API (contract for the customer to talk to the chef and vice versa). The chef is bound to the kitchen walls where he prepares the meals, and the customer is only allowed to stay in the dining area.

The customer calls the waitress, talks to the waitress, makes an order (the customer does not even need to know how the meal is prepared), and then the waitress takes the order to the chef, the waitress waits for the chef to prepare the meal when the meal is ready the waitress will bring it back to the customer and if the meal cannot be prepared the waitress will communicate back to the customer that the meal cannot be prepared at the moment.

The APIs also work in the same way, a Client sends a request through the API to the Server, and when the server resolves the request, through the API it sends a response back to the Client.

API Types

There are three main types of APIs and they are :-

  1. Hardware APIs,
    • This kind of API creates an interface for software to talk to hardware and an example here is how your phone’s camera talks to the phone’s operation system.
  2. Software Library APIs,
    • This kind of API creates an interface for directly consuming code from another code base and an example is using methods from a library you import into your application.
  3. Web APIs,
    • This kind of API creates an interface for communicating across the codebase over a network and an example is fetching posts from the JSON placeholder API over the internet.

In some cases, multiple API types may be used to achieve a task, an example is uploading a photo to Instagram. This makes use of various APIs:

  1. Hardware API for the app to talk to your camera.
  2. Software Library API for the image to be processed with filters
  3. Web API for sending your image to Instagram’s servers so your friends can like it!

API Architectures

Multiple architectures are employed when developing APIS and these include: –

REST (Representational State Transfer) first defined in 2000 by Dr. Roy Fielding a computer scientist in his doctoral dissertation is an interface that two computer systems use to exchange information securely over the internet.

GraphQL created in 2012 and open-sourced by Facebook in 2015 is a query language for APIs and a runtime for fulfilling those queries with your existing data. This gives the client the power to ask exactly what they need from the server and nothing more.

WebSockets, a computer communications protocol, provides full-duplex communication channels over a single TCP connection. This communication protocol was standardized in 2011.

Webhooks, a method of sending automated messages (payload) sent from an app/ server when a specific event happens

SOAP, Simple Object Access Protocol first appeared in 1998 as an access protocol application programming interface used for communication between two or multiple computers.

gRPC, Google Remote Procedure Call initially created by Google around 2001 is a cross-platform open-source high-performance remote procedure call framework used in APIs to connect a large number of microservices.

MQTT, MQ Telemetry Transport, is a machine-to-machine API connectivity protocol used in extremely lightweight publish/subscribe messaging protocol between small and IOT devices.

API Variation/ Classifications

APIs developed can be classified under the following classifications, though as well some developed APIs can fall into more than a single category.

  • Public/ Open APIs are APIs accessible and consumable by anyone who discovers the API. Often, this API classification does not require a key to access. An example of this classification is the JSON placeholder API.
  • Private APIs are APIs consumed only within an organization and not made public. Any API used internally at your organization but not accessed outside your organization is classified as a private API.
  • Partner APIs are APIs consumed between one or more organizations that have an established relationship. These APIs are more evident in cases where two or more established organizations are extending services from one another that they would have otherwise developed from scratch. This is common for integrations in payment gateway systems.

Until next time, more love from Flyhub and Stanbic Group.

References

https://academy.postman.com/path/postman-api-fundamentals-student-expert/

https://www.ibm.com/topics/rest-apis

https://aws.amazon.com/what-is/restful-api/

https://traefik.io/blog/the-history-and-evolution-of-apis/

Author: Ssemugenyi Isaac

Software Developer