API stands for Application Programming Interface, a mechanism that allows the interaction between two applications using a set of rules. One fundamental thing about APIs is that they can not be categorized into one type because not every software integration is the same. Therefore, different APIs can be categorized based on ownership, architecture, use cases, and applications.
Ownership or Provisioning Types of APIs
1. Open APIs
Open APIs, also known as External or Public APIs, are publicly available to developers and other users with minimal restrictions. They may require registration, use an API Key or OAuth, or be completely open. They focus on external users to access data or services. For Example, Facebook and Twitter have a few Open APIs which you can access using OAuth or API key. While some open APIs are free, others require a subscription fee based on the number of calls made to the API.
2. Internal APIs
Also known as Private APIs, These are usually designed for internal use within an organization. The company uses the Internal type for the different internal projects like in-house HR, Security, or data transfer systems. These APIs are entirely hidden from the outside world and can only be accessed by internal developers.
3. Partner APIs
Partner APIs are exposed to business partners. They are not available publicly and need specific entitlement to access them. Example: Payment Gateways APIs like Paypal and PayU. Courier Service API like BlueDart and DHL. With Partner APIs, Security measures must be more robust than public APIs. Enterprises also typically do not monetize Partner APIs directly; partners are paid for their services rather than API use.
4. Composite APIs
This type of API combines different data and service APIs. Use Composite APIs if you need data from various applications or data sources. For example, when an order is placed on a shopping website, it makes different APIs calls to the customer and order management system. You can combine several APIs into one to reduce complexity and server load and make calls faster.
API Types based on Architecture
An API’s architecture consists of the rules that guide what information an API can share with clients and how it transfers the data.
1. SOAP (Simple Object Access Protocol)
This protocol uses XML as a format to transfer data. Its primary function is to define the structure of the messages and methods of communication. It also uses WSDL, or Web Services Definition Language, to publish its interface definition in a machine-readable document. SOAP APIs are more secure than REST APIs, but they are code-heavy and harder to implement because of rigid guidelines. SOAP APIs also work over any communication protocol.
Unlike REST and SOAP, which facilitate data transfer, RPC APIs invoke processes and execute scripts on a server. The RPC or Remote Procedural call can be further divided into two types. XML-RPC and JSON-RPC. XML-RPC protocol uses a specific XML format to transfer data compared to SOAP, which uses a proprietary XML format. XML-RPC uses minimum bandwidth and is much simpler than SOAP. JSON-RPC, This protocol is similar to XML-RPC, but instead of using XML format to transfer data, it uses JSON. XML is more secure and accommodating than JSON. RPC APIs can be used for internal systems for making basic process requests, especially many at once. RPC-based APIs are not a good choice for enterprise-grade APIs because of their limited data type support and security.
3. REST (Representational State Transfer)
REST is not a protocol like the other web services; instead, it is a set of architectural principles. To be a REST API, an API must stick to certain architectural constraints or principles, including client-server architecture, stateless, cacheability, and layered Systems. Today, REST is very popular, and the majority of Web APIs are built on this architecture.
API Types based on System
APIs can be classified according to the systems for which they are designed.
1. Database APIs
Database APIs enable communication between an application and a database management system. Developers work with databases by writing queries to access data, change tables, etc.
2. Operating systems APIs
This group of APIs defines how applications use the resources and services of operating systems. Every OS has its set of APIs, for instance, Windows API or Linux API. Apple also provides API references for macOS and iOS in its developer documentation.
3. Remote APIs
Remote APIs define standards of interaction for applications running on different machines. In other words, one software product accesses resources located outside the device that requests them. Since two remotely located applications are connected over a communications network, particularly the internet, most remote APIs are written based on web standards. Java Database Connectivity API and Java Remote Method Invocation API are two examples of remote application programming interfaces.
4. Web APIs
This API class is the most common. Web APIs provide machine-readable data and transfer functionality between web-based systems, representing client-server architecture. These APIs mainly deliver requests from web applications and responses from servers using Hypertext Transfer Protocol (HTTP). Developers can use web APIs to extend the functionality of their apps or sites. For instance, Google Maps API enables the addition of a map with an organization’s location.
API Types based on Applications
You can also categorize APIs based on Applications. For Example:
- IP Geolocation
- Food & Restaurant