# `Hunter.Api.Request`
[🔗](https://github.com/milmazz/hunter/blob/v0.8.0/lib/hunter/api/request.ex#L1)

The single HTTP transport for Hunter.

`request!/6` joins the endpoint path onto the base URL, sets
authentication headers from the `Hunter.Client` (none for a bare base
URL string), performs the request via `Req`, decodes the response
through Hunter.Api.Transformer, and raises `Hunter.Error` on failure.

# `request!`

Performs a request against the Mastodon API and returns the transformed
entity.

## Parameters

  * `conn_or_base_url` - a `Hunter.Client` (authenticated) or a base URL
    string (unauthenticated, e.g. app registration and OAuth flows)
  * `method` - `:get`, `:post`, `:put`, `:patch` or `:delete`
  * `path` - endpoint path, e.g. `"/api/v1/statuses"`
  * `to` - Hunter.Api.Transformer target (e.g. `:status`, `:accounts`,
    `:empty`), or `nil` for the JSON-decoded body untouched
  * `payload` - query params for `:get`/`:delete`; JSON body (map or
    keyword) or `{:form_multipart, parts}` for write verbs
  * `opts` - `headers: [{name, value}]` extra request headers

Raises `Hunter.Error` on non-2xx responses and transport errors.

---

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