# `Teac.RateLimit`
[🔗](https://codeberg.org/FullStacking/teac)

Rate limit information extracted from Twitch API response headers.

Twitch includes these headers on every response:

- `Ratelimit-Limit` — total requests allowed in the current window
- `Ratelimit-Remaining` — requests remaining in the current window
- `Ratelimit-Reset` — Unix timestamp (seconds) when the window resets

All `Teac.Api.*` functions return this struct as the last element of their
return tuple so callers can implement their own throttling strategy.

## Non-paginated

    case Teac.Api.Users.get(client, id: "123") do
      {:ok, users, rl} ->
        if rl.remaining < 10, do: maybe_slow_down()
        users
      {:error, %Teac.Error{status: 429, ratelimit: rl}} ->
        wait_until(rl.reset)
    end

## Paginated

    {:ok, data, cursor, rl} = Teac.Api.Clips.get(client, broadcaster_id: "123")

## Fields

Fields are `nil` when headers are absent (e.g. in tests using `Req.Test` stubs).

# `t`

```elixir
@type t() :: %Teac.RateLimit{
  limit: non_neg_integer() | nil,
  remaining: non_neg_integer() | nil,
  reset: non_neg_integer() | nil
}
```

---

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