APIRequestContext
Playwright\API\APIRequestContextInterface
Executes HTTP requests through Playwright. Use a context to prepare application state without driving a browser page. Request options apply to a single call unless configured when it is created.
Methods
get()
APIResponseInterfaceSends a GET request. Resolves relative URLs against the configured base URL. Returns a response object even for unsuccessful HTTP status codes.
function get(string $url, array $options = []): APIResponseInterface
post()
APIResponseInterfaceSends a POST request. Request options can provide data, form fields, headers, and timeouts. Returns a response object even for unsuccessful HTTP status codes.
function post(string $url, array $options = []): APIResponseInterface
put()
APIResponseInterfaceSends a PUT request. Request options can provide data, form fields, headers, and timeouts. Returns a response object even for unsuccessful HTTP status codes.
function put(string $url, array $options = []): APIResponseInterface
patch()
APIResponseInterfaceSends a PATCH request. Request options can provide data, form fields, headers, and timeouts. Returns a response object even for unsuccessful HTTP status codes.
function patch(string $url, array $options = []): APIResponseInterface
delete()
APIResponseInterfaceSends a DELETE request. Request options can provide headers, query parameters, and timeouts. Returns a response object even for unsuccessful HTTP status codes.
function delete(string $url, array $options = []): APIResponseInterface
head()
APIResponseInterfaceSends a HEAD request. Request options can provide headers, query parameters, and timeouts. Returns a response object without downloading a response body.
function head(string $url, array $options = []): APIResponseInterface
fetch()
APIResponseInterfaceSends an HTTP request. The method, headers, body, and retry behavior are provided in options. Relative URLs resolve against the base URL configured for this context.
function fetch(string $urlOrRequest, array $options = []): APIResponseInterface
storageState()
arrayReturns the context storage state. The returned cookies and origins can initialize another API or browser context. Pass a path to save the serialized state for later reuse.
function storageState(?string $path = null): array
tracing()
TracingInterfaceTracing controls for this context. A context obtained from a browser context traces into that same browser context.
function tracing(): TracingInterface
dispose()
voidReleases the request context. Cancels pending work owned by this context on the Playwright server. Do not use the context for further requests after disposal.
function dispose(): void