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

[`APIResponse`](`Playwright.APIResponse`) class represents responses returned by `Playwright.APIRequestContext.get/3` and similar methods.

*Since Playwright 1.16.*

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

# `t`

```elixir
@type t() :: %Playwright.APIResponse{
  _apiName: term(),
  _headers: term(),
  _initializer: term(),
  _request: term()
}
```

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

# `body`

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

Returns the buffer with response body.

*Since Playwright 1.16.*

# `body!`

```elixir
@spec body!(t()) :: binary()
```

Like `body/1`, but returns the value and raises on error.

# `dispose`

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

Disposes the body of this response. If not called then the body will stay in memory until the context closes.

*Since Playwright 1.16.*

# `dispose!`

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

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

# `headers`

```elixir
@spec headers(t()) :: %{optional(String.t()) =&gt; String.t()}
```

An object with all the response HTTP headers associated with this response.

*Since Playwright 1.16.*

# `headers_array`

```elixir
@spec headers_array(t()) :: [%{name: String.t(), value: String.t()}]
```

An array with all the response HTTP headers associated with this response. Header names are not lower-cased.
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.

*Since Playwright 1.16.*

# `json`

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

Returns the JSON representation of response body.

This method will fail if the response body is not parsable via `JSON.parse`.

*Since Playwright 1.16.*

# `json!`

```elixir
@spec json!(t()) :: term()
```

Like `json/1`, but returns the value and raises on error.

# `ok`

```elixir
@spec ok(t()) :: boolean()
```

Contains a boolean stating whether the response was successful (status in the range 200-299) or not.

*Since Playwright 1.16.*

# `security_details`

```elixir
@spec security_details(t()) ::
  {:ok,
   nil
   | %{
       optional(:issuer) =&gt; String.t(),
       optional(:protocol) =&gt; String.t(),
       optional(:subjectName) =&gt; String.t(),
       optional(:validFrom) =&gt; number(),
       optional(:validTo) =&gt; number()
     }}
  | {:error, Playwright.error()}
```

Returns SSL and other security information. Returns `nil` for non-HTTPS responses. For redirected requests, returns the information for the last request in the redirect chain.

*Since Playwright 1.61.*

# `security_details!`

```elixir
@spec security_details!(t()) ::
  nil
  | %{
      optional(:issuer) =&gt; String.t(),
      optional(:protocol) =&gt; String.t(),
      optional(:subjectName) =&gt; String.t(),
      optional(:validFrom) =&gt; number(),
      optional(:validTo) =&gt; number()
    }
```

Like `security_details/1`, but returns the value and raises on error.

# `server_addr`

```elixir
@spec server_addr(t()) ::
  {:ok, nil | %{ipAddress: String.t(), port: integer()}}
  | {:error, Playwright.error()}
```

Returns the IP address and port of the server. Returns `nil` if the server address is not available. For redirected requests, returns the information for the last request in the redirect chain.

*Since Playwright 1.61.*

# `server_addr!`

```elixir
@spec server_addr!(t()) :: nil | %{ipAddress: String.t(), port: integer()}
```

Like `server_addr/1`, but returns the value and raises on error.

# `status`

```elixir
@spec status(t()) :: integer()
```

Contains the status code of the response (e.g., 200 for a success).

*Since Playwright 1.16.*

# `status_text`

```elixir
@spec status_text(t()) :: String.t()
```

Contains the status text of the response (e.g. usually an "OK" for a success).

*Since Playwright 1.16.*

# `text`

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

Returns the text representation of response body.

*Since Playwright 1.16.*

# `text!`

```elixir
@spec text!(t()) :: String.t()
```

Like `text/1`, but returns the value and raises on error.

# `timing`

```elixir
@spec timing(t()) :: %{
  startTime: number(),
  domainLookupStart: number(),
  domainLookupEnd: number(),
  connectStart: number(),
  secureConnectionStart: number(),
  connectEnd: number(),
  requestStart: number(),
  responseStart: number(),
  responseEnd: number()
}
```

Returns resource timing information for given response. For redirected requests, returns the information for the last
request in the redirect chain. When the response is served [from the HAR file](https://playwright.dev/docs/mock#replaying-from-har), timing
information is not available and all the values are -1. Find more information at
[Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).

*Since Playwright 1.62.*

# `url`

```elixir
@spec url(t()) :: String.t()
```

Contains the URL of the response.

*Since Playwright 1.16.*

---

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