# `PDFShift.API`
[🔗](https://github.com/sgerrand/ex_pdf_shift/blob/v0.2.1/lib/pdf_shift/api.ex#L1)

Module implementing the PDFShift API endpoints.

# `convert`

```elixir
@spec convert(
  module(),
  PDFShift.Config.t(),
  String.t(),
  PDFShift.Types.convert_options()
) ::
  {:ok, map()} | {:error, any()}
```

Converts a HTML document or URL to PDF.

## Parameters

  * `client` - The HTTP client module
  * `config` - The configuration struct
  * `source` - URL or HTML content to convert to PDF
  * `options` - Conversion options (see `t:PDFShift.Types.convert_options/0`)

## Returns

  * `{:ok, response}` - On successful conversion
  * `{:error, reason}` - On failure

## Examples

    iex> PDFShift.API.convert(PDFShift.Client, config, "https://example.com")
    {:ok, %{body: <<PDF binary data>>, status: 200, headers: [...]}}

# `credits_usage`

```elixir
@spec credits_usage(module(), PDFShift.Config.t()) :: {:ok, map()} | {:error, any()}
```

Gets the current credits usage.

## Parameters

  * `client` - The HTTP client module
  * `config` - The configuration struct

## Returns

  * `{:ok, response}` - On successful request
  * `{:error, reason}` - On failure

## Examples

    iex> PDFShift.API.credits_usage(PDFShift.Client, config)
    {:ok, %{
      body: %{
        "credits" => %{
          "base" => 50000,
          "remaining" => 49881,
          "total" => 50000,
          "used" => 119
        },
        "success" => true
      },
      status: 200,
      headers: [...]
    }}

---

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