Sitemap

API (Application Programming Interface

6 min readMay 17, 2024

--

An API, or Application Programming Interface, is a set of rules and protocols for building and interacting with software applications. It defines the methods and data formats that applications can use to communicate with each other, allowing developers to use predefined functions to interact with the operating system, other applications, or services without having to write the code from scratch.

In simple meaning of an API, An API, or application programming interface, is a set of rules or protocols that enables software applications to communicate with each other to exchange data, features and functionality.

How do APIs work?

Press enter or click to view image in full size

It’s useful to think about API communication in terms of a request and response between a client and server. The application submitting the request is the client, and the server provides the response. The API is the bridge establishing the connection between them.

Types of APIs

APIs can be categorized by use case, including data APIs, operating system APIs, remote APIs and web APIs.

  • Data (or database) APIs-Used to connect applications and database management systems.
  • Operating system (local) APIs-Used to define how apps use operating system services and resources.
  • Remote APIs-Used to define how applications on different devices interact.
  • Web APIs-Used to enable data and functionality transfer over the internet using HTTP protocol.

Today, most APIs are web APIs. Web APIs are a type of remote API (meaning that the API uses protocols to manipulate external resources) that expose an application’s data and functionality over the internet.

The 4 main types of web APIs are:

  • Open APIs

Open APIs are open-source application programming interfaces you can access with the HTTP protocol. Also known as public APIs, they have defined API endpoints and request and response formats.

  • Partner APIs

Partner APIs connect strategic business partners. Typically, developers access these APIs in self-service mode through a public API developer portal. Still, they need to complete an onboarding process and get login credentials to access partner APIs.

  • Internal APIs

Internal, or private, APIs remain hidden from external users. These private APIs aren’t available for users outside of the company. Instead, organizations use them to improve productivity and communication across different internal development teams.

  • Composite APIs

Composite APIs combine multiple data or service APIs. They allow programmers to access several endpoints in a single call. Composite APIs are useful in microservices architecture where running a single task might require information from several sources.

API protocols, architectural styles and languages

Traditionally, API referred to an interface connected to an application created with any of the low-level programming languages, such as JavaScript. However, modern APIs vary in their architectures and use of data formats. They are typically built for HTTP, resulting in developer-friendly interfaces that are easily accessible and widely understood by applications written in Java, Ruby, Python and many other languages.

As the use of web APIs has increased, it has led to the development and use of certain protocols, styles, standards and languages. These structures provide users with a set of defined rules, or API specifications, that create accepted data types, commands and syntax. In effect, these API protocols facilitate standardized information exchange.

REST (representational state transfer)

Press enter or click to view image in full size

REST is a set of web API architecture principles. REST APIs — also known as RESTful APIs — are APIs that adhere to certain REST architectural constraints. REST APIs use HTTP requests such as GET, PUT, HEAD and DELETE to interact with resources. REST makes data available as resources, with each resource represented by a unique URI. Clients request a resource by providing its URI.

REST APIs are stateless — they do not save client data between requests. It’s possible to build RESTful APIs with SOAP protocols, but practitioners usually view the two standards as competing specifications.

SOAP (simple object access protocol)

Get Kaweesha Nadeethara De Silva’s stories in your inbox

Join Medium for free to get updates from this writer.

SOAP is a lightweight XML-based messaging protocol specification that enables endpoints to send and receive data through a range of communication protocols including SMTP (simple mail transfer protocol) and HTTP (hypertext transfer protocol.) SOAP is independent, which allows SOAP APIs to share information between apps or software components running in different environments or written in different languages.

Remote procedure call (RPC)

Remote procedure call (RPC) is a protocol that provides the high-level communications paradigm used in the operating system. RPC presumes the existence of a low-level transport protocol, such as transmission control protocol/internet protocol (TCP/IP) or user datagram protocol (UDP), for carrying the message data between communicating programs.

RPC implements a logical client-to-server communications system designed specifically for the support of network applications. The RPC protocol enables users to work with remote procedures as if the procedures were local.1

  • XML-RPC (XML- remote procedure call)

The XML-RPC protocol relies on a specific XML format to transfer data. XML-RPC is older than SOAP, but simpler, and relatively lightweight in that it uses minimum bandwidth.

  • JSON-RPC

Like XML-RPC, JSON-RPC is a remote procedure call, that uses JSON (JavaScript Object Notation) instead of XML. JSON is a lightweight format for data exchange that is simple to parse and uses name/value pairs and ordered lists of values. Because JSON uses universal data structures, it can be used with any programming language.

  • gRPC

gRPC is a high-performance, open-source RPC framework initially developed by Google. gRPC uses the network protocol HTTP/2 and Protocol Buffers data format and is commonly used to connect services in a microservices architecture.

WebSocket

WebSocket APIs enable bidirectional communication between client and server. This type of API does not require a new connection to be established for each communication — once the connection is established it allows for continuous exchange. This makes Web Socket APIs ideal for real-time communication.

GraphQL

GraphQL is an open-source query language and server-side runtime that specifies how clients should interact with APIs.2 GraphQL allows users to make API requests with just a few lines, rather than having to access complex endpoints with many parameters. This capability can make it easier to generate and respond to API queries, particularly more complex or specific requests that target multiple resources.

REST vs. SOAP

SOAP and REST represent different approaches to API design, describing rules and standards for how an API should interact with other applications. SOAP is a protocol while REST is a set of constraints that constitute an architectural style. Both use HTTP to exchange information.

REST is often considered a simpler alternative to SOAP because it is lightweight, flexible, transparent and relatively easy to use; SOAP requires users to write more code to complete each task than REST requires.

SOAP is more deterministic and robust (due to type checking), and proponents make the case that it is easier to use because of the SOAP support built into many development tools. SOAP features built-in compliance, and developers often consider it a more secure protocol, better suited for situations with strict data integrity requirements.

RESTful systems support messaging in different formats, such as plain text, HTML, YAML, XML and JSON, while SOAP only allows XML. Each has their strengths, and the “right choice,” might depend on the use case. However, the ability to support multiple formats for storing and exchanging data is one of the reasons REST is a prevailing choice for building public APIs.

Examples of Popular APIs

  • Google Maps API: Allows developers to integrate maps and location services into their applications.
  • Twitter API: Provides access to Twitter data and functionality, enabling features like tweet retrieval, posting, and user management.
  • Stripe API: Used for handling online payments, offering services like payment processing, subscriptions, and invoicing.

Benefits of Using APIs

  • Modularity: APIs allow different parts of a software system to communicate, promoting modular design and reusability.
  • Efficiency: Developers can leverage existing APIs to add complex functionalities quickly, saving time and resources.
  • Interoperability: APIs enable different systems and applications to work together, facilitating data exchange and integration.

Conclusion

APIs are crucial in modern software development, enabling seamless integration and interaction between different systems, applications, and services. By adhering to standardized protocols and formats, APIs help developers build robust and scalable solutions efficiently.

Reference:

What Is an API (Application Programming Interface)? | IBM

ChatGPT

--

--