---
title: Axios
description: Learn how to integrate Allure with Axios to capture detailed HTTP request and response data in your test reports.
---

# Getting started with Allure Axios

[![Allure Axios npm latest version](https://img.shields.io/npm/v/allure-axios?style=flat "Allure Axios npm latest version")](https://www.npmjs.com/package/allure-axios)

Capture [Axios](https://axios-http.com/) HTTP requests and responses as attachments in your [Allure Report](https://allurereport.org/docs/) test reports.

Allure Axios is compatible with any Allure JS framework integration, including [Allure Vitest](/docs/vitest/), [Allure Jest](/docs/jest/), [Allure Playwright](/docs/playwright/), [Allure Mocha](/docs/mocha/), and others.

To enable the integration in your project:

1. Make sure you have an Allure integration set up for the test framework you use.

   See the instructions in the integration's documentation in [Frameworks](/docs/frameworks/).

1. Install `allure-axios`.

   **npm:**
   ```bash
   npm install --save-dev allure-axios
   ```

   **yarn:**
   ```bash
   yarn add --dev allure-axios
   ```

   **pnpm:**
   ```bash
   pnpm install --dev allure-axios
   ```

1. For every Axios instance used in your tests, call `instrumentAxios()` to start capturing requests.

   `instrumentAxios()` installs interceptors on the instance and returns a cleanup function. Call the cleanup function when you no longer want requests captured — typically in `afterEach` or `afterAll`.

   The example below shows usage in a Vitest test suite.

   ```ts
   import { instrumentAxios } from "allure-axios";
   import axios, { type AxiosInstance } from "axios";
   import { afterEach, beforeEach, describe, expect, it } from "vitest";

   describe("Orders API", () => {
     let client: AxiosInstance;
     let restore: () => void;

     beforeEach(() => {
       client = axios.create({ baseURL: "https://api.example.com" });
       restore = instrumentAxios(client);
     });

     afterEach(() => {
       restore();
     });

     it("creates an order", async () => {
       const response = await client.post("/orders", { item: "book", qty: 1 });
       expect(response.status).toBe(201);
     });
   });
   ```

   Every HTTP request made through `client` will be added to the test result as an attachment, wrapped in a step of the same name. The attachment captures the full exchange in one place: the request method, URL, headers, query parameters, cookies, and body; the response status, headers, cookies (including attributes such as `Path`, `Domain`, `Expires`, `Secure`, `HttpOnly`, and `SameSite`), and body; the exchange start and stop timestamps; and, when the request fails, the error name and message.

   Info:
   To prevent secrets from leaking into reports, certain values are redacted by default — all cookies, any header or query parameter whose name suggests it contains a credential, and any URL-encoded form field whose name does the same. See [Allure Axios configuration](/docs/axios-configuration/) for the full list of defaults and how to customize the redaction rules.

1. Run your tests and generate a test report the same way as you would normally.
