# `JSONAPIPlug.API`
[🔗](https://github.com/lucacorti/jsonapi_plug/blob/main/lib/jsonapi_plug/api.ex#L1)

  JSON:API API Configuration

  You can define an API by "use-ing" `JSONAPIPlug.API` in your API module:

  ```elixir
  defmodule MyApp.API do
    use JSONAPIPlug.API, otp_app: :my_app
  end
  ```

  API module configuration can be customized via your application configuration:

  ```elixir
  config :my_app, MyApp.API,
    namespace: "api",
    case: :dasherize
  ```

  See `t:options/0` for all available configuration options.

# `options`

```elixir
@type options() :: keyword()
```

API configuration options:

* `:case` - This option controls how your API's field names will be cased. The current `JSON:API Specification v1.0` recommends dasherizing (e.g. `"favorite-color": "blue"`), while the upcoming `JSON:API Specification v1.1` recommends camelCase (e.g. `"favoriteColor": "blue"`). The default value is `:camelize`.

* `:client_generated_ids` (`t:boolean/0`) - Enable support for Client-Generated IDs. When enabled, the resources received in requests are supposed to contain a valid 'id'. The default value is `false`.

* `:host` (`t:String.t/0`) - Hostname used for link generation instead of deriving it from the connection.

* `:namespace` (`t:String.t/0`) - Namespace for all resources in your API. if you want your resources to live under ".../api/v1", pass `namespace: "api/v1"`.

* `:normalizer` (`t:atom/0`) - Normalizer for transformation of `JSON:API` document to and from user data. The default value is `JSONAPIPlug.Normalizer.Ecto`.

* `:query_parsers` (`t:keyword/0`) - Parsers for transformation of `JSON:API` request query parameters to user data. The default value is `[fields: JSONAPIPlug.QueryParser.Ecto.Fields, filter: JSONAPIPlug.QueryParser.Filter, include: JSONAPIPlug.QueryParser.Ecto.Include, page: JSONAPIPlug.QueryParser.Page, sort: JSONAPIPlug.QueryParser.Ecto.Sort]`.

  * `:fields` (`t:atom/0`) - Fields query parameter parser. The default value is `JSONAPIPlug.QueryParser.Ecto.Fields`.

  * `:filter` (`t:atom/0`) - Filter query parameter parser. The default value is `JSONAPIPlug.QueryParser.Filter`.

  * `:include` (`t:atom/0`) - Include query parameter parser. The default value is `JSONAPIPlug.QueryParser.Ecto.Include`.

  * `:page` (`t:atom/0`) - Page query parameter parser. The default value is `JSONAPIPlug.QueryParser.Page`.

  * `:sort` (`t:atom/0`) - Sort query parameter parser. The default value is `JSONAPIPlug.QueryParser.Ecto.Sort`.

* `:pagination` (`t:atom/0`) - A module adopting the `JSONAPIPlug.Pagination` behaviour for pagination. The default value is `nil`.

* `:port` (`t:pos_integer/0`) - Port used for link generation instead of deriving it from the connection.

* `:scheme` - Scheme used for link generation instead of deriving it from the connection.

* `:version` - `JSON:API` version advertised in the document The default value is `:"1.0"`.

# `t`

```elixir
@type t() :: module()
```

# `get_config`

```elixir
@spec get_config(t()) :: keyword()
```

Retrieve API configuration

Please note that API configuration is also cached on first request and read back from it afterwards.

---

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