APIs are everywhere. It is one of those terms that no one can go without knowing. If you’ve ever used a website or an app, you’ve probably interacted with an API without realising it. API stands for Application Programming Interface, and it’s a way for different applications to communicate.
So, what exactly is an API? At a high level, an API is a set of protocols, routines, and tools for building software and applications. It defines how different software components should interact with each other, making it easier to build complex applications by breaking them down into smaller, more manageable parts (sometimes).
An API is essentially a way for different applications or pieces of software to interact with each other. It’s a way to share data and functionality. If you think of software as a human body, an API is likely the hands.
Basic concepts
I came across a meme that illustrates what an API is extremely eloquently (at least in terms of web development):
This meme at least illustrates how APIs work for websites and web development. They commonly act as the interface between your front-end and back-end.
Let’s quickly take a look at those two terms:
Back-end:
The part of a system or application that is responsible for:
- Processing and storing data.
- Managing communication between different components or systems.
- Usually does the heavy lifting in terms of processing and computations.
The back-end typically includes a server, database, and application logic that work together to provide the functionality of the application. It may also include APIs (Application Programming Interfaces) that allow other software applications to interact with the system.
Front-end
The part of an application or website that users interact with directly. It includes the visual elements, user interface, and user experience design that allow users to interact with the application and access its functionality.
Think of the front end essentially as the website you interact with to consume, change or input data or access functionality of the application.
An application typically uses an API to retrieve data from the back-end to display on the front-end. It goes beyond that as APIs can also be used to:
- Add data to the server
- Alter data on the server
- Access any other functionality
It is important to note that APIs are not just used in web development, they can also be used to facilitate integrations, share functionality between apps and to make data and functionality available to other applications or processes, among other uses.
Why are APIs used?
Imagine you’re building a website or application that needs to retrieve data from a third-party service, like a weather forecast. Instead of building a weather forecasting system from scratch, you can use an API provided by a weather service. This API allows your application to request the weather service, which returns the requested data in a format your application can understand and use.
To simplify, there are a few reasons why APIs are commonly used:
- Reusability – an API can be reused across many different applications and even in different parts of an application where needed
- Accessibility – making data or functionality accessible without needing to recreate it every time saves time and money and has a massive impact on simplifying support and enhancement
- Efficiency – APIs allow for reusability and accessibility, which already enhances efficiency. However, it also allows for the separation of development concerns. Breaking things down into smaller blocks allows for better control over design, easier support and maintenance and often an all-around more understandable architecture. (opinion here, not necessarily fact)
Of course, there are many more reasons, but these are three of the most important elements. Also, APIs often promote standardisation, integration and security.
How do APIs work?
APIs typically stand as the middleman between two applications to expose data or functionality.
It can be something like this, where the API facilitates interaction between the back end and the front end (typically seen with SPA – Singla Page Applications)
You can also see something like this, where one application or system will make use of another application or system’s APIi to access its data or functionality:
There are many different types APIs, but one of the most popular is REST (Representational State Transfer). REST is a web-based API that uses HTTP requests to retrieve data from a server. It’s used by many popular websites and services, such as Twitter, Facebook, and Google Maps. Many organisations also have internal APIs to facilitate:
- Integration
- data availability and modification
- Functionality distribution
Other API technologies include SOAP (Simple Object Access Protocol), which uses XML to transfer data between applications, and GraphQL, which allows clients to specify exactly what data they need from a server, making it more efficient than others APIs.
There are many different ways in which APIs can be created and hosted. This depends on the developer, the project, available technology and the infrastructure. APIs can be created with code, a framework or even low-code tools.
Examples of APIs
Some examples of APIs that you might use in your everyday life include:
- Google Maps API: allows developers to integrate maps into applications and retrieve location data.
- Twitter API: allows developers to build applications that interact with Twitter, such as social media monitoring tools.
- Amazon Web Services APIs: allows developers to access cloud computing resources like storage and computing power.
- Internal APIs: Organisations often have APIs to facilitate integration, data transfer and manipulation and allow for sharing of different applications’ functionality within the organisation.
- CRUD-APIs: One of the most typical API types allowing data interaction. CRUD stand for Create, Read, Update, Delete.
APIs are a powerful tool for building complex applications by breaking them down into smaller, more manageable parts. They often work well for SOA (Service Orientated Architecture) and are key to a successful Microservices architecture. They allow different applications to communicate with each other, making it easier to build and integrate different software components.
This is an extremely rudimentary explanation of APIs. If you quickly need to consume and use an API, why not look at something like a Low-Code tool. It removes the effort of having to write code to interact with APIs. You can also create APIs with ease and speed by using a low-code tool. I have a few articles on how you can easily do this with minimal coding required:
