API
基本
- ベースURL
https://getotp.cc/api/v1
- メソッド
- すべて
POST
- APIキー
Authorization: Bearer gk_…(またはX-Api-Key)。/developerで発行。/totpは不要
- 受信箱
- 毎回
addressとpasswordを本文で指定。キーには紐づかない
- 本文
- JSONまたは
application/x-www-form-urlencoded。4KBまで
- 応答
- JSON。失敗時は
{"error": "...", "message": "..."}
- 日時
- ISO 8601(UTC)
- CORS
- 許可。公開ページのJavaScriptにキーやパスワードを置かない
- OpenAPI
- /docs/openapi.json
アドレス
ログイン画面と同じ。mail7z.net / mailcab.win / mailgz.dev などの受信ドメインと、irith / firstmail / mail.tm。GmailやYahooなどの個人向けメールは不可。
エンドポイント
POST /otp
コード入りの一番新しいメール。無ければotpとmailはnull。
本文
| 名前 | 型 | 必須 | 説明 |
|---|
| address | string | 必須 | メールアドレス |
| password | string | 必須 | メールボックスのパスワード |
| after | string | | この日時(ISO 8601)より後の受信だけ見る。firstmailには効かない |
応答
| 名前 | 型 | 説明 |
|---|
| address | string | 照合したアドレス |
| otp | string | null | 認証コード |
| mail | object | null | id / sender / subject / receivedAt |
リクエストcurl -X POST https://getotp.cc/api/v1/otp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer gk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-d '{"address": "xxxx@mail7z.net", "password": "パスワード", "after": "2026-10-12T03:20:00Z"}'
200{
"address": "xxxx@mail7z.net",
"otp": "482913",
"mail": {
"id": 1203,
"sender": "info@x.com",
"subject": "Your X confirmation code is 482913",
"receivedAt": "2026-10-12T03:21:45.000Z"
}
}
200(未着){"address": "xxxx@mail7z.net", "otp": null, "mail": null}
POST /mails
受信箱。新しい順。firstmailは最新の1通のみ(idは1)。
本文
| 名前 | 型 | 必須 | 説明 |
|---|
| address | string | 必須 | メールアドレス |
| password | string | 必須 | メールボックスのパスワード |
応答
| 名前 | 型 | 説明 |
|---|
| address | string | 照合したアドレス |
| mails | array | 次の要素の配列 |
mails[]
| 名前 | 型 | 説明 |
|---|
| id | integer | /mails/{id}に渡すID |
| sender | string | null | 差出人 |
| subject | string | null | 件名 |
| otp | string | null | 本文から抜き出した認証コード |
| receivedAt | string | 受信日時(ISO 8601、UTC)。firstmailは空文字 |
リクエストcurl -X POST https://getotp.cc/api/v1/mails \
-H "Content-Type: application/json" \
-H "Authorization: Bearer gk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-d '{"address": "xxxx@mail7z.net", "password": "パスワード"}'
200{
"address": "xxxx@mail7z.net",
"mails": [
{
"id": 1203,
"sender": "info@x.com",
"subject": "Your X confirmation code is 482913",
"otp": "482913",
"receivedAt": "2026-10-12T03:21:45.000Z"
},
{
"id": 1198,
"sender": "noreply@example.com",
"subject": "お知らせ",
"otp": null,
"receivedAt": "2026-10-12T02:10:03.000Z"
}
]
}
POST /mails/{id}
1通の本文。他人宛・無いIDは404。
パス
| 名前 | 型 | 必須 | 説明 |
|---|
| id | integer | 必須 | /mailsのid |
本文
| 名前 | 型 | 必須 | 説明 |
|---|
| address | string | 必須 | メールアドレス |
| password | string | 必須 | メールボックスのパスワード |
応答
| 名前 | 型 | 説明 |
|---|
| address | string | 照合したアドレス |
| mail | object | mails[]の項目に加えて次の2つ |
| mail.body | string | 本文(テキスト) |
| mail.replyTo | string | null | Reply-To |
リクエストcurl -X POST https://getotp.cc/api/v1/mails/1203 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer gk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-d '{"address": "xxxx@mail7z.net", "password": "パスワード"}'
200{
"address": "xxxx@mail7z.net",
"mail": {
"id": 1203,
"sender": "info@x.com",
"subject": "Your X confirmation code is 482913",
"otp": "482913",
"receivedAt": "2026-10-12T03:21:45.000Z",
"body": "Your X confirmation code is 482913.\n...",
"replyTo": null
}
}
POST /totp
base32の秘密キーから現在のコード。SHA-1 / 6桁 / 30秒。キーは保存しない。APIキー不要。
本文
| 名前 | 型 | 必須 | 説明 |
|---|
| secret | string | 必須 | base32。空白とハイフンは無視 |
応答
| 名前 | 型 | 説明 |
|---|
| code | string | 6桁 |
| expiresIn | integer | 切り替わるまでの秒数 |
| period | integer | 30 |
| digits | integer | 6 |
リクエストcurl -X POST https://getotp.cc/api/v1/totp \
-H "Content-Type: application/json" \
-d '{"secret": "JBSWY3DPEHPK3PXP"}'
200{"code": "287082", "expiresIn": 17, "period": 30, "digits": 6}
回数制限
超過は429とRetry-After。ポーリングは3〜5秒間隔。
| 対象 | 上限 |
| /otp・/mails・/mails/{id} | キーごと60回/分、1,000回/時 |
| 同じアドレス | 30回/分(キー横断) |
| 照合の失敗 | キーごと10回/分、60回/時 |
| パスワードの連続ミス | 同じアドレスで5回続くと5分ロック |
| キー無し・無効なキー | IPごと30回/分 |
| /totp | IPごと60回/分 |
エラー
| HTTP | error | 意味 |
| 400 | invalid_request | 必須項目が無い、または形式が違う |
| 400 | invalid_json | JSONとして読めない |
| 400 | invalid_secret | secretがbase32でない |
| 401 | invalid_api_key | APIキーが無い・無効・停止中 |
| 401 | invalid_credentials | アドレスまたはパスワードが違う |
| 404 | not_found | エンドポイントまたはメールが無い |
| 413 | payload_too_large | 本文が4KBを超えている |
| 429 | rate_limited | 回数制限。retryAfter秒後に再試行 |
| 502 | upstream | メールサービスに接続できない |
サンプル
Pythonimport time, requests
API_KEY = "gk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
def wait_for_otp(address, password, timeout=120):
after = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
# ここでコードを送らせる
deadline = time.time() + timeout
while time.time() < deadline:
res = requests.post("https://getotp.cc/api/v1/otp",
headers={"Authorization": "Bearer " + API_KEY},
json={"address": address, "password": password, "after": after}).json()
if res.get("otp"):
return res["otp"]
if res.get("error") in ("invalid_api_key", "invalid_credentials", "rate_limited"):
raise RuntimeError(res["message"])
time.sleep(4)
raise TimeoutError("timeout")
print(wait_for_otp("xxxx@mail7z.net", "パスワード"))
JavaScriptconst API_KEY = "gk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
async function waitForOtp(address, password, timeoutMs = 120000) {
const after = new Date().toISOString();
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const res = await fetch("https://getotp.cc/api/v1/otp", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer " + API_KEY },
body: JSON.stringify({ address, password, after }),
}).then((r) => r.json());
if (res.otp) return res.otp;
if (["invalid_api_key", "invalid_credentials", "rate_limited"].includes(res.error)) throw new Error(res.message);
await new Promise((r) => setTimeout(r, 4000));
}
throw new Error("timeout");
}
シェルcurl -s -X POST https://getotp.cc/api/v1/otp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer gk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-d '{"address": "xxxx@mail7z.net", "password": "パスワード"}' | jq -r .otp