> For the complete documentation index, see [llms.txt](https://qatesting.gitbook.io/qa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qatesting.gitbook.io/qa/api-testing/api-tools/rest-assured.md).

# REST Assured

Rest Assured is an <mark style="background-color:yellow;">**open-source Java library**</mark> that makes testing RESTful web services simple. It allows you to:

* Validate response status codes
* Validate headers
* Validate response body (JSON, XML)
* Perform authentication
* Parameterize requests

## Some main features of Rest Assured:

* Request building - Easily build HTTP requests using a Domain Specific Language rather than manual header/body setup. Saves time.
* Response validation - Inspect response status, body, headers and validate against expectations. Ensures API works as intended.
* Parameterization - Externalize test data and define parameters for data-driven, maintainable tests across browsers in parallel.
* Pre/post request specification - Define authentication, common headers etc. once to avoid duplication in each test case.
* Response extraction using JSON path - Query and extract specific response values for assertions or for use in next request. Handy!
* Assertions library - Validate responses using Hamcrest or JUnit matchers for clear pass/fail results in a readable manner.
* Logging filter - Log request/response details across tests for easy debugging. Like recording an experiment!
* Pretty printing - Print response in pretty/formatted JSON or XML rather than one long string. Makes visualizing responses simpler.
* Interactive documentation - Automatically generate API documentation from tests. Great for code documentation and collaboration.
* Test runners - Integrate tests with popular runners like JUnit to execute automated regression suites on multiple browsers or servers in parallel.

## Postman vs Rest Assured ⚖️

<table data-full-width="true"><thead><tr><th>Postman</th><th>Rest Assured</th></tr></thead><tbody><tr><td>User interface</td><td>Code based</td></tr><tr><td>Manual + automation</td><td>Automation only</td></tr><tr><td>Language agnostic</td><td>Java specific</td></tr><tr><td>Broad API testing</td><td>Focused on REST</td></tr></tbody></table>

## Using Postman and Rest Assured 🤝

They can be used together:

* Postman to prototype APIs 🚀
* Rest Assured to automate tests ⚡️
* Postman provides UI, Rest Assured provides a programmatic interface 💻➕📲
* Combined they streamline API testing 🏃‍♂️


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://qatesting.gitbook.io/qa/api-testing/api-tools/rest-assured.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
