---
source: https://iinventedlight.com/library/notes/playwright-api-testing.md
title: "APIRequestContext sends HTTP requests from Playwright without loading a page"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Playwright docs); Apache-2.0 (microsoft/playwright (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Playwright docs, API testing, Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation; microsoft/playwright (GitHub), api-testing-js.md (Playwright source docs), Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-17
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-17
as_of: 2026-11-17
confidence: medium
untested: "Not reproduced (2026-11-17). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Playwright API testing"
tags: [playwright, APIRequestContext, request-fixture, api-testing, baseURL]
client: Librarian
sources:
  - id: S1
    title: "API testing"
    publisher: Playwright docs
    url: https://playwright.dev/docs/api-testing
    accessed: 2026-11-17
    license: "Apache-2.0"
  - id: S2
    title: "api-testing-js.md (Playwright source docs)"
    publisher: microsoft/playwright (GitHub)
    url: https://github.com/microsoft/playwright/blob/main/docs/src/api-testing-js.md
    accessed: 2026-11-17
    license: "Apache-2.0"
---
# APIRequestContext sends HTTP requests from Playwright without loading a page
**Answer:** Playwright can call a server's HTTP API directly from Node.js, without loading a page or running JavaScript in a browser. `APIRequestContext` is the object that sends those requests. Use it to test the API itself, to set up server state before a UI test, or to check post-conditions after browser actions.

## The request fixture

Playwright Test ships a `request` fixture that already honors config such as `baseURL` and `extraHTTPHeaders`. In a test you can `request.post(...)` or `request.get(...)` and then assert with `ok()` or `json()`. Set `baseURL` and `extraHTTPHeaders` in the configuration file, or with `test.use()` in the test file itself.

If tests run behind a proxy, set `use.proxy` in the config and the `request` fixture picks it up.

## See also

- [playwright-locators](https://iinventedlight.com/library/notes/playwright-locators/)
- [javascript-fetch](https://iinventedlight.com/library/notes/javascript-fetch/)
- [playwright-storage-state](https://iinventedlight.com/library/notes/playwright-storage-state/)
- [playwright-headless-tests](https://iinventedlight.com/library/notes/playwright-headless-tests/)

## Claims

- id: C1
  claim: APIRequestContext can send HTTP requests over the network.
  source: S1
  evidence: "can send all kinds of HTTP(S) requests over network"

- id: C2
  claim: You can send requests from Node.js without loading a page.
  source: S1
  evidence: "without loading a page and running js code in it"

- id: C3
  claim: The request fixture honors baseURL and extraHTTPHeaders from config.
  source: S2
  evidence: "respects configuration options like `baseURL` or `extraHTTPHeaders`"

- id: C4
  claim: The request fixture is ready to send requests in a test.
  source: S2
  evidence: "ready to send some requests"

## Sources

- [S1] API testing. Playwright docs. https://playwright.dev/docs/api-testing . License: Apache-2.0. Accessed 2026-11-17.

- [S2] api-testing-js.md (Playwright source docs). microsoft/playwright (GitHub). https://github.com/microsoft/playwright/blob/main/docs/src/api-testing-js.md . License: Apache-2.0. Accessed 2026-11-17.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Playwright docs, API testing, Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation; microsoft/playwright (GitHub), api-testing-js.md (Playwright source docs), Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
