Web Application Programming Interfaces (Web APIs) 101
SENG 42273 — Semantic Web and Ontological Engineering
APIs are everywhere. You are making use of them even if you don’t know what an API is. Have you ever wondered how you are able to shop online, order an Uber, or even check the weather on your phone? They are all powered by APIs.
What is an API?
API stands for Application Programming Interface, which is a software-to-software interface that defines the contract for applications to communicate with each other without human interaction. This contract defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the kinds of responses, etc.
What is a Web API?
A Web API is an API for either a web server or a web browser. In the context of web browsers, web APIs are the APIs exposed by the browsers to be used by the front end web developers. They let users access various services on the client’s device such as location or storage. In the context of the web servers, web APIs are how the servers expose their functionalities to clients so that the clients can access them over the internet. For this article though, let’s talk about web APIs from the context of web servers.
Web APIs use a request-response messaging system and standards like JSON, XML to describe the content in the message body. Web APIs come in forms like SOAP, REST, and GraphQL. An API endpoint is the point of entry in a communication channel where the client and the server interacts. A single API can multiple endpoints.
Why do we use web APIs?
The main advantage of web APIs is that they provide abstractions for the functionalities that they offer. The client only needs to be aware of the functionality a particular API provides, its endpoints, request parameters, and responses. They do not need to know or care(in most cases) about how the functionality is offered, only that it does. This can dramatically reduce the complexity of the programs and increase the productivity of the people who write them.
Web APIs also facilitate the distributed deployment of applications. Instead of developing a monolithic application, the developers can create a set of loosely coupled microservices and use API calls to facilitate communication among them. Each microservice can be deployed, maintained, and scaled independently from others, which makes it a cost-effective, reliable, and flexible approach for developing applications.
Mobile computing is another area that heavily utilizes the use of web APIs. Since mobile devices have limited resources (CPU, RAM, storage, and power), mobile applications can use cloud servers to perform resource-intensive operations and only retrieve the outcome. APIs are what powers the communication between the application and the cloud.
From a business perspective, organizations can expose their APIs to the public in order to integrate their services to other applications. This provides a competitive advantage for the organization by expanding its reach and it can generate revenue by charging fees for API calls. For example, Google Maps APIs are used by applications like Uber to integrate the maps and navigation functionalities.
Examples for web APIs
- Google Maps APIs: provides the geolocation services for the clients.
- YouTube API: integrate YouTube features to a client application, including the ability to upload videos, create and manage playlists, and more.
- Spotify API: provides access to user-related data, like playlists and music that the user’s music library.
- Weatherstack API: provide weather-related services like forecasts, real-time weather, etc.
- Facebook APIs: allow applications to use social connections and profile information to make applications more involving, etc.
Limitations of web APIs
Like every technology, APIs also have their own caveats.
- Latency in API calls due to network issues.
- Exposing APIs adds additional attack surfaces to a web server.
- Network errors may cause request failures and reduce stability.
These limitations can be sometimes circumvented using techniques like caching, proper error handling, and following security practices.
That concludes a simple introduction to the concept of web APIs. See you in the next one! 🙂