APIs#
APIs, or Application Programming Interfaces, are a set of protocols and routines for building software and applications. They specify how software components should interact and APIs allow for communication between different systems. They can be used to access web-based services, such as social media platforms, weather services, and online databases.
Types of APIs#
Type |
Description |
Implementations |
|---|---|---|
Open APIs |
also known as external or public APIs, are available to developers and other external users for use in their own applications |
|
Internal APIs |
also known as private or partner APIs, are used within a company or organization to share information between different internal systems |
|
Partner APIs |
used by approved partners to access a company’s internal systems |
|
Composite APIs |
allow developers to access multiple endpoints in a single call |
|
Web APIs |
use HTTP protocol and can return data in XML or JSON format |
|
Class APIs |
available through programming languages, libraries, and frameworks |
|
Database APIs |
provide a way to interact with databases and retrieve data |
|
Remote Procedure Call (RPC) APIs |
allow for communication between different systems using a protocol such as HTTP or HTTPS |
gRPC, tRPC |
Service-oriented architectures (SOA) APIs |
built on a service-oriented architecture and allow for communication between different services |
SOAP |
Hypertext Transfer Protocol (HTTP) APIs |
specific type of web API that use HTTP requests and responses to GET, PUT, POST and DELETE data |
REST |
Comparison of SOAP, REST, RPC, and GraphQL#
SOAP |
REST |
RPC |
GraphQL |
|
|---|---|---|---|---|
Design philosophy |
Follows a strict set of rules, with a focus on structure and a heavy use of XML. |
Flexible, with a focus on resources and their representations. Uses HTTP methods like GET, POST, etc. |
Remote procedure calls, which are similar to function calls. |
A query language for APIs that allows clients to define the structure of the data they need. |
Data format |
XML |
JSON or XML |
Any format |
JSON |
Error handling |
SOAP faults |
HTTP status codes |
Any format |
Returns only the requested data and includes errors in the response. |
Statefulness |
Stateful |
Stateless |
Stateless or stateful |
Stateless |
Caching |
No caching support |
Cacheable |
No caching support |
No caching support |
Security |
WS-Security provides a wide range of security options |
Can use HTTPS for transport-level security |
Depends on the implementation |
Can use HTTPS for transport-level security, also can use JSON Web Token (JWT) for authentication and authorization |
Complexity |
Complex |
Simple |
Simple or complex |
Simple for small queries, but complexity can increase for complex and nested queries |
Latency |
Higher |
Lower |
Depends on the implementation |
Lower |
Please note that some of the characteristics and features may depend on the specific implementation and usage of the API.