Table of Contents
Summary
This document is a curated list of beginner and intermediate focused topics primarily covering the development of APIs and understanding their use cases in the modern world of development. It is recommended to have prior knowledge of development, including design pattern knowledge as APIs can become a very difficult and extensive subject to cover properly.
TL;DR
What is an API?
In simple terms, consider yourself as a customer sitting at a table within a restaurant. A waiter comes to you and asks for your order--- which you happily comply--- providing the order to the waiter; its the waiters responsibility to communicate your order (request) to the kitchen and have a chef make it for you. After its been made, its the waiters responsibility to serve the dish you have requested in the manner you would expect to be presented, and the waiter happily does so. This process is similar to the process of an API.
Definition of an API
An application programming interface (API) is a way for two or more computer programs or components to communicate with each other. It is a type of interface, offering a service to other pieces of software.
That definition above would be fine, but its very vague, a proper definition would be: an API is a intermediary communication layer that communicates and shares information (or performs a specific task) from A to B. For an API, it’s job is to transfer data or perform actions, giving each side (A or B) the intricate details without any of the other sides knowing each others internal architecture.
How is it used in Microservices or Monoliths?
Microservices and Monoliths are architectures that heavily differ from one another. However, they both use APIs to get the job done.
- Monolithic Architecture: Since monoliths employ a set of layers, usually falling in the line of UI, Business Logic, Data Access (Database), APIs would false right in the middle where most of the business logic resides. APIs would need to communicate with the Database to retrieve information, and send data to the UI (User Interface) in order to display the data appropriately and make use of it.
- Microservice Architecture: In Microservices, APIs are used to communicate between microservices. Think of it as a web of complexity where APIs are continuously talking and communicating with one another to perform some task efficiently. Usually each microservice can expose its functionality through an API, where other APIs from other microservices can interact with it.
Building a Production Level API
Production-level APIs require a lot of work upfront. They should be designed with the following in mind:
- Reliability
- Scalability
- Maintainability
- Flexibility
- Being Secure & Efficient
- Meeting End-User Requirements
Production-level APIs are usually publicly accessible, but at times there would be a need for more private and secure APIs that are used internally within a company--- which is fine, since its sensitive data.
What Benefits do APIs Provide?
Many, its a gold standard for developing any application. APIs are near integral to most modern software development as its one of the best ways for completely different applications to speak with one another.
What are some Common APIs?
Unless I was to miraculously come across a written dissertation for “The most common APIs of the century,” I would probably assume everything within there will either be hardly used or obsolete (unless there are some rare occasions). As anything in Software, APIs are always being continuously developed--- they change over, and over, and over. While I cant guarantee or provide a proper list of the most common APIs, I would suggest looking into this site: https://rapidapi.com/.
Common Ways to Build APIs
The most common ways to Build APIs comes from the following article: https://blog.amigoscode.com/p/6-common-ways-to-build-apis, where the six more common ways are the following:
- Restful APIs
- GraphQL APIs
- gRPC APIs
- Web Socket APIs
- MQTT APIs
- Serverless APIs
RESTful APIs: A RESTful API (Representational State Transfer Application Programming Interface) is like a set of rules that allow different programs to communicate to each other over the internet. RESTful APIs use HTTP Request Methods like GET, POST, PUT, DELETE. APIs built using a RESTful approach are very popular, mostly due to their flexible, lightweight, and organized nature.
GRAPHQL APIs: GraphQL APIs are APIs that are considered to be more efficient and robust than other APIs as they use a single endpoint to send complex queries and mutations (commands to change data) to the server. Rather than having multiple endpoints that request and receive data, consider it like a replacement layer for your API where GraphQL does all of the heavy lifting (request, receive).
gRPC, tRPC APIs:
Web Socket APIs:
MQTT APIs: An MQTT (Message Queuing Telemetry Transport) API is a lightweight message protocol designed for small sensors and mobile devices. It’s often useful in IoT projects because it has a low overhead, coupled with reliable message delivery, and supports the publish-subscribe pattern with its variants. Consider using this API technique for IoT and with network oriented software.
Serverless APIs: A serverless API is an API that is built using a cloud service provider like AWS Lambda or Google Cloud Functions. Instead of you--- the API developer managing your own servers, a cloud provider will handle all your infrastructure; leaving you to do what matters most, code. Scaling and maintenance is the job of the provider you are using, but this will lead to additional costs which can get pricey quick. I don’t see many developers developing with serverless in mind, probably due to the fact that there are companies behind them that will take your life savings without hesitation.