Essential Fundamentals for Getting Started with API Test Automation - Instituto Eldorado
22 de Janeiro de 2025

Essential Fundamentals for Getting Started with API Test Automation

Adriany

Adriany Graças de Souza

Author

APIs are a key component of modern software architecture, as they facilitate communication between different services and systems, often of distinct natures. API testing is crucial to ensure that this communication occurs correctly, securely, and efficiently while also verifying that the implemented functionalities work as expected. With API testing, we can validate backend functionalities independently of the frontend, allowing tests to begin before the interface is complete. This practice enables early identification and resolution of issues, speeding up the development process and improving overall software quality.

What is API Testing?

API stands for “Application Programming Interface.” The “Application” represents any software that performs a specific function, and the “Interface” establishes a contract or set of rules for communication. Each part (client and server) must follow the format defined by the API to send and receive data correctly. This structure ensures that exchanged messages are understood, promoting efficient and secure integration between different systems. The API acts as a “bridge” for communication between applications, allowing them to exchange information and resources in a standardized and structured manner.

What is HTTP?

HTTP, or Hypertext Transfer Protocol, is a communication protocol that enables the exchange of information between a client and a server. It defines a set of rules that both must follow for communication to be clear and understandable, which is why it is called a protocol. This allows the client to send requests to the server, which responds according to the same rules, ensuring an organized and effective data exchange.

When you access a website, the browser sends an HTTP request to the server hosting the site. The server then responds with the page data (usually in HTML), which the browser interprets and displays to you. HTTP also allows operations beyond simply “viewing” a page, such as submitting forms or downloading files.

  • HTTP is based on a request-response model, and messages can be sent using methods such as:
    • GET: Retrieves data (such as loading a webpage).
    • POST: Sends data to the server (such as submitting a form).
    • PUT and DELETE: Update and remove data, respectively.

HTTP is called a “stateless” protocol because each request is independent; it does not “remember” past interactions. The more secure version of the protocol is HTTPS (HTTP Secure), which encrypts communication to protect data.

Request (Request Structure)

A Request is the request the client makes to the server, precisely describing what it wants. Each request includes a specific structure containing:

  • Address (URL): The location of the resource that the client wants to access or manipulate on the server.
  • Header: A set of additional information providing context for the server, such as the accepted data type (JSON, HTML), authentication details, and request origin.
  • Body: Extra data the client sends, required in methods like POST and PUT, usually in JSON or XML format, detailing what needs to be processed or stored.

This structure helps the server understand and process the request to respond with the requested information or action.

What are GET and POST?

These are HTTP methods used to interact with the server. They indicate the action the client wants to perform and are fundamental in client-server communication (e.g., a browser interacting with a web server).

  • GET: Used when the client wants to retrieve information from the server. In other words, it requests data, such as when you visit a webpage. When you enter a website address and press “Enter,” the browser makes a GET request to the server, requesting the necessary resources (such as the page’s HTML, images, etc.).
  • POST: Used when the client wants to send data to the server for processing or storage. A classic example is submitting a form—when you fill in fields like name and email on a registration page and click “Submit,” the browser sends the form data via a POST request to the server for processing.

Response (Server Response)

We’ve learned that the client sends a Request to the server. The Response is the message the server sends back after receiving and processing the request. It contains the requested information or, in case of an error, a message explaining what went wrong. When a client makes a request, it specifies what it expects to receive in return (for example, data or a webpage).

What Validations Can Be Performed on an API?

  • Security Testing: Identifies security vulnerabilities and verifies if the API can withstand attacks.
  • Integration Testing: Checks how the API connects and interacts with other systems or parts of the software.
  • Unit Testing: Tests specific parts of the API, such as individual functions or methods.
  • Error Handling Testing: Ensures the API can handle issues, such as missing or incorrect data.
  • Functional Testing: Verifies if different API functions work correctly.
  • Reliability Testing: Confirms that the API functions properly over time without failures.
  • Load Testing: Measures API performance when handling many requests under normal conditions and peak loads.

These tests help ensure that the API is secure, efficient, and reliable.

Subscribe to our newsletter.