エラーと利用制限
エラーの形
エラーは、code はmessage は
{ "error": { "code": "not_found", "message": "見つかりません" } }code は、bad_request、unauthorized、invalid_viewer_token、not_found、method_not_allowed、rate_limited のcode をmessage の
500 番台は、res.json() が
const res = await fetch(`${BASE}/content/docs/nothing`, { headers });
if (!res.ok) {
const { error } = await res.json();
console.error(res.status, error.code, error.message);
}ステータスごとのメッセージ
| ステータス | code |
message |
起きる |
|---|---|---|---|
| 400 | bad_request |
ref が |
ref の |
| 400 | bad_request |
並べ替えに<項目> |
order にindexed でない |
| 400 | bad_request |
絞り込みに<項目> |
filter にindexed でない |
| 400 | bad_request |
未対応の<演算子> |
filter[項目][演算子] が |
| 400 | bad_request |
in の |
in の |
| 400 | bad_request |
数値の<項目> |
number の |
| 401 | unauthorized |
API トークンが |
トークンが |
| 401 | invalid_viewer_token |
閲覧者トークンが |
Kumidana-Viewer の |
| 404 | not_found |
見つかりません | 存在しないdraft=1 やref、 |
| 404 | not_found |
種類が |
種類の |
| 404 | not_found |
エントリーが |
ID や |
| 404 | not_found |
フォームが |
フォームの |
| 405 | method_not_allowed |
GET だけを |
GET と |
| 429 | rate_limited |
リクエストが |
利用制限を |
<項目> と<演算子> には、order とfilter の
コンテンツ API は、origin_not_allowed)と、forbidden)だけです。
エラーの
- パスが
API の 形でない : 404、 GET以外: 405 - トークンが
正しくない : 401 unauthorized - トークンの
サイトと URL の サイトが 違う : 404 refの形が 正しくない (空を 含む) : 400 bad_request。公開トークンでも、 404 より 先に 400 に なります - 公開トークンで
draft=1やrefを付けた : 404 - トークンの
範囲の 外 (プレビュー用の 一時トークン、 カスタムの ポリシー) : 404 Kumidana-Viewerのトークンが 無効: 401 invalid_viewer_token- 種類・フォームが
見つからない : 404。 order・filterの誤り: 400。 エントリーが 見つからない : 404
401 にはWWW-Authenticate: Bearer ヘッダーがinvalid_viewer_token のWWW-Authenticate: Bearer error="invalid_token" とCache-Control: private, no-store がcode で
エラーのerror.code をdraft=1、ref=)では、Access-Control-Allow-Origin が
実装が
利用制限
乱用を
| 対象 | 数える |
上限 |
|---|---|---|
| トークンを |
トークン | 600 回 / 60 秒 |
トークンを/mcp) |
トークン | 120 回 / 60 秒 |
| トークンを |
IP アドレス | 60 回 / 60 秒 |
Authorization を |
IP アドレス | 1200 回 / 60 秒 |
| トークンを |
IP アドレス | 60 回 / 60 秒 |
| フォームの |
IP アドレス | 10 回 / 60 秒 |
Git(git.kumidana.com) |
トークン |
120 回 / 60 秒 |
| Git で |
IP アドレス | 10 回 / 60 秒 |
| パスキーの |
IP アドレス | 20 回 / 60 秒 |
| 復旧メールと |
メールアドレス | 5 回 / 60 秒 |
OAuth の/oauth/token、/oauth/device/code、/oauth/register、/token の |
IP アドレス | 30 回 / 60 秒 |
Kumidana ID の/token、/userinfo |
クライアントと/userinfo は |
600 回 / 60 秒 |
トークンごとのKumidana-Viewer の
フォームのOPTIONS)は、{ "error": "slow_down" } です。Retry-After: 60 が
数値は
429 が返ったとき
上限を429 とRetry-After: 60(秒)、Cache-Control: no-store、Access-Control-Allow-Origin: * も
{ "error": { "code": "rate_limited", "message": "リクエストが多すぎます。しばらくしてからもう一度お試しください" } }Retry-After のRetry-After ヘッダーをAccess-Control-Expose-Headers がheaders.get('retry-after') はnull に
async function fetchWithRetry(url: string, init: RequestInit, retries = 2): Promise<Response> {
const res = await fetch(url, init);
if (res.status !== 429 || retries === 0) return res;
const wait = Number(res.headers.get('retry-after') ?? 60);
await new Promise((r) => setTimeout(r, wait * 1000));
return fetchWithRetry(url, init, retries - 1);
}429 をfields とlimit で