see ApiBaseOptions
Protected ReadonlybaseProtected ReadonlybodyProtected ReadonlydebugProtected ReadonlyheadersProtectedbodyWraps a payload as data (JSON) or form, depending on the client's bodyType.
Optionaldata?: anyAllows to set post data of the request. If the data parameter is an object, it will be serialized to json string
and content-type header will be set to application/json if not explicitly set. Otherwise the content-type
header will be set to application/octet-stream if not explicitly set.
OptionalfailOnStatusCode?: booleanWhether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
Optionalform?: FormData | { [key: string]: string | number | boolean }Provides an object that will be serialized as html form using application/x-www-form-urlencoded encoding and sent
as this request body. If this parameter is specified content-type header will be set to
application/x-www-form-urlencoded unless explicitly provided.
Optionalheaders?: { [key: string]: string }Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
OptionalignoreHTTPSErrors?: booleanWhether to ignore HTTPS errors when sending network requests. Defaults to false.
OptionalmaxRedirects?: numberMaximum number of request redirects that will be followed automatically. An error will be thrown if the number is
exceeded. Defaults to 20. Pass 0 to not follow redirects.
OptionalmaxRetries?: numberMaximum number of times network errors should be retried. Currently only ECONNRESET error is retried. Does not
retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to 0 - no retries.
Optionalmethod?: stringOptionalmultipart?: Provides an object that will be serialized as html form using multipart/form-data encoding and sent as this
request body. If this parameter is specified content-type header will be set to multipart/form-data unless
explicitly provided. File values can be passed either as
fs.ReadStream or as file-like object containing file
name, mime-type and its content.
Optionalparams?: string | URLSearchParams | { [key: string]: string | number | boolean }Query parameters to be sent with the URL.
Optionalsignal?: AbortSignalAllows to cancel the operation using an
AbortSignal. If the signal is aborted, the
operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
which can be changed using
browserContext.setDefaultTimeout(timeout)
or page.setDefaultTimeout(timeout); pass
timeout: 0 to disable the timeout entirely.
Optionaltimeout?: numberRequest timeout in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
Sends a DELETE request.
the response body's type
relative to the base URL
Optionalpayload: unknown
request body, encoded as the client's bodyType
Releases the request context. Optional: call it from an afterAll if a worker creates many clients.
Sends a GET request.
the response body's type
relative to the base URL
Optionalparams: string | URLSearchParams | { [key: string]: string | number | boolean }
query string parameters
ProtectedlogLogs a labelled value when debug is on.
Sends a PATCH request.
the response body's type
relative to the base URL
Optionalpayload: unknown
request body, encoded as the client's bodyType
Sends a POST request.
the response body's type
relative to the base URL
Optionalpayload: unknown
request body, encoded as the client's bodyType
Sends a PUT request.
the response body's type
relative to the base URL
Optionalpayload: unknown
request body, encoded as the client's bodyType
ProtectedrequestThe client's request context: created on first use, then reused for every request in the worker.
ProtectedresolveThe headers for the next request, calling the headers function if one was given.
Sends a request. The caller asserts on the response, usually through getBody or
errorCheck, which also dispose it.
the response body's type
HTTP method, any case
relative to the base URL
Playwright fetch options; their headers are merged over the client's
Optionaldata?: anyAllows to set post data of the request. If the data parameter is an object, it will be serialized to json string
and content-type header will be set to application/json if not explicitly set. Otherwise the content-type
header will be set to application/octet-stream if not explicitly set.
OptionalfailOnStatusCode?: booleanWhether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
Optionalform?: FormData | { [key: string]: string | number | boolean }Provides an object that will be serialized as html form using application/x-www-form-urlencoded encoding and sent
as this request body. If this parameter is specified content-type header will be set to
application/x-www-form-urlencoded unless explicitly provided.
Optionalheaders?: { [key: string]: string }Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
OptionalignoreHTTPSErrors?: booleanWhether to ignore HTTPS errors when sending network requests. Defaults to false.
OptionalmaxRedirects?: numberMaximum number of request redirects that will be followed automatically. An error will be thrown if the number is
exceeded. Defaults to 20. Pass 0 to not follow redirects.
OptionalmaxRetries?: numberMaximum number of times network errors should be retried. Currently only ECONNRESET error is retried. Does not
retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to 0 - no retries.
Optionalmethod?: stringOptionalmultipart?: Provides an object that will be serialized as html form using multipart/form-data encoding and sent as this
request body. If this parameter is specified content-type header will be set to multipart/form-data unless
explicitly provided. File values can be passed either as
fs.ReadStream or as file-like object containing file
name, mime-type and its content.
Optionalparams?: string | URLSearchParams | { [key: string]: string | number | boolean }Query parameters to be sent with the URL.
Optionalsignal?: AbortSignalAllows to cancel the operation using an
AbortSignal. If the signal is aborted, the
operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
which can be changed using
browserContext.setDefaultTimeout(timeout)
or page.setDefaultTimeout(timeout); pass
timeout: 0 to disable the timeout entirely.
Optionaltimeout?: numberRequest timeout in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
the response, typed as APIResponse<T>
Builds the full URL for a path.
relative to the base URL; a leading slash is ignored
e.g. "https://example.com/api/products" for "products"
Base class for one-client-per-API-area. Subclass it, add one method per endpoint, and export a single instance.
Name each response body's type in the method (
this.get<ProductList>(...)), as Playwright's own request methods allow.getBody,pollUntilandresponse.json()then return that type without the spec repeating it.Example