The Unsung Hero of our Connected World

Cognizant
Cognizant Softvision Insights
6 min readFeb 28, 2023

Part 1: Basics and Benefits

By Tudor Blaga, QC Engineer, Cognizant Softvision

Application Programming Interfaces, or APIs, are an important and integral part of modern software development, helping different applications and technologies interact and share data between them.

This two-part article will cover API basics, benefits, testing approaches, tools, and best practices. The following, part one, explores what an API is and dives into the methods, web services, and how the software development process benefits from using APIs.

What is API?

API is the messenger that takes requests and tells a system what you want to do, and then returns the response back to you.

For an example, the most common analogy is to imagine that you are in a restaurant with a menu in front of you. The kitchen is the part of the system which will prepare your order. The crucial link in communicating your order to the kitchen is missing, and this is where the waiter (the API) steps in. The waiter acts as the messenger, taking your request (your order) and communicating it to the system (the kitchen) on what actions to take. The waiter then returns the response back to you (the food).

A technical definition for Application Programming Interface (API):

An API serves as a software interface that enables two applications to communicate with each other without any need for user involvement. It comprises multiple functions and procedures (code) that can be easily accessed and executed, facilitating communication and data exchange between two or more software programs.

An illustration of a functioning API can be seen through the example of booking.com. This platform gathers information from multiple hotel, apartment, and vendor sources. For instance, when you book a hotel room, you input details such as the number of days you need the room for, room options, breakfast offerings, etc. This, in turn, presents you with various room options and their availability. In this scenario, the application interacts with APIs from multiple vendors, providing access to their data.

What is API Testing?

API testing is a type of software testing that doesn’t use a Graphical User Interface (GUI) and cannot be done at a front-end level.

The API lies at the heart of an application, sandwiched between the data layer, the service layer (API), and the presentation layer (UI/GUI). As a middleware, it serves as the connecting link between these layers and enables communication between two software programs.

The purpose of API testing is to evaluate the Application Programming Interface and ensure that it delivers the expected functionality, performance, reliability, and security. This is achieved by sending requests to one or more API endpoints and comparing the response to the expected outcome.

What is REST API?

Imagine you are searching for videos of cats on YouTube. You type “cats” into the search field and upon hitting enter, you are presented with a list of videos about cats. This is how a REST API endpoint operates. You send a request for information, and in return, you receive a list of results from the service you are making the request to.

The anatomy of a Request is as follows:

  • The endpoint
  • The method
  • The headers
  • The body (data)

What is an Endpoint?

An API endpoint is a digital spot where the API can receive requests related to a particular resource hosted on its server. It comprises a uniform resource locator (URL) which provides the location of the resource on the server. An endpoint is a part of the API, while the API as a whole is a set of guidelines that enable multiple applications to share resources.

What is a method?

The method is the request type that you send to a server. The available methods are as follows:

GET:

This request is used to get a resource from a server. If you perform a `GET` request, the server looks for the data you requested and sends it back to you. In other words, a `GET` request performs a `READ` operation. This is the default request method.

Example: GET /store/inventory, which is an operation that returns inventory items from somewhere

POST:

This request is used to create a new resource on a server. If you perform a `POST` request, the server creates a new entry in the database and tells you whether the creation is successful. In other words, a `POST` request performs a `CREATE` operation.

Example: POST /store/order, which is an operation that places and order for something

PUT / PATCH:

These two requests are used to update a resource on a server. If you perform a `PUT` or `PATCH` request, the server updates an entry in the database and tells you whether the update is successful. In other words, a `PUT` or `PATCH` request performs an `UPDATE` operation.

Example: PUT /itemId, which is an operation that updates the information regarding a particular item by id

DELETE:

This request is used to delete a resource from a server. If you perform a `DELETE` request, the server deletes an entry in the database and tells you whether the deletion is successful. In other words, a `DELETE` request performs a `DELETE` operation.

Example: DELETE /store/order/{orderId}, which is an operation that deletes a purchase order by id.

These methods provide the meaning regarding the request that you are performing. Those operations are named CRUD operations. CRUD is an abbreviation for CREATE, READ, UPDATE, and DELETE.

Web Services vs. Web API

Web Services and Web API both serve the purpose of facilitating communication between the client and the server. The main distinction between them lies in the manner of communication. To communicate effectively, each of them requires a request body that can be processed in a specific language. Additionally, there are differences in terms of security, speed of communication with the server, and response time to the client.

Web Services:

  • Web Services use XML for encoding and therefore offer higher security.
  • In addition to SSL for data transmission, Web Services also provide WSS for enhanced security.
  • Web Services are a subset of Web APIs, only offering three styles of use (SOAP, REST, and XML-RPC).
  • Web Services require a network connection to function.
  • Web Services allow for “One Code different applications,” meaning a single, generic code can be used across various applications.

Web API:

  • The use of JSON (JavaScript Object Notation) in a Web API contributes to its speed advantage.
  • Web API is faster than other technologies like XML due to JSON being a lighter weight data format.
  • Web API encompasses the functionality of Web Services, including all styles such as JSON-RPC.
  • The need for a network connection is not always required for Web API to function.
  • The level of interoperability supported by a Web API can vary depending on the specific system or application.

Key takeaways

APIs are an essential part of modern software development, helping easy integration and communication between different applications and systems. REST APIs are the most popular architecture style for web APIs. Endpoints and methods are fundamental concepts in API design, allowing different software programs and applications to access and manipulate specific resources from the servers.

As demand for interoperability and data exchange is continuously growing, APIs will continue to play a critical role in enabling innovation in businesses and applications development, thus making API testing an absolutely crucial process to ensure that the applications are working as expected. We expand on this in part two of this article.

--

--