手机号码租用API
通过您的代码租用号码、读取接收的短信、延长及取消。通过HTTPS使用JSON格式,使用控制台中的一个API密钥。
- 基础URL
- https://snsnumber.com/api/v1
- 认证
- Authorization: Bearer snk_...
- 速率限制
- 每个密钥每分钟300次请求
在控制台的API下创建密钥。价格为美元字符串,保留两位小数。时间为UTC下的ISO 8601格式。
端点
GET
/balance您的余额,单位为美元。{ "balance": "120.00", "currency": "USD" }GET
/prices?country=us国家、租期及价格。省略国家参数则返回所有。{ "currency": "USD", "countries": [ { "country": "us", "name": "United States", "dial": "+1",
"periods": [ { "days": 15, "price": "36.00" }, { "days": 30, "price": "54.00" } ] } ] }POST
/rentals租用号码。请求体:国家及天数。curl -X POST https://snsnumber.com/api/v1/rentals -H "Authorization: Bearer snk_..." \
-H "Content-Type: application/json" -d '{"country":"us","days":30}'
{ "rental": { "id": "RN-7KQ2M9XWD4", "country": "us", "phone": "+14155550123", "state": "active",
"days": 30, "ends_at": "2026-12-03T10:00:00.000Z", "can_cancel": true, "messages": [] } }GET
/rentals?state=active您的租用号码,按最新排序(状态:有效、过期、已取消)。{ "rentals": [ { "id": "RN-7KQ2M9XWD4", "phone": "+14155550123", "state": "active", "message_count": 2 } ] }GET
/rentals/{id}一个租用号码及其收件箱。{ "rental": { "id": "RN-7KQ2M9XWD4", "messages": [ { "id": 18, "sender": "Verify",
"text": "Your verification code is 482913.", "code": "482913", "received_at": "2026-11-03T10:01:12.000Z" } ] } }POST
/rentals/{id}/extend为有效租用号码添加一个租期。天数:天。{"days":15} -> { "rental": { "id": "RN-7KQ2M9XWD4", "extensions": 1, "ends_at": "2026-12-18T10:00:00.000Z" } }POST
/rentals/{id}/cancel在20分钟内取消且未收到短信时全额退款。{ "rental": { "id": "RN-7KQ2M9XWD4", "state": "canceled" } }错误
错误返回HTTP状态和{ "error": { "code", "message" } }。
| 状态 | 代码 | 含义 |
|---|---|---|
| 401 | no_key, bad_key | 缺少或错误的API密钥 |
| 402 | no_balance | 余额不足 |
| 404 | not_found | 未找到租用号码 |
| 409 | ended, cancel_denied | 租用已结束,或取消窗口已过 |
| 429 | rate_limited, too_many_active | 每分钟300次请求,或20个有效号码 |
| 503 | network_error | 稍后再试 |