短信验证码 API
通过 BinOTP API,你可以在自己的应用或脚本中租用虚拟号码、接收 OTP 验证码并取消订单。所有接口均返回 JSON,并使用 API 密钥认证。
快速开始
基础地址:
https://binotp.com/api/v1你的 API Key:
免费注册 即可获得 API 密钥,登录后在账户页面查看。
认证 — 建议通过请求头传递 API Key:
X-API-Key: YOUR_API_KEY
旧方式
?apikey=... 仍然可用,以免破坏现有集成,但 不建议使用:URL 中的密钥会被记录 会出现在服务器日志、浏览器历史和 Referer 请求头中。限制与说明
- 每个 API 密钥每分钟最多 60 次请求(所有接口合计),超出将返回 429 错误。
- 最多同时有 5 个订单等待验证码。
- 建议每 5 秒调用一次 get-sms,更频繁的查询并不会让验证码更快到达。
- 订单过期仍未收到验证码时,get-sms 返回 status "expired",refunded 字段显示退回到余额的金额。
代码示例
租用一个美国的 Google(opt4)号码,然后每 5 秒查询一次验证码,直到有结果。
# 1. Rent a Google (opt4) number in the US
curl -X POST "https://binotp.com/api/v1/rent-number" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"service": "opt4", "country": "US"}'
# 2. Check for the SMS code (repeat every 5 seconds until status is not "waiting_sms")
curl "https://binotp.com/api/v1/get-sms?orderId=ORDER_ID" \
-H "X-API-Key: YOUR_API_KEY"import time
import requests
API = "https://binotp.com/api/v1"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}
# 1. Rent a Google (opt4) number in the US
order = requests.post(API + "/rent-number", headers=HEADERS,
json={"service": "opt4", "country": "US"}).json()
if not order["success"]:
raise SystemExit(order["error"])
print("Phone:", order["phone"])
# 2. Poll for the code every 5 seconds
while True:
sms = requests.get(API + "/get-sms", headers=HEADERS,
params={"orderId": order["orderId"]}).json()
if not sms["success"]:
raise SystemExit(sms["error"])
if sms["status"] != "waiting_sms":
print(sms["status"], sms.get("smsCode"))
break
time.sleep(5)// Node.js 18+ (built-in fetch), run as an ES module
const API = "https://binotp.com/api/v1";
const headers = { "X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json" };
// 1. Rent a Google (opt4) number in the US
const order = await fetch(API + "/rent-number", {
method: "POST",
headers,
body: JSON.stringify({ service: "opt4", country: "US" }),
}).then((r) => r.json());
if (!order.success) throw new Error(order.error);
console.log("Phone:", order.phone);
// 2. Poll for the code every 5 seconds
while (true) {
const sms = await fetch(API + "/get-sms?orderId=" + order.orderId, { headers })
.then((r) => r.json());
if (!sms.success) throw new Error(sms.error);
if (sms.status !== "waiting_sms") {
console.log(sms.status, sms.smsCode);
break;
}
await new Promise((resolve) => setTimeout(resolve, 5000));
}<?php
$api = "https://binotp.com/api/v1";
$headers = ["X-API-Key: YOUR_API_KEY", "Content-Type: application/json"];
function call($method, $url, $headers, $body = null) {
$ch = curl_init($url);
$options = [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
];
if ($body !== null) {
$options[CURLOPT_POSTFIELDS] = json_encode($body);
}
curl_setopt_array($ch, $options);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
return $result;
}
// 1. Rent a Google (opt4) number in the US
$order = call("POST", $api . "/rent-number", $headers, ["service" => "opt4", "country" => "US"]);
if (!$order["success"]) exit($order["error"]);
echo "Phone: " . $order["phone"] . PHP_EOL;
// 2. Poll for the code every 5 seconds
do {
sleep(5);
$sms = call("GET", $api . "/get-sms?orderId=" . $order["orderId"], $headers);
} while ($sms["success"] && $sms["status"] === "waiting_sms");
echo $sms["success"] ? $sms["status"] . " " . ($sms["smsCode"] ?? "") : $sms["error"];接口列表
8GET
/api/v1/me获取账户信息
返回你的余额与账户信息。
名称类型是否必填说明
apikeystring必填你的 API Key{ "success": true, "balance": 10.00, "email": "user@example.com", "username": "demo" }GET
/api/v1/services获取可用服务列表
返回所有可用的接码服务。
名称类型是否必填说明
apikeystring必填你的 API Key{ "success": true, "services": [{ "code": "opt4", "name": "Google" }, ...] }GET
/api/v1/countries获取可用国家列表
返回所有支持的国家。
名称类型是否必填说明
apikeystring必填你的 API Key{ "success": true, "countries": [{ "code": "US", "name": "United States", "flagEmoji": "🇺🇸" }, ...] }GET
/api/v1/prices获取价格
返回各服务的价格,可按服务代码与国家代码筛选。
名称类型是否必填说明
apikeystring必填你的 API Keyservicestring可选服务代码(如 opt4)countrystring可选国家代码(如 US){ "success": true, "prices": [{ "service": "opt4", "serviceName": "Google", "country": "US", "price": 0.35 }] }POST
/api/v1/rent-number租用手机号
购买一个用于接收验证码的虚拟号码,自动从余额扣款。
名称类型是否必填说明
apikeystring必填你的 API Keyservicestring必填服务代码(如 Google 为 opt4)countrystring必填国家代码(如 US)maxPricenumber可选可接受的最高价格(美元)。当前价格更高时订单会被拒绝,不会扣费。{ "success": true, "orderId": "abc123", "phone": "12025551234", "service": "opt4", "country": "US", "price": 0.35, "expiresAt": "..." }GET
/api/v1/get-sms查询短信验证码
轮询该接口以查看是否已收到验证码。超时未收到将自动退款。
名称类型是否必填说明
apikeystring必填你的 API KeyorderIdstring必填来自 rent-number 的订单号{ "success": true, "orderId": "abc123", "phone": "12025551234", "smsCode": "123456", "status": "completed" }POST
/api/v1/cancel取消订单
取消进行中的订单并将款项退回余额。
名称类型是否必填说明
apikeystring必填你的 API KeyorderIdstring必填要取消的订单号{ "success": true, "orderId": "abc123", "refunded": 0.35, "status": "cancelled" }GET
/api/v1/orders订单记录
分页列出你的历史订单。
名称类型是否必填说明
apikeystring必填你的 API Keylimitnumber可选每页结果数(默认 10,最多 100)offsetnumber可选跳过 N 条结果(用于分页){ "success": true, "orders": [...], "total": 42, "limit": 10, "offset": 0 }错误码
出错时,API 返回下表中的 HTTP 状态码,JSON 中 success 为 false,error 字段描述错误(始终为英文):
{ "success": false, "error": "Insufficient balance" }HTTPerror(示例)含义
400
Missing service or country code缺少必填参数或参数无效。400
Insufficient balance余额不足,请充值后重试。400
Temporarily out of stock, please try again该服务/国家暂时无号,请稍后重试或换一个国家。400
Price is $0.25 which exceeds your maxPrice of $0.20…当前价格高于你设置的 maxPrice,请提高 maxPrice 或通过 /prices 查询价格。401
Invalid or missing API key缺少 API 密钥、密钥错误,或账户已被停用。404
Order not found你的账户中没有该订单。409
Cannot cancel: SMS code already received…该订单已收到验证码,无法取消,请调用 get-sms 读取。409
Cannot cancel yet: please wait about 2 minutes after purchase…购买后暂时无法立即取消,请几分钟后重试。429
Too many requests. Limit: 60/min每分钟请求超过 60 次。429
You already have 5 active orders (max 5)…等待验证码的订单过多,请等待收码、过期或取消部分订单。429
Cannot cancel yet: please wait … minute(s) after purchase…购买后暂时无法立即取消,请几分钟后重试。503
Service temporarily unavailable服务暂时不可用,请稍后重试。