# レート制限とクォータ

> Kanorio APIにおけるリクエストレート制限の仕組み、現在の状況を確認するためのヘッダー、および保存リソース量の上限となるプランごとのクォータについて解説します。

> Markdown version of https://kanorio.com/ja/developers/basics/rate-limits. Append `.md` to any developer docs URL for this format. Index: https://kanorio.com/llms.txt · MCP: https://app.kanorio.com/api/mcp
>
> Translated from the English original: https://kanorio.com/en/developers/basics/rate-limits.md

レート制限は、特定のインテグレーションが他のユーザーのパフォーマンスを低下させることを防ぐための仕組みです。Management APIでは認証情報ごとに、パブリックAPIではサイト、訪問者、または顧客ごとに制限がカウントされます。クォータはこれとは異なり、コレクションアイテムやWebhookエンドポイントなど、サイトが保存できるリソース量の上限を指し、契約しているプランによって異なります。

## 制限に達した場合

APIは `429` ステータスコードと `RATE_LIMITED` というコードを返し、`Retry-After` ヘッダーで秒数を指定します。その秒数以上待機してから、バックオフを考慮して再試行してください。

```json
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Too many requests.",
    "details": { "retryAfter": 12 }
  }
}
```

バックエンドが混雑している場合、`SEARCH_BUSY` や `ANALYTICS_BUSY` など、より具体的なコードとともに `429` が返されることがあります。これらも同様の方法で処理してください。

## Management API

各トークンには独自の予算が割り当てられています。ほとんどの操作はデフォルトの階層を共有します。分析クエリは負荷が高いため、トークンごとに低い階層が設定されており、さらにサイトごとに上限が設けられ、そのサイト上のすべてのトークンで共有されます。REST呼び出しとMCP呼び出しは、同じ予算枠としてカウントされます。

[Management APIリファレンス](https://kanorio.com/en/developers/management-api)の各操作には階層が示されており、OpenAPIドキュメントでは `x-kanorio-rate-limit` として記載されています。

## Content Delivery API

エッジキャッシュから提供されるレスポンスはカウントされないため、キャッシュが有効な混雑したサイトがこれらの制限に達することはありません。キャッシュミス、フォームへの書き込み、分析ビーコン、ドラフトプレビューはトークンバケットでカウントされます。各バケットは一定の速度で補充され、短時間のバーストが可能です。カウント対象のレスポンスには以下のヘッダーが含まれます。

| ヘッダー | 意味 |
|---|---|
| `X-RateLimit-Limit` | バケットサイズ |
| `X-RateLimit-Remaining` | 現在の残りリクエスト数 |
| `X-RateLimit-Reset` | バケットが再び満杯になるまでの秒数 |

可能な限りサーバーサイドやビルド時にページを構築し、エッジキャッシュで訪問者のトラフィックを吸収するようにしてください。

## Customer API

サインイン後の呼び出しは、顧客トークンごとに制限されます。サインインのリクエストは、IPアドレスごとに制限されます。

## 現在の制限とクォータ

以下の値は、APIが適用している定数から生成されています。

### Management API tiers

| Tier | Limit | Applies to |
| --- | --- | --- |
| default | 120/minute per token | Every operation not listed below |
| heavy | 20/minute per token, plus 20/minute per site | Analytics queries (`analytics.*`); REST and MCP share the bucket |
| publish | 30/hour per token | Publishing and unpublishing |

### Content Delivery API buckets

Cache hits are not counted. Only requests that miss the edge cache, form writes and analytics beacons use these buckets.

| Bucket | Limit |
| --- | --- |
| Cache misses per site | 20 requests/second, burst 100 |
| Cache misses per visitor IP | 10 requests/second, burst 30 |
| Draft preview per IP | 2 requests/second, burst 20 |
| Gated content per customer token | 5 requests/second, burst 30 |

### Customer API buckets

| Bucket | Limit |
| --- | --- |
| Per customer token | 5 requests/second, burst 30 |
| Sign-in (challenge and verify) per IP | 1 requests/second, burst 10 |

### Plan quotas

| Resource | Free | Pro | Business |
| --- | --- | --- | --- |
| Collection items included | 50 | 1,000 | 10,000 |
| Storage included | 200 MB | 10 GB | 200 GB |
| Custom domains | 0 | 1 | 5 |
| Webhook endpoints per site | 10 | 10 | 10 |
| Rows per import batch | 100 | 1,000 | 2,000 |
