DEV Community

Anna Baker
Anna Baker

Posted on

API Validation: Why You Need It

API Validation: Why You Need It

API validation is important because it allows you to ensure that your API is functioning correctly. By validating your API, you can catch errors and ensure that your API is working as expected. API validation is essential for ensuring that your API is stable and reliable.
API validation can be performed using a number of different tools. The most common tool for performing API validation is the use of unit tests. Unit tests allow you to test individual pieces of code to ensure that they are functioning correctly. Unit tests are typically written by developers and are used to test code before it is deployed to production.
Another tool that can be used for performing API validation is the use of integration tests. Integration tests allow you to test how different parts of your system work together. Integration tests are typically written by testers and are used to test code after it has been deployed to production.
API validation is important because it allows you to ensure that your API is functioning correctly. By validating your API, you can catch errors and ensure that your API is working as expected. API validation is essential for ensuring that your API is stable and reliable.

What is API validation?

API validation is the process of verifying that an API meets the requirements for functionality, performance and security. This can be done manually or automatically, but automated API validation is generally preferred as it is more efficient and can be more comprehensive. API validation tools can check for a wide variety of issues, such as incorrect responses, missing or incorrect headers, and security vulnerabilities.

The importance of API validation

API validation is a process of verifying that an API meets its requirements and that it functions as expected. The purpose of API validation is to ensure that the API is fit for purpose and that it works as intended. API validation can be done manually or automatically, and it is typically done during the development process. Automated API validation can be done using tools such as SoapUI.

How to validate your APIs

I recommend using either SoapUI or Postman, you first need to create a project. A project is a collection of tests and/or requests that you can run against an API. Once you have created a project, you can start adding tests or requests to it.

SoapUI

  • To create a project in SoapUI, you need to select the File > New Project option from the menu. This will open the New Project dialog box. In the New Project dialog box, you need to specify the name of the project, the description, and the initial WSDL or Swagger file. Once you have specified these details, you can click the OK button to create the project.

  • To add a test in SoapUI, you need to select the Test Case node in the navigator and then click on the Add button in the toolbar. This will open the Add TestCase dialog box. In this dialog box, you need to specify the name of the test case and its description. Once you have specified these details, you can click on the Create button to add the test case.

Postman

  • To create a project in Postman, you need to select the File > New > Collection option from the menu. This will open the New Collection dialog box. In the New Collection dialog box, you need to specify the name of the collection and its description. Once you have specified these details, you can click the Create button to create the collection.

  • To add a request in Postman, you need to select the Collection node in which you want to add it and then click on the Add Request button in the toolbar. This will open up a new tab where you can specify all of the details for your request, such as its method (e.g., GET, POST), its URL, its headers, and its body (if applicable). Once you have specified all of these details, you can click on the Send button to make your request.

After adding tests or requests to your project, you can run them by selecting them and clicking on the Run button in either SoapUI or Postman. When your tests or requests are run, they will be executed against your API and their results will be displayed in either tool. These results will #include things like whether or not your test passed or failed and what kind of response (if any)
you received from your API.

As someone who works in the API industry, I can tell you that API validation is important stuff. It's the process of making sure that an API meets expectations and requirements, and it's something you need to do if you want your API to be successful. Here's why:

  1. It prevents problems down the line. By making sure that an API is properly validated before it's released, you can avoid a lot of headaches later on.

  2. It helps ensure compatibility. If an API is compatible with other APIs and technologies, it'll be much easier to work with and integrate into existing systems.

  3. It allows for better documentation. When an API is well-documented, it's much easier for developers to use and understand. This in turn makes it more likely to be used properly and adopted by others.

In short, API validation is essential to the success of any API. If you're not doing it, you're setting yourself up for problems down the road. So do yourself a favor and make sure your APIs are properly validated before you release them into the wild!

Top comments (5)

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited

Hi Anna!
I understood the types of tests covered in the first block are manual tests, unit tests and integration tests and lately you talk about postman only, now I've been wanting to know which other tools do you use to perform unit testing and integration testing (a.k.a. tests E2E)

For me:

  • Postman is used during the development process of any endpoint.
  • The other one is driven by unit tests that live inside the code, i.e. Jest.
  • And the last one is driven by tests E2E (i.e. Playwright) that can run manually (in bulk or not), or by adding them in the pipeline of the project.

In the last block, you talk about Postman and SoapUI. PLEASE don't code SOAP interfaces, we're in 2022 I beg you πŸ˜…

Better pick REST + GraphQL if you want to provide more than a single option 😁

Collapse
 
andre_adpc profile image
Andre Du Plessis

Joel, don't throw that old brick of SOAP away just yet 😁.

When there is a requirement to link as securely as possible to File and Data servers via RDS and Windows' Active Directory, for example. It is very well-used still today.

Especially in the banking and payment gateway industry as well. All your banking-app authentication comms gets "soaped up" quite well before anyone or thing is allowed in-or outside :-)

SOAP is the oldest API protocol yes (1990-ish), but also the most secure of all six prominent protocols used these days.

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡

Damn at the time of writting that I forgot about the WS-Security in SOAP hahaha we need something more dev-friendly 😭

Thread Thread
 
andre_adpc profile image
Andre Du Plessis

Friendly is always good, Joel, I agree! 😭 Who knows, maybe some guy like Linus Tovalds is already hammering away on a solid solution from the server core up, using Zero-knowledge Proof encryption methods? One can hope, or one can try and do I guess.

Collapse
 
youssefmic profile image
Youssef-mic

Another tool to consider is Insomnia I use it and it’s amazing!