# `Playwright.APIRequestContext`
[🔗](https://github.com/ftes/playwright_ex/blob/v1.65.0-rc.3/lib/playwright/api/api_request_context.ex#L7)

This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
environment or the service to your e2e test.

Each Playwright browser context has an associated [`APIRequestContext`](`Playwright.APIRequestContext`), accessible via
`Playwright.BrowserContext.request/1` or `Playwright.Page.request/1` (these return the

**same instance** — `Playwright.Page.request/1` is a shortcut for `Playwright.BrowserContext.request/1` of `Playwright.Page.context/1`).
You can also create a standalone, isolated instance with `Playwright.APIRequest.new_context/2`.

**Cookie management**

The [`APIRequestContext`](`Playwright.APIRequestContext`) returned by `Playwright.BrowserContext.request/1` and

`Playwright.Page.request/1` uses the same cookie jar as its [`BrowserContext`](`Playwright.BrowserContext`):

If you want API requests that do **not** share cookies with the browser, create an
isolated context via `Playwright.APIRequest.new_context/2`. Such [`APIRequestContext`](`Playwright.APIRequestContext`)
object will have its own isolated cookie storage.

*Since Playwright 1.16.*

The examples alias the modules they use (`alias Playwright.{Locator, Page}`).

# `clear_cookies_options`

```elixir
@type clear_cookies_options() ::
  [
    domain: String.t() | Regex.t() | Playwright.RegExp.t(),
    name: String.t() | Regex.t() | Playwright.RegExp.t(),
    path: String.t() | Regex.t() | Playwright.RegExp.t()
  ]
  | %{
      optional(:domain) =&gt; String.t() | Regex.t() | Playwright.RegExp.t(),
      optional(:name) =&gt; String.t() | Regex.t() | Playwright.RegExp.t(),
      optional(:path) =&gt; String.t() | Regex.t() | Playwright.RegExp.t()
    }
```

Options of `clear_cookies/2`, see its docs.

# `delete_options`

```elixir
@type delete_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `delete/3`, see its docs.

# `dispose_options`

```elixir
@type dispose_options() ::
  [{:reason, String.t()}] | %{optional(:reason) =&gt; String.t()}
```

Options of `dispose/2`, see its docs.

# `fetch_options`

```elixir
@type fetch_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    method: String.t(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:method) =&gt; String.t(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `fetch/3`, see its docs.

# `get_options`

```elixir
@type get_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `get/3`, see its docs.

# `head_options`

```elixir
@type head_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `head/3`, see its docs.

# `patch_options`

```elixir
@type patch_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `patch/3`, see its docs.

# `post_options`

```elixir
@type post_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `post/3`, see its docs.

# `put_options`

```elixir
@type put_options() ::
  [
    data: String.t() | {:binary, binary()} | term(),
    fail_on_status_code: boolean(),
    form: %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
    headers: %{optional(String.t()) =&gt; String.t()},
    ignore_https_errors: boolean(),
    max_redirects: integer(),
    max_retries: integer(),
    multipart:
      term()
      | %{
          optional(String.t()) =&gt;
            String.t()
            | number()
            | boolean()
            | term()
            | %{name: String.t(), mimeType: String.t(), buffer: binary()}
        },
    params:
      %{optional(String.t()) =&gt; String.t() | number() | boolean()}
      | term()
      | String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:data) =&gt; String.t() | {:binary, binary()} | term(),
      optional(:fail_on_status_code) =&gt; boolean(),
      optional(:form) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()} | term(),
      optional(:headers) =&gt; %{optional(String.t()) =&gt; String.t()},
      optional(:ignore_https_errors) =&gt; boolean(),
      optional(:max_redirects) =&gt; integer(),
      optional(:max_retries) =&gt; integer(),
      optional(:multipart) =&gt;
        term()
        | %{
            optional(String.t()) =&gt;
              String.t()
              | number()
              | boolean()
              | term()
              | %{name: String.t(), mimeType: String.t(), buffer: binary()}
          },
      optional(:params) =&gt;
        %{optional(String.t()) =&gt; String.t() | number() | boolean()}
        | term()
        | String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `put/3`, see its docs.

# `storage_state_options`

```elixir
@type storage_state_options() ::
  [indexed_db: boolean(), opfs: boolean(), path: String.t()]
  | %{
      optional(:indexed_db) =&gt; boolean(),
      optional(:opfs) =&gt; boolean(),
      optional(:path) =&gt; String.t()
    }
```

Options of `storage_state/2`, see its docs.

# `t`

```elixir
@type t() :: %Playwright.APIRequestContext{
  conn: term(),
  guid: term(),
  initializer: term(),
  table: term(),
  type: term()
}
```

A `APIRequestContext` handle. Compare handles with `==`, their fields are internal.

# `add_cookies`

```elixir
@spec add_cookies(t(), [map()]) :: :ok | {:error, Playwright.error()}
```

Adds cookies into this request context. They will be sent with matching subsequent requests. For `Playwright.BrowserContext.request/1`
and `Playwright.Page.request/1`, this is equivalent to calling `Playwright.BrowserContext.add_cookies/2` on the corresponding browser context.

**Usage**

```elixir
APIRequestContext.add_cookies!(request, [cookie_object1, cookie_object2])
```

*Since Playwright 1.64.*

## Arguments

* `cookies`
  * `:name`
  * `:value`
  * `:url` - Either `url` or both `domain` and `path` are required. Optional.
  * `:domain` - For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". Either `url` or both `domain` and `path` are required. Optional.
  * `:path` - Either `url` or both `domain` and `path` are required. Optional.
  * `:expires` - Unix time in seconds. Optional.
  * `:httpOnly` - Optional.
  * `:secure` - Optional.
  * `:sameSite` - Optional.
  * `:partitionKey` - For partitioned third-party cookies (aka [CHIPS](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies)), the partition key. Optional.

# `add_cookies!`

```elixir
@spec add_cookies!(t(), [map()]) :: :ok
```

Like `add_cookies/2`, but returns the value and raises on error.

# `clear_cookies`

```elixir
@spec clear_cookies(t(), clear_cookies_options()) ::
  :ok | {:error, Playwright.error()}
```

Removes cookies from this request context. Accepts optional filter. For `Playwright.BrowserContext.request/1`
and `Playwright.Page.request/1`, this is equivalent to calling `Playwright.BrowserContext.clear_cookies/2` on the corresponding browser context.

**Usage**

```elixir
APIRequestContext.clear_cookies!(request)
APIRequestContext.clear_cookies!(request, name: "session-id")
APIRequestContext.clear_cookies!(request, domain: "my-origin.com")
APIRequestContext.clear_cookies!(request, domain: ~r/.*my-origin\.com/)
APIRequestContext.clear_cookies!(request, path: "/api/v1")
APIRequestContext.clear_cookies!(request, name: "session-id", domain: "my-origin.com")
```

*Since Playwright 1.64.*

## Options

* `:domain` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - Only removes cookies with the given domain.
* `:name` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - Only removes cookies with the given name.
* `:path` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - Only removes cookies with the given path.

# `clear_cookies!`

```elixir
@spec clear_cookies!(t(), clear_cookies_options()) :: :ok
```

Like `clear_cookies/2`, but returns the value and raises on error.

# `cookies`

```elixir
@spec cookies(t(), String.t() | [String.t()] | nil) ::
  {:ok,
   [
     %{
       :name =&gt; String.t(),
       :value =&gt; String.t(),
       :domain =&gt; String.t(),
       :path =&gt; String.t(),
       :expires =&gt; number(),
       :httpOnly =&gt; boolean(),
       :secure =&gt; boolean(),
       :sameSite =&gt; String.t(),
       optional(:partitionKey) =&gt; String.t()
     }
   ]}
  | {:error, Playwright.error()}
```

If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
are returned. For `Playwright.BrowserContext.request/1` and `Playwright.Page.request/1`, this is equivalent to calling
`Playwright.BrowserContext.cookies/2` on the corresponding browser context.

*Since Playwright 1.64.*

## Arguments

* `urls` - Optional list of URLs.

# `cookies!`

```elixir
@spec cookies!(t(), String.t() | [String.t()] | nil) :: [
  %{
    :name =&gt; String.t(),
    :value =&gt; String.t(),
    :domain =&gt; String.t(),
    :path =&gt; String.t(),
    :expires =&gt; number(),
    :httpOnly =&gt; boolean(),
    :secure =&gt; boolean(),
    :sameSite =&gt; String.t(),
    optional(:partitionKey) =&gt; String.t()
  }
]
```

Like `cookies/2`, but returns the value and raises on error.

# `delete`

```elixir
@spec delete(t(), String.t(), delete_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

*Since Playwright 1.16.*

## Arguments

* `url` - Target URL.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - *Since Playwright 1.17.* Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - *Since Playwright 1.17.* 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:multipart` (`t:term/0` | `t:map/0`) - *Since Playwright 1.17.* 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `delete!`

```elixir
@spec delete!(t(), String.t(), delete_options()) :: Playwright.APIResponse.t()
```

Like `delete/3`, but returns the value and raises on error.

# `dispose`

```elixir
@spec dispose(t(), dispose_options()) :: :ok | {:error, Playwright.error()}
```

All responses returned by `Playwright.APIRequestContext.get/3` and similar methods are stored in the memory, so that you can later call `Playwright.APIResponse.body/1`.This method discards all its resources, calling any method on disposed [`APIRequestContext`](`Playwright.APIRequestContext`) will fail.

*Since Playwright 1.16.*

## Options

* `:reason` (`t:String.t/0`) - *Since Playwright 1.45.* The reason to be reported to the operations interrupted by the context disposal.

# `dispose!`

```elixir
@spec dispose!(t(), dispose_options()) :: :ok
```

Like `dispose/2`, but returns the value and raises on error.

# `fetch`

```elixir
@spec fetch(t(), String.t() | Playwright.Request.t(), fetch_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

**Usage**

JSON objects can be passed directly to the request:

```elixir
APIRequestContext.fetch!(request, "https://example.com/api/createBook",
  method: "post",
  data: %{title: "Book Title", author: "John Doe"}
)
```

The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data` encoding, by specifiying the `:multipart` parameter:

```elixir
form = [
  name: "John",
  name: "Doe",
  # Send two file fields with the same name.
  file: %{name: "f1.js", mimeType: "text/javascript", buffer: "console.log(2024);"},
  file: %{name: "f2.txt", mimeType: "text/plain", buffer: "hello"}
]

APIRequestContext.fetch!(request, "https://example.com/api/uploadForm", multipart: form)
```

*Since Playwright 1.16.*

## Arguments

* `url_or_request` - Target URL or Request to get all parameters from.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:method` (`t:String.t/0`) - If set changes the fetch method (e.g. [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) or
  [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)). If not specified, GET method is used.
* `:multipart` (`t:term/0` | `t:map/0`) - 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `fetch!`

```elixir
@spec fetch!(t(), String.t() | Playwright.Request.t(), fetch_options()) ::
  Playwright.APIResponse.t()
```

Like `fetch/3`, but returns the value and raises on error.

# `get`

```elixir
@spec get(t(), String.t(), get_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

**Usage**

Request parameters can be configured with `:params` option, they will be serialized into the URL search parameters:

```elixir
# Passing params as map
APIRequestContext.get!(request, "https://example.com/api/getText", params: %{"isbn" => "1234", "page" => 23})

# Passing params as keyword list (URLSearchParams, names may repeat)
search_params = [isbn: "1234", page: 23, page: 24]
APIRequestContext.get!(request, "https://example.com/api/getText", params: search_params)

# Passing params as string
query_string = "isbn=1234&page=23&page=24"
APIRequestContext.get!(request, "https://example.com/api/getText", params: query_string)
```

*Since Playwright 1.16.*

## Arguments

* `url` - Target URL.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - *Since Playwright 1.26.* Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - *Since Playwright 1.26.* 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:multipart` (`t:term/0` | `t:map/0`) - *Since Playwright 1.26.* 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `get!`

```elixir
@spec get!(t(), String.t(), get_options()) :: Playwright.APIResponse.t()
```

Like `get/3`, but returns the value and raises on error.

# `head`

```elixir
@spec head(t(), String.t(), head_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

*Since Playwright 1.16.*

## Arguments

* `url` - Target URL.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - *Since Playwright 1.26.* Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - *Since Playwright 1.26.* 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:multipart` (`t:term/0` | `t:map/0`) - *Since Playwright 1.26.* 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `head!`

```elixir
@spec head!(t(), String.t(), head_options()) :: Playwright.APIResponse.t()
```

Like `head/3`, but returns the value and raises on error.

# `patch`

```elixir
@spec patch(t(), String.t(), patch_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

*Since Playwright 1.16.*

## Arguments

* `url` - Target URL.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:multipart` (`t:term/0` | `t:map/0`) - 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `patch!`

```elixir
@spec patch!(t(), String.t(), patch_options()) :: Playwright.APIResponse.t()
```

Like `patch/3`, but returns the value and raises on error.

# `post`

```elixir
@spec post(t(), String.t(), post_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

**Usage**

JSON objects can be passed directly to the request:

```elixir
APIRequestContext.post!(request, "https://example.com/api/createBook",
  data: %{title: "Book Title", author: "John Doe"}
)
```

To send form data to the server use `:form` option. Its value will be encoded into the request body with `application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):

```elixir
APIRequestContext.post!(request, "https://example.com/api/findBook",
  form: %{title: "Book Title", author: "John Doe"}
)
```

The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data` encoding. Use `FormData` to construct request body and pass it to the request as `:multipart` parameter:

```elixir
form = [
  name: "John",
  name: "Doe",
  # Send two file fields with the same name.
  file: %{name: "f1.js", mimeType: "text/javascript", buffer: "console.log(2024);"},
  file: %{name: "f2.txt", mimeType: "text/plain", buffer: "hello"}
]

APIRequestContext.post!(request, "https://example.com/api/uploadForm", multipart: form)
```

*Since Playwright 1.16.*

## Arguments

* `url` - Target URL.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:multipart` (`t:term/0` | `t:map/0`) - 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `post!`

```elixir
@spec post!(t(), String.t(), post_options()) :: Playwright.APIResponse.t()
```

Like `post/3`, but returns the value and raises on error.

# `put`

```elixir
@spec put(t(), String.t(), put_options()) ::
  {:ok, Playwright.APIResponse.t()} | {:error, Playwright.error()}
```

Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.

*Since Playwright 1.16.*

## Arguments

* `url` - Target URL.

## Options

* `:data` (`t:String.t/0` | `{:binary, binary()}` | `t:term/0`) - Allows 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.
* `:fail_on_status_code` (`t:boolean/0`) - Whether to fail on response codes other than 2xx and 3xx. By default response object is returned
  for all status codes.
* `:form` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0`) - 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. Use `FormData` to send multiple values for the same field.
* `:headers` (`%{optional(String.t()) => String.t()}`) - Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
* `:ignore_https_errors` (`t:boolean/0`) - Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
* `:max_redirects` (`t:integer/0`) - *Since Playwright 1.26.* Maximum number of request redirects that will be followed automatically. The call fails if the number is exceeded.
  Defaults to `20`. Pass `0` to not follow redirects.
* `:max_retries` (`t:integer/0`) - *Since Playwright 1.46.* Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. The call fails if the limit is exceeded. Defaults to `0` - no retries.
* `:multipart` (`t:term/0` | `t:map/0`) - 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`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
  or as file-like object containing file name, mime-type and its content.
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content
* `:params` (`%{optional(String.t()) => String.t() | number() | boolean()}` | `t:term/0` | `t:String.t/0`) - Query parameters to be sent with the URL.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `put!`

```elixir
@spec put!(t(), String.t(), put_options()) :: Playwright.APIResponse.t()
```

Like `put/3`, but returns the value and raises on error.

# `storage_state`

```elixir
@spec storage_state(t(), storage_state_options()) ::
  {:ok,
   %{
     :cookies =&gt; [
       %{
         :name =&gt; String.t(),
         :value =&gt; String.t(),
         :domain =&gt; String.t(),
         :path =&gt; String.t(),
         :expires =&gt; number(),
         :httpOnly =&gt; boolean(),
         :secure =&gt; boolean(),
         :sameSite =&gt; String.t(),
         optional(atom()) =&gt; term()
       }
     ],
     :origins =&gt; [
       %{
         :origin =&gt; String.t(),
         :localStorage =&gt; [
           %{
             :name =&gt; String.t(),
             :value =&gt; String.t(),
             optional(atom()) =&gt; term()
           }
         ],
         optional(atom()) =&gt; term()
       }
     ],
     optional(atom()) =&gt; term()
   }}
  | {:error, Playwright.error()}
```

Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.

*Since Playwright 1.16.*

## Options

* `:indexed_db` (`t:boolean/0`) - *Since Playwright 1.51.* Set to `true` to include IndexedDB in the storage state snapshot.
* `:opfs` (`t:boolean/0`) - *Since Playwright 1.63.* Set to `true` to include the origin private file system in the storage state snapshot.
* `:path` (`t:String.t/0`) - The file path to save the storage state to. If `:path` is a relative path, then it is resolved relative to
  current working directory. If no path is provided, storage
  state is still returned, but won't be saved to the disk.

# `storage_state!`

```elixir
@spec storage_state!(t(), storage_state_options()) :: %{
  :cookies =&gt; [
    %{
      :name =&gt; String.t(),
      :value =&gt; String.t(),
      :domain =&gt; String.t(),
      :path =&gt; String.t(),
      :expires =&gt; number(),
      :httpOnly =&gt; boolean(),
      :secure =&gt; boolean(),
      :sameSite =&gt; String.t(),
      optional(atom()) =&gt; term()
    }
  ],
  :origins =&gt; [
    %{
      :origin =&gt; String.t(),
      :localStorage =&gt; [
        %{:name =&gt; String.t(), :value =&gt; String.t(), optional(atom()) =&gt; term()}
      ],
      optional(atom()) =&gt; term()
    }
  ],
  optional(atom()) =&gt; term()
}
```

Like `storage_state/2`, but returns the value and raises on error.

# `tracing`

```elixir
@spec tracing(t()) :: Playwright.Tracing.t()
```

Tracing recorder for requests made through this API request context.

*Since Playwright 1.60.*

---

*Consult [api-reference.md](api-reference.md) for complete listing*
