API 文档
通过 iLoveSMS REST API 或 SMS-Activate 协议自动购买号码。
您的个人 API 密钥位于账户设置中。 注册
REST JSON API v1
基础地址: https://ilovesms.com.tr/api/v1/ — 认证方式: ?api_key=… / Authorization: Bearer …
| Method | 参数 | 说明 |
|---|---|---|
GET services | — | 服务列表(含最低价和库存)。 |
GET countries | — | 国家列表。 |
GET prices | service | 某服务在各国的价格和库存。 |
GET balance | api_key | 您的余额。 |
POST buy | api_key, service, country_id | 购买号码,费用从余额扣除。 |
GET status | api_key, id | 订单状态和短信验证码。 |
POST cancel | api_key, id | 取消等待中的订单并退款。 |
POST finish | api_key, id | 收到验证码后关闭号码。 |
GET orders | api_key | 您最近的 100 个订单。 |
# 1) 购买号码
curl -X POST "https://ilovesms.com.tr/api/v1/buy" -d "api_key=YOUR_API_KEY" -d "service=tg" -d "country_id=12"
{"ok":true,"order":{"id":1042,"service":"Telegram","country":"USA","number":"12025550123",
"price":0.45,"status":"waiting","code":null,"seconds_left":1200}}
# 2) 每 5 秒查询一次,直到收到验证码
curl "https://ilovesms.com.tr/api/v1/status?api_key=YOUR_API_KEY&id=1042"
{"ok":true,"order":{"id":1042,"status":"received","code":"48213", ...}}
错误码: bad_key, bad_service, insufficient, no_numbers, not_cancelable, cancel_later
Webhooks
无需反复轮询:提供一个网址,收到验证码或订单退款时我们会推送 JSON 事件。
POST https://your-server.example/sms-webhook
Content-Type: application/json
X-Event: sms.received (sms.received | order.refunded | test)
X-Signature: sha256=<hmac_sha256(body, API_KEY)>
{"event":"sms.received","order":{"id":1042,"service":"Telegram","number":"12025550123","status":"received","code":"48213", ...},"sent_at":"2026-10-30T12:00:00+00:00"}
# PHP
$ok = hash_equals('sha256=' . hash_hmac('sha256', file_get_contents('php://input'), API_KEY), $_SERVER['HTTP_X_SIGNATURE']);
请在 5 秒内返回 HTTP 2xx。在此设置 Webhook 网址: 账户设置
兼容 SMS-Activate 的接口
为 SMS-Activate 协议开发的软件无需修改即可使用:只需替换基础地址和 API 密钥。
https://ilovesms.com.tr/stubs/handler_api.php?api_key=YOUR_API_KEY&action=getBalance → ACCESS_BALANCE:12.40
...&action=getNumber&service=tg&country=12 → ACCESS_NUMBER:1042:12025550123
...&action=getStatus&id=1042 → STATUS_WAIT_CODE | STATUS_OK:48213
...&action=setStatus&id=1042&status=8 → ACCESS_CANCEL
...&action=setStatus&id=1042&status=6 → ACCESS_ACTIVATION
...&action=getPrices&service=tg → {"12":{"tg":{"cost":0.45,"count":3120}}}
服务代码和国家 ID 与 services、countries 方法一致。