Introduction to API Automation with Rest Assured

Setup and Configuration

 

Learning Outcome

4

Set up a Rest Assured project with Java 

 

3

2

1

Understand API automation in modern testing

Learn Rest Assured basics and usage

See how it simplifies API testing

What is API Testing?

API Testing is a type of software testing that verifies whether Application Programming Interfaces (APIs) are working correctly.
 

It focuses on validating the requests, responses, data accuracy, and business logic between different software systems without interacting with the user interface.

In simple terms, API testing checks whether systems communicate with each other properly and return the expected results.

 

Package Delivery Service

A request is sent to the warehouse

The warehouse processes the request

The package is delivered to you

In API communication

 

In Software Testing

Why API Automation is Important

Automating API tests helps teams validate backend functionality quickly and efficiently.

Since APIs operate behind the UI, testing them early helps identify issues before they affect the user interface.

 

Benefits of API automation include:

 

  • Faster execution compared to manual testing
     

  • Early detection of defects in the backend layer
     

  • Easy integration with CI/CD pipelines
     

  • Ability to test large numbers of API scenarios repeatedly

In the previous section, we understood what API testing is and why it is important.

While tools like Postman or Swagger help us manually send requests and validate responses, manual testing can become time-consuming and repetitive when the number of APIs and test scenarios increases.

In real-world projects, APIs need to be tested frequently, repeatedly, and often as part of automated pipelines.

This is where API automation tools become essential.

 

This is where API automation tools become essential
One of the most widely used tools for automating REST API testing in Java is Rest Assured.

Manual vs Automation API Testing

Setup and Configuration for REST Assured

(Public API)

What is REST Assured ??

REST Assured is a Java-based API automation testing framework designed specifically for testing RESTful APIs

Built on top of Java HTTP clients like Apache HttpClient, it integrates with popular testing frameworks.

Write tests that are easy to understand and maintain.

Validate response data in various formats with ease

Versatile framework for multiple testing scenarios

Why Use REST Assured?

Understanding the HTTP Protocol

Client sends request to server

Client

Server

Server returns status code, headers, and data

Server processes the request

Request

Response

Processing

Now, let’s understand the full API flow.

 Request

A Request is a message sent by the client to the server asking for something.

 

Example:

Why JSON and XML

When a client sends a request to a server, the server responds with data.
That data must be in a structured format so both systems can understand it.

JSON (JavaScript Object Notation)

🔹 Lightweight
🔹 Easy to read
🔹 Mostly used in modern REST APIs

Why JSON is popular

  • Less bulky

  • Faster to parse

  • Human-readable

  • Works very well with web and mobile apps

🔹 Tag-based structure

🔹 Older but still widely used
🔹 Common in SOAP APIs and enterprise systems

XML (Extensible Markup Language)

Characteristics:

  • Uses opening and closing tags

  • More verbose (larger size)

  • Strict structure rules

     

Server

A Server is a system that:

  • Receives the request

  • Processes the logic

  • Validates authentication

  • Accesses database if needed

  • Prepares response

  • Sends response back

Server listens → Processes → Responds

Response 

A Response is what the server sends back to the client.

  • Status Code (200, 404, 500, etc.)

  • Headers

  • Body (Data in JSON or XML)

  • Error message (if something failed)

 It contains:

HTTP Methods

 

  • Used to retrieve data
     

  • Does NOT modify data
     

  • Data is visible in URL
     

  • Safe and idempotent

GET Method

HTTP Methods

POST Method

  • Used to create new data
     

  • Data is sent in request body
     

  • Not idempotent

HTTP Methods

PUT Method

  • Used to update entire resource

  • Replaces old data completely

  • Idempotent

HTTP Methods

PATCH Method

  • Used to partially update data
     

  • Updates only specific fields
     

  • Idempotent (generally)

HTTP Methods

Delete Method

  • Used to remove data
     

  • Idempotent

HTTP Status Code Categories

What Do We Validate in API Testing?

  • Correct data
     

  • Mandatory fields
     

  • Data type
     

  • Status code
     

  • Schema

Functional

  • Performance
     

  • Security
     

  • Reliability
     

  • Load

Non-functional

 

  • Invalid input
     

  • Missing fields
     

  • Wrong data type
     

  • Unauthorized access

  • Expired token

Negative Testing

Important concepts

Types of Authentication

Username + Password sent with request

Token sent in header
Authorization: Bearer <token>

 

 Unique key given to access APIs

Login using Google / Facebook

Secure token containing user data & expiry

Performance & Security Testing in API Testing

  • Response time

  • Load

  • Concurrency

  • Stress testing

     

Performance

  • Injection

  • Broken authentication

  • Data exposure

  • Rate limiting

  • Concurrent user simulation

  • Throughput

     

Security

  • JMeter

  • k6

Tools

Summary

5

Build strong branding

4

Use different marketing channels

3

Target the right audience

2

Create and communicate value

1

Understand customer needs

Quiz

API testing helps detect issues:

A. Late in production

B. Only UI defect

C. Early in development

D. Only performance defects

Quiz-Answer

API testing helps detect issues:

A. Late in production

B. Only UI defect

C. Early in development

D. Only performance defects

Copy of HTTP Methods, Headers, Params

By Content ITV

Copy of HTTP Methods, Headers, Params

  • 7