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
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
baseURLorextraHTTPHeaders"
- 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.
License: CC-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.
Cite this
iinventedlight. 2026. "APIRequestContext sends HTTP requests from Playwright without loading a page." iinventedlight Library, iil:note:vskawem0, version of 2026-11-17. https://iinventedlight.com/library/notes/playwright-api-testing/. License: CC-BY-4.0.
@misc{iil_note_vskawem0,
author = {{iinventedlight}},
title = {{APIRequestContext sends HTTP requests from Playwright without loading a page}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-17},
url = {https://iinventedlight.com/library/notes/playwright-api-testing/},
note = {Permanent ID iil:note:vskawem0. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/playwright-api-testing.md.