跳到正文
  1. Otpforyou
  2. API 文档

REST API

REST API 文档

工具类接口使用 GET 请求,返回形如 { "status": "success", "data": … } 的 JSON。登录后在 API Docs 页面获取 ?api_key= 参数进行认证。

基础 URLllms.txt 供 AI 和工具使用

接口列表

GET/api/v1/services

无需认证

服务 — 价格与库存

不带 ?service= 返回完整列表;带 ?service= 返回单个服务的价格和库存。无需 API 密钥。

参数 · query

service可选
留空返回完整列表;填写代码返回单个服务(也接受简写,如 facebook)
成功 · 200 · JSON
GET https://otpforyou.com/api/v1/services?service=otp_gmail_facebook

{ "status": "success", "data": { "services": [
    { "code": "otp_gmail_facebook", "name": "Facebook", "price": 0.0493, "stock": 42 }
  ] } }

GET/api/v1/me

需要 API 密钥

账户信息

当前调用所用 API 密钥对应的 ID、邮箱和余额。

参数 · query

无参数。

成功 · 200 · JSON
GET https://otpforyou.com/api/v1/me?api_key=…

{ "status": "success", "data": { "id": "b7e5...-uuid", "email": "demo@example.com", "balance": 12.5, "created_at": "2026-01-15T08:30:00Z" } }

GET/api/v1/orders

需要 API 密钥

创建订单

同一个接口处理两种情况:service 为 Gmail OTP 代码(otp_gmail_*)时分配 1 个 OTP 邮箱;为库存商品代码(hotmail_*…)时按 quantity 购买。按标价扣费。

参数 · query

service
OTP 服务代码(otp_gmail_*)或库存商品代码(如 hotmail_oauth2_graph)
quantity可选
仅适用于一次性售出的邮箱 — 数量(默认 1)
unique_key可选
自行生成的 UUID — 重发不会重复创建或扣费
成功 · 200 · JSON
GET https://otpforyou.com/api/v1/orders?service=otp_gmail_facebook&api_key=…

{ "status": "success", "data": {
    "id": "b7e5a1c2-3d4e-4f60-8a91-2c3d4e5f6a7b", "email": "zurhansuzu@gmail.com",
    "service": "otp_gmail_facebook", "amount": 0.0493
  } }

GET/api/v1/orders/otp

无需认证

按订单获取 OTP

读取某个订单的 OTP。无需 API 密钥 — 订单号(order_id)即访问凭证。

参数 · query

order_id
订单号(创建订单时返回)
unique_key可选
每次调用自行生成的 UUID
from可选
Unix 秒 — 若没有更新的验证码则不返回 otp/received_at
成功 · 200 · JSON
GET https://otpforyou.com/api/v1/orders/otp?order_id=<order_id>

{ "status": "success", "data": {
    "otp": "481253", "amount": 0.0493, "received_at": 1732000000,
    "from": "security@facebookmail.com", "otp_history": [
      { "value": "481253", "received_at": 1732000000 }
    ] } }

GET/api/v1/otp/orders

需要 API 密钥

OTP 订单列表

已租用的 Gmail OTP 订单(分页),附带每个订单的最新 OTP。

参数 · query

page可选
页码(默认 1)
page_size可选
每页行数(默认 20,最大 200)
成功 · 200 · JSON
GET https://otpforyou.com/api/v1/otp/orders?page=1&page_size=20&api_key=…

{ "status": "success", "data": { "orders": [
    { "id": "b7e5a1c2-3d4e-4f60-8a91-2c3d4e5f6a7b", "email": "...", "service": "otp_gmail_facebook",
      "latest_otp": "481253", "latest_link": null, "tier": "normal", "charged": 0.0493,
      "received_at": "2026-11-01T14:39:02Z" }
  ], "page": 1, "page_size": 20, "total": 137 } }

GET/api/v1/mail

需要 API 密钥

读取全部邮件

某个邮箱的全部邮件,附带已提取的 OTP/链接。

参数 · query

order_id
订单号
成功 · 200 · JSON
GET https://otpforyou.com/api/v1/mail?order_id=<order_id>&api_key=…

{ "status": "success", "data": { "count": 1, "messages": [
    { "id": 88, "from": "...", "subject": "...", "otp": "481253", "received_at": "..." }
  ] } }

常见错误码

错误响应
{ "status": "error", "message": "out_of_stock", "retryable": true }
常见错误码
messageHTTP含义retryable
unauthorized401API 密钥无效或缺失false
invalid_request400请求参数无效false
not_found404未找到服务、订单或接口false
insufficient_balance402余额不足false
out_of_stock409缺货——Gmail OTP:可重试,几秒后再试;买断邮箱:等待补货true
service_unavailable503服务器暂时无法完成订单——请使用相同的 unique_key 重试true
in_progress409订单正在处理,或可能已在供应商处创建——请使用相同的 unique_key 重试true
forbidden403无权访问该资源false
idempotency_mismatch422unique_key 已用于其他请求——请使用新的 unique_keyfalse
order_cancelled409订单在扣费前被释放,未扣费——请重试true
too_many_requests429请求过于频繁——稍后重试true
auth_unavailable503暂时无法验证 API 密钥,密钥本身没问题——请重试true
shutting_down503服务器正在重启——几秒后重试true
payload_too_large413请求数据过大false
internal_server_error500系统错误,请稍后重试false

面向 AI 和工具的文档

完整的 Markdown 文档位于 https://otpforyou.com/llms.txt —— 粘贴到 Cursor、Claude 或 ChatGPT 中即可生成集成代码。

使用 unique_key 安全重试

每个订单都附带一个 unique_key(自行生成的 UUID)。如果网络中断,使用同一个 unique_key 重试:你会拿回同一个订单,不会新建订单,也不会重复扣费。

错误格式

出错时,响应只包含 status、message(snake_case 格式的错误代码)和 retryable,后者告诉你是否应该重试。

立即开始使用 Otpforyou

免费注册,充值钱包,几分钟内即可租到第一个邮箱。

创建账号