Introduction to the concept of API

Introduction to the concept of API

What is API?

API is an abbreviation for Application Programming Interface which is a collection of communication protocols and subroutines used by various programs to communicate between them. A programmer can make use of various API tools to make its program easier and simpler. Also, an API facilitates the programmers with an efficient way to develop their software programs. Thus in simpler terms, an API helps two programs or applications to communicate with each other by providing them with necessary tools and functions. It takes the request from the user and sends it to the service provider and then again sends the result generated from the service provider to the desired user.

What is an example of an API?

When you use an application on your mobile phone, the application connects to the Internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions and sends it back to your phone. The application then interprets that data and presents you with the information you wanted in a readable way. This is what an API is - all of this happens via an API.

To explain this better, let us take a familiar example.

Imagine you’re sitting at a table in a restaurant with a menu of choices to order from. The kitchen is the part of the “system” that will prepare your order. What is missing is the critical link to communicate your order to the kitchen and deliver your food back to your table. That’s where the waiter or API comes in. The waiter is the messenger – or API – that takes your request or order and tells the kitchen – the system – what to do. Then the waiter delivers the response back to you; in this case, it is the food.

API ex2.webp

Types of APIs

There are four main types of APIs:

  1. Open APIs

  2. Partner APIs

  3. Internal APIs

  4. Composite APIs

api-types 1.png

Open APIs: Open APIs, also known as external or public APIs, are available to developers and other users with minimal restrictions. Open APIs have relaxed security measures, allowing developers and external users to access data easily. Some systems remain completely transparent, while others may require a simple registration or API key. This feature makes public APIs an excellent option for businesses that want to streamline communication with third-party users, such as vendors or clients. It also allows software developers to quickly implement components without restrictions. For example, the ability to create an account on an external site/app using your Facebook credentials is made possible using Facebook's open API. Many large technology firms, such as Twitter, LinkedIn and Facebook, allow the use of their service by third parties and competitors.

Partner APIs: Much like the open method, partner APIs are intended to promote communication between a company and its external users. However, this method uses more security to grant data access to specific business partners. While partner APIs are often exposed to other public API platforms, third-party gateways ensure only registered servers are permitted to access information. This is a very common pattern in software as a service ecosystem.

Internal APIs: Also known as private, internal APIs are hidden from external parties and used to enhance communication within an organization. With this method, companies can streamline data sharing between departments and all business locations. Although access is limited to inside operations, internal APIs still provide security measures to verify employee identity before granting entrance into the system.

Composite APIs: The composite API design can withstand several integration systems and combine all data. This increased functionality makes composite APIs the ideal method in microservices, where multiple services are needed to execute one operation. It also allows developers to access numerous endpoints, including web and/or other API applications, in one procedure call. The robust infrastructure of the composite API improves data service performance and provides an all-in-one solution.

APIs Protocols

An API protocol defines the rules for API calls: it specifies accepted data types and commands. Different API architectures specify different protocol constraints.

REST:

Representational state transfer (REST) is more architectural rather than a protocol. This means it has to adhere to specific user interface characteristics so servers can recognize commands immediately and fulfill requests. Rather than regulating actions like protocols, REST handles document transferal. The main principles that REST API must abide by are-

  • Client-Server - The client side and server application must be independent of each other, so changes at one endpoint don't affect the other

  • Cache - The platform should be able to cache, or temporarily retain, responses to increase service speed and enhance user experience.

  • Layered - Supporting a layered architecture allows APIs to communicate either directly with the server or through an application chain.

  • Stateless - Being stateless ensures that no client information is stored on the server.

  • Uniform Interface - Allowing clients and servers to communicate using various data formats such as HTTP, URIs, CRUD, or JSON improves information sharing.

REST API.png

JSON-RPC and XML-RPC

An RPC is a remote procedural call protocol. XML-RPC uses XML to encode its calls, while JSON-RPC uses JSON for the encoding. Both protocols are simple. A call can contain multiple parameters, and expects one result. They have a couple of key features, which require a different architecture to REST:

They are designed to call methods, whereas REST protocols involve the transfer of documents (resource representations). Or, to put it another way, REST works with resources, whereas RPC is about actions. The URI identifies the server, but contains no information in its parameters, whereas in REST the URI contains details such as query parameters.

SOAP

SOAP (simple object access protocol) is an established web API protocol. It is intended to be extensible, neutral (able to operate over a range of communication protocols, including HTTP, SMTP, TCP and more), and independent (it allows for any programming style) The SOAP specification includes:

  • The processing model: how to process a SOAP message.

  • Extensibility model: SOAP features and modules.

  • Protocol binding rules: how to use SOAP with an underlying protocol, such as HTTP.

  • Message construct: how to structure a SOAP message

When seeking an integration solution, businesses need to do a deep dive into the different types of API. A company needs to determine what line(s) of communication they want to improve and what set of protocols interacts well with their existing systems. Successful API implementation can promote data transparency and performance.

Thank you for reading. Don't forget to like and leave a comment.