跳转到快速开始
API 参考
在你自己的代码中购买虚拟号码、租用号码、Google Voice 号码和礼品卡。每个调用都是一个 GET 请求,密钥放在查询参数中,并从你在网站上使用的同一个钱包扣款。
https://smsonline.io/api/v1更喜欢点点鼠标?Postman 集合已备好每个可直接发送的调用。
响应与错误
成功的调用返回 "status": 1,结果在 data 中。其他任何情况都表示调用没有生效:请阅读 msg 了解原因。
- 1
- 成功
- -1
- 失败。除非 msg 另有说明,否则不会扣费
- -2
- 尚未收到短信,请继续轮询
{
"status": -1,
"error": "missing parameter",
"msg": ["Insufficient inventory"]
}账户
查看用于支付每笔购买的钱包。
curl -G "https://smsonline.io/api/v1/get-balance" \
-d apiKey=YOUR_API_KEY{
"status": 1,
"data": { "balance": "24.60" }
}虚拟号码
用于短信验证的一次性号码。查找产品、购买,然后轮询验证码。
curl -G "https://smsonline.io/api/v1/virtual-number/get-countries" \
-d apiKey=YOUR_API_KEY{
"status": 1,
"data": [
{ "id": 1, "name": "United States", "image": "https://…/us.png" },
{ "id": 7, "name": "United Kingdom", "image": "https://…/gb.png" }
]
}curl -G "https://smsonline.io/api/v1/virtual-number/get-services" \
-d apiKey=YOUR_API_KEY{
"status": 1,
"data": [
{ "id": 2, "name": "Telegram", "image": "https://…/telegram.png" },
{ "id": 5, "name": "WhatsApp", "image": "https://…/whatsapp.png" }
]
}GET/virtual-number/get-products
某个应用在某个国家的价格,每个运营商(operatorId 为 1 至 4)一行,显示该运营商最便宜的号码。运营商会随库存增减,因此只能使用本次调用刚返回的 operatorId 购买。
查询参数
apiKey必填你的 API 密钥countryId必填来自“国家列表”的国家 IDserviceId必填来自“服务列表”的服务 ID
curl -G "https://smsonline.io/api/v1/virtual-number/get-products" \
-d apiKey=YOUR_API_KEY \
-d countryId=1 \
-d serviceId=2{
"status": 1,
"data": [
{ "countryId": 1, "serviceId": 2, "operatorId": 1, "price": "0.45" },
{ "countryId": 1, "serviceId": 2, "operatorId": 3, "price": "0.72" },
{ "countryId": 1, "serviceId": 2, "operatorId": 4, "price": "0.64" }
]
}购买号码
从你的钱包扣款GET/virtual-number/buy-service
按“产品列表”返回的价格,从所选运营商购买号码,并从你的钱包扣款。号码有效期为 10 分钟。
查询参数
apiKey必填你的 API 密钥countryId必填国家 IDserviceId必填服务 IDoperatorId必填来自“产品列表”的运营商 ID(1 至 4)
curl -G "https://smsonline.io/api/v1/virtual-number/buy-service" \
-d apiKey=YOUR_API_KEY \
-d countryId=1 \
-d serviceId=2 \
-d operatorId=1{
"status": 1,
"data": {
"order_id": 918273,
"Number": "+14155550132",
"country_name": "United States",
"service_name": "Telegram",
"country_image": "https://…/us.png",
"service_image": "https://…/telegram.png"
}
}GET/virtual-number/get-sms
每隔几秒轮询一次,直到验证码到达。status: -2 表示尚未收到。如果短信未及时到达,订单会失败,费用退回你的钱包。
查询参数
apiKey必填你的 API 密钥orderId必填来自“购买号码”的 order_id
curl -G "https://smsonline.io/api/v1/virtual-number/get-sms" \
-d apiKey=YOUR_API_KEY \
-d orderId=918273{
"status": 1,
"code": "48213"
}
// still waiting
{ "status": -2, "error": "Sms not received", "msg": ["sms for this number is not received"] }Google Voice
附带 Google 账号的现成美国 Google Voice 号码。
curl -G "https://smsonline.io/api/v1/google-voice/get-numbers" \
-d apiKey=YOUR_API_KEY{
"status": 1,
"data": [
{ "id": 3321, "number": "+1 (628) 555-0147", "price": "4.90", "type": 1, "country_name": "USA" }
]
}curl -G "https://smsonline.io/api/v1/google-voice/get-number" \
-d apiKey=YOUR_API_KEY \
-d id=3321{
"status": 1,
"data": { "id": 3321, "number": "+1 (628) 555-0147", "price": "4.90", "type": 1, "country_name": "USA" }
}curl -G "https://smsonline.io/api/v1/google-voice/buy-number" \
-d apiKey=YOUR_API_KEY \
-d id=3321{
"status": 1,
"data": { "order_id": 918274, "number": "+1 (628) 555-0147" }
}租用号码
将一个号码保留数小时、数天、数周或数月,并接收发往该号码的所有短信。
curl -G "https://smsonline.io/api/v1/rent-number/get-durations" \
-d apiKey=YOUR_API_KEY{
"status": 1,
"data": [
{ "type": "hour", "time": [1, 2, 4, 8, 12] },
{ "type": "day", "time": [1, 2, 3, 4, 5, 6, 7] }
]
}GET/rent-number/get-countries
可租用号码的国家,价格按你指定的周期计算。
查询参数
apiKey必填你的 API 密钥type必填hour、day、week 或 monthtime必填该周期的数量
curl -G "https://smsonline.io/api/v1/rent-number/get-countries" \
-d apiKey=YOUR_API_KEY \
-d type=day \
-d time=3{
"status": 1,
"type": "day",
"time": "3",
"data": [ { "id": 1, "name": "United States", "price": "2.85" } ]
}租用号码
从你的钱包扣款GET/rent-number/buy-number
创建待处理的租用订单,并从你的钱包扣款。订单完成后会分配号码。
查询参数
apiKey必填你的 API 密钥countryId必填来自“国家列表”的国家 IDtype必填hour、day、week 或 monthtime必填该周期的数量
curl -G "https://smsonline.io/api/v1/rent-number/buy-number" \
-d apiKey=YOUR_API_KEY \
-d countryId=1 \
-d type=day \
-d time=3{
"status": 1,
"data": { "order_id": 918275, "status": "pending", "type": "day", "time": "3" }
}礼品卡
游戏、商店和流媒体兑换码。订单由我们的团队确认,随后显示兑换码。
curl -G "https://smsonline.io/api/v1/giftcard/get-list" \
-d apiKey=YOUR_API_KEY{
"status": 1,
"data": [
{ "id": 12, "brand": "Steam", "name": "Steam $20 US", "face_value": "20.00",
"selling_price": "21.40", "currency_code": "USD", "category_name": "Games" }
]
}curl -G "https://smsonline.io/api/v1/giftcard/get-detail" \
-d apiKey=YOUR_API_KEY \
-d id=12{
"status": 1,
"data": { "id": 12, "brand": "Steam", "name": "Steam $20 US", "selling_price": "21.40" }
}curl -G "https://smsonline.io/api/v1/giftcard/buy" \
-d apiKey=YOUR_API_KEY \
-d id=12{
"status": 1,
"data": { "order_id": 918276, "order_status": "pending" }
}GET/giftcard/order-status
轮询订单。当 order_status 为 complete 时,会包含兑换码和序列号。
查询参数
apiKey必填你的 API 密钥orderId必填来自“购买礼品卡”的 order_id
curl -G "https://smsonline.io/api/v1/giftcard/order-status" \
-d apiKey=YOUR_API_KEY \
-d orderId=918276{
"status": 1,
"data": { "order_id": 918276, "order_status": "complete", "code": "XXXX-XXXX-XXXX", "serial": "8812…" }
}