API thuê số nhận OTP
Dùng API của BinOTP để thuê số điện thoại ảo, nhận mã OTP và huỷ đơn ngay trong ứng dụng hoặc script của bạn. Mọi endpoint trả về JSON; xác thực bằng API key.
Bắt đầu nhanh
https://binotp.com/api/v1X-API-Key: YOUR_API_KEY
?apikey=... vẫn hoạt động để không làm hỏng tích hợp sẵn có, nhưng không nên dùng: key nằm trong URL sẽ bị ghi lại ở log máy chủ, lịch sử trình duyệt và header Referer.Giới hạn và lưu ý
- 60 lượt gọi mỗi phút cho mỗi API key, tính chung mọi endpoint. Vượt quá sẽ nhận lỗi 429.
- Tối đa 5 đơn đang chờ mã cùng lúc.
- Nên gọi get-sms mỗi 5 giây — gọi dày hơn không làm mã về sớm hơn.
- Đơn hết hạn mà chưa có mã: get-sms trả status "expired", trường refunded cho biết số tiền đã hoàn vào số dư.
Ví dụ code
Thuê một số Google (opt4) ở Mỹ, rồi hỏi mã mỗi 5 giây cho tới khi có kết quả.
# 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"];Danh sách endpoint
8/api/v1/meLấy thông tin tài khoản
Trả về số dư và thông tin tài khoản của bạn.
apikeystringBắt buộcAPI Key của bạn{ "success": true, "balance": 10.00, "email": "user@example.com", "username": "demo" }/api/v1/servicesDanh sách dịch vụ
Trả về tất cả dịch vụ OTP đang hoạt động.
apikeystringBắt buộcAPI Key của bạn{ "success": true, "services": [{ "code": "opt4", "name": "Google" }, ...] }/api/v1/countriesDanh sách quốc gia
Trả về tất cả quốc gia được hỗ trợ.
apikeystringBắt buộcAPI Key của bạn{ "success": true, "countries": [{ "code": "US", "name": "United States", "flagEmoji": "🇺🇸" }, ...] }/api/v1/pricesLấy bảng giá
Trả về giá của các dịch vụ. Có thể lọc theo mã dịch vụ và mã quốc gia.
apikeystringBắt buộcAPI Key của bạnservicestringTuỳ chọnMã dịch vụ (vd: opt4)countrystringTuỳ chọnMã quốc gia (vd: US){ "success": true, "prices": [{ "service": "opt4", "serviceName": "Google", "country": "US", "price": 0.35 }] }/api/v1/rent-numberThuê số điện thoại
Mua một số điện thoại ảo để nhận OTP. Tự động trừ số dư.
apikeystringBắt buộcAPI Key của bạnservicestringBắt buộcMã dịch vụ (vd: opt4 cho Google)countrystringBắt buộcMã quốc gia (vd: US)maxPricenumberTuỳ chọnGiá tối đa chấp nhận (USD). Giá hiện tại cao hơn thì đơn bị từ chối, không trừ tiền.{ "success": true, "orderId": "abc123", "phone": "12025551234", "service": "opt4", "country": "US", "price": 0.35, "expiresAt": "..." }/api/v1/get-smsKiểm tra mã SMS
Gọi lặp endpoint này để xem đã nhận được mã OTP chưa. Tự động hoàn tiền khi hết hạn.
apikeystringBắt buộcAPI Key của bạnorderIdstringBắt buộcMã đơn lấy từ rent-number{ "success": true, "orderId": "abc123", "phone": "12025551234", "smsCode": "123456", "status": "completed" }/api/v1/cancelHuỷ đơn
Huỷ một đơn đang chạy và hoàn tiền vào số dư.
apikeystringBắt buộcAPI Key của bạnorderIdstringBắt buộcMã đơn cần huỷ{ "success": true, "orderId": "abc123", "refunded": 0.35, "status": "cancelled" }/api/v1/ordersLịch sử đơn hàng
Liệt kê các đơn đã qua, có phân trang.
apikeystringBắt buộcAPI Key của bạnlimitnumberTuỳ chọnSố kết quả mỗi trang (mặc định 10, tối đa 100)offsetnumberTuỳ chọnBỏ qua N kết quả (dùng để phân trang){ "success": true, "orders": [...], "total": 42, "limit": 10, "offset": 0 }Mã lỗi
Khi có lỗi, API trả mã HTTP bên dưới kèm JSON có success = false và trường error mô tả lỗi (luôn bằng tiếng Anh):
{ "success": false, "error": "Insufficient balance" }Missing service or country codeThiếu hoặc sai tham số bắt buộc.Insufficient balanceSố dư không đủ — nạp thêm rồi thử lại.Temporarily out of stock, please try againTạm hết số cho dịch vụ/quốc gia này — thử lại sau hoặc chọn quốc gia khác.Price is $0.25 which exceeds your maxPrice of $0.20…Giá hiện tại cao hơn maxPrice bạn đặt — tăng maxPrice hoặc xem giá qua /prices.Invalid or missing API keyThiếu API key, key sai, hoặc tài khoản đang bị khoá.Order not foundKhông có đơn này trong tài khoản của bạn.Cannot cancel: SMS code already received…Đơn đã nhận được mã nên không huỷ được — gọi get-sms để đọc mã.Cannot cancel yet: please wait about 2 minutes after purchase…Chưa huỷ được ngay sau khi thuê — thử lại sau vài phút.Too many requests. Limit: 60/minVượt quá 60 lượt gọi mỗi phút.You already have 5 active orders (max 5)…Đang có quá nhiều đơn chờ mã — đợi có mã, hết hạn, hoặc huỷ bớt.Cannot cancel yet: please wait … minute(s) after purchase…Chưa huỷ được ngay sau khi thuê — thử lại sau vài phút.Service temporarily unavailableDịch vụ đang gián đoạn tạm thời — thử lại sau.