---
title: Rate limiting
description: "A fixed-window limiter, counted per key per binding, on one node."
---

## Configuration

```jsonc
"ratelimiters": [{ "binding": "API", "limit": 100, "period": 60 }]
```

`limit` and `period` (seconds) are fixed in `sproutboat.jsonc` — they cannot be changed per call.

## Usage

```js
const { success, resetAt } = env.API.limit({ key: clientIp });
if (!success) {
  const retryAfter = Math.ceil((resetAt - Date.now()) / 1000);
  return new Response("slow down", { status: 429, headers: { "retry-after": String(retryAfter) } });
}
```

## Method

| Method | Signature | Returns |
| --- | --- | --- |
| `limit` | `({ key: string })` | `{ success: boolean, resetAt: number }` — `resetAt` is epoch milliseconds |

:::warning
A fixed window, counted per key per binding, on one node. A burst straddling a window boundary can briefly reach roughly `2 × limit`.
:::
