開發者API

大規模自動化驗證

SNSPhone API讓您的工具能夠訂購美國非VoIP號碼、讀取SMS驗證碼及管理租用服務。提供兩種格式:JSON格式的REST API,以及適用於現有腳本的通用SMS激活格式。

快速開始

基礎URL https://snsphone.com/api/v1。於控制台的API頁面創建密鑰並以Authorization: Bearer spk_...(或密鑰欄位)發送。所有號碼均為美國非VoIP。金額以2位小數的USD字串表示,時間為ISO 8601 UTC格式,每分鐘每密鑰限300次請求。價格截至2026-11-03。

Python

import os, time, requests

API = "https://snsphone.com/api/v1"
H = {"Authorization": f"Bearer {os.environ['SNSPHONE_KEY']}"}

order = requests.post(f"{API}/orders", headers=H, data={"service": "google"}).json()["order"]
print("Use this US number:", order["phone"])

while True:
    o = requests.get(f"{API}/orders/{order['id']}", headers=H).json()["order"]
    if o["code"] or o["status"] in ("refunded", "canceled"):
        break
    time.sleep(4)
print("Code:", o["code"])

Node.js

const API = "https://snsphone.com/api/v1";
const H = { Authorization: `Bearer ${process.env.SNSPHONE_KEY}` };

const { order } = await fetch(`${API}/orders`, {
  method: "POST", headers: H, body: new URLSearchParams({ service: "discord" }),
}).then((r) => r.json());
console.log("Use this US number:", order.phone);

let o = order;
while (!o.code && !["refunded", "canceled"].includes(o.status)) {
  await new Promise((r) => setTimeout(r, 4000));
  ({ order: o } = await fetch(`${API}/orders/${order.id}`, { headers: H }).then((r) => r.json()));
}
console.log("Code:", o.code);

目錄

GET/services

包含服務代碼、名稱、類別、驗證價格及租用期限的完整清單。無需密鑰。

公開,無需密鑰。

curl "https://snsphone.com/api/v1/services"
{"country":"us","services":[{"code":"whatsapp","name":"WhatsApp","category":"Messaging","verification":"0.90","rentals":[]},{"code":"telegram","name":"Telegram","verification":"0.45","rentals":[{"days":365,"period":"1 year","price":"37.44"}]}]}

GET/prices?service=telegram

以USD顯示價格,可選擇單一服務。無需密鑰。

公開,無需密鑰。

curl "https://snsphone.com/api/v1/prices?service=telegram"
{"country":"us","prices":[{"service":"telegram","type":"verification","days":null,"price":"0.45"},{"service":"telegram","type":"rental","days":365,"price":"37.44"}]}

GET/balance

您的餘額(USD)。

需要您的API密鑰。

curl "https://snsphone.com/api/v1/balance" \
  -H "Authorization: Bearer $KEY"
{"balance":"25.00","currency":"USD"}

驗證

POST/orders

購買一次驗證(201)。返回美國號碼及20分鐘驗證碼接收時段結束時間。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/orders" \
  -H "Authorization: Bearer $KEY" \
  -d "service=whatsapp"
{"order":{"id":"VR-7K2M9QX4PB","service":"whatsapp","country":"us","phone":"+14155550142","number":"4155550142","status":"waiting","code":null,"expires_at":"2026-11-03T12:20:00.000Z"},"window_minutes":20}

GET/orders/VR-7K2M9QX4PB

單次驗證的狀態及所有收到的驗證碼。狀態包括:waiting、received、finished、refunded、canceled。

需要您的API密鑰。

curl "https://snsphone.com/api/v1/orders/VR-7K2M9QX4PB" \
  -H "Authorization: Bearer $KEY"
{"order":{"id":"VR-7K2M9QX4PB","status":"received","code":"482913","sms":"Your WhatsApp code is 482913"}}

GET/orders?status=open

您未完成的驗證(status=all可查詢最近100筆)。

需要您的API密鑰。

curl "https://snsphone.com/api/v1/orders?status=open" \
  -H "Authorization: Bearer $KEY"
{"orders":[...]}

POST/orders/VR-7K2M9QX4PB/resend

於首次收到驗證碼且時段仍開放時,要求同一號碼再次發送驗證碼。無需額外費用。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/orders/VR-7K2M9QX4PB/resend" \
  -H "Authorization: Bearer $KEY"
{"order":{"status":"received","waiting_for_resend":true}}

POST/orders/VR-7K2M9QX4PB/finish

關閉已收到驗證碼的驗證。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/orders/VR-7K2M9QX4PB/finish" \
  -H "Authorization: Bearer $KEY"
{"order":{"status":"finished"}}

POST/orders/VR-7K2M9QX4PB/cancel

在驗證碼到達前取消。全額退回您的餘額。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/orders/VR-7K2M9QX4PB/cancel" \
  -H "Authorization: Bearer $KEY"
{"order":{"status":"canceled","refunded":"0.90"}}

租用

POST/rentals

租用美國號碼用於單一服務及期限(201)。當服務僅有一個期限時,days可省略。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/rentals" \
  -H "Authorization: Bearer $KEY" \
  -d "service=telegram&days=365"
{"rental":{"id":"RN-4J8T2W6QHM","service":"telegram","phone":"+13125550198","days":365,"period":"1 year","price":"37.44","status":"active","ends_at":"2027-11-03T12:00:00.000Z","messages":[]}}

GET/rentals?status=active

您現有的租用服務及其最新訊息(status=all可查詢最近100筆)。

需要您的API密鑰。

curl "https://snsphone.com/api/v1/rentals?status=active" \
  -H "Authorization: Bearer $KEY"
{"rentals":[...]}

GET/rentals/RN-4J8T2W6QHM

單筆租用服務及其所有收到的SMS。

需要您的API密鑰。

curl "https://snsphone.com/api/v1/rentals/RN-4J8T2W6QHM" \
  -H "Authorization: Bearer $KEY"
{"rental":{"id":"RN-4J8T2W6QHM","status":"active","messages":[{"from":"Telegram","sms":"Telegram code: 57291","code":"57291","received_at":"2026-11-03T12:01:12.000Z"}]}}

POST/rentals/RN-4J8T2W6QHM/renew

以相同價格延長一個期限。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/rentals/RN-4J8T2W6QHM/renew" \
  -H "Authorization: Bearer $KEY"
{"rental":{"renewed":1,"ends_at":"2028-11-02T12:00:00.000Z"}}

POST/rentals/RN-4J8T2W6QHM/cancel

於首20分鐘內且未收到任何SMS時取消。已支付金額全數退回您的餘額。

需要您的API密鑰。

curl -X POST "https://snsphone.com/api/v1/rentals/RN-4J8T2W6QHM/cancel" \
  -H "Authorization: Bearer $KEY"
{"rental":{"status":"canceled","refunded":"37.44"}}

SMS激活格式

適用於已支援通用激活格式的工具。單一URL、動作欄位、純文字回應。僅限驗證服務。

https://snsphone.com/stubs/handler_api.php?api_key=KEY&action=ACTION
動作額外欄位回應意義
getBalance無ACCESS_BALANCE:12.50您的餘額(USD)。
getServicesList無{"status":"success","services":[{"code":"whatsapp","name":"WhatsApp"}]}包含驗證價格的服務代碼(JSON格式)。
getCountries無{"us":{"name":"United States","dial":"1"}}僅限美國。country可填us、187或留空。
getPrices&service=whatsapp{"us":{"whatsapp":{"cost":0.9,"count":100}}}以USD顯示價格。服務篩選為可選。
getNumber&service=whatsapp&country=usACCESS_NUMBER:VR-7K2M9QX4PB:14155550142購買一次驗證。返回id及以1開頭的號碼。
getStatus&id=VR-7K2M9QX4PBSTATUS_OK:482913STATUS_WAIT_CODE、STATUS_OK:<code>、STATUS_WAIT_RETRY:<last code>(已要求再次發送驗證碼)、STATUS_CANCEL(已取消或退款)。
setStatus&id=VR-7K2M9QX4PB&status=3ACCESS_RETRY_GETstatus=1準備就緒(ACCESS_READY)、3再次發送驗證碼(ACCESS_RETRY_GET)、6完成(ACCESS_ACTIVATION)、8在驗證碼未到達前取消並全額退款(ACCESS_CANCEL)。

錯誤

REST錯誤以{"error":{"code","message"}}格式返回並附帶狀態碼。激活格式以純文字單詞回應。

400缺少或錯誤欄位 (bad_json, bad_period)。
401沒有提供或錯誤的密鑰 (no_key, bad_key)。
402餘額不足 (no_balance)。
404未知服務、訂單、租用或端點,或該服務未提供的產品 (not_sold)。
409目前無法操作 (has_code, has_sms, too_late, not_ready, too_many_open, too_many_active, no_numbers)。
429一分鐘內超過300次請求 (rate_limited)。
BAD_KEY缺少或錯誤的API密鑰。
BAD_ACTION未知操作。
BAD_SERVICE未知服務代碼。
BAD_COUNTRY非美國地區,或該服務僅提供租用。
NO_BALANCE餘額不足。
NO_NUMBERS目前沒有可用號碼,請稍後再試。
NO_ACTIVATION未知ID或非你所屬。
EARLY_CANCEL_DENIED驗證碼已送達,無法取消。
NO_ACTIVATIONS已有20個驗證進行中。
TOO_MANY_REQUESTS一分鐘內超過300次請求。

API問題

密鑰、限制與輪詢解答。

SNSPhone有提供SMS驗證API嗎?

有。提供REST API,JSON格式於/api/v1,用於服務、價格、驗證及租用,以及常見SMS激活格式於/stubs/handler_api.php。

如何驗證API請求?

在控制台的API頁面創建密鑰,並以Authorization: Bearer spk_...或key欄位發送。密鑰僅以哈希形式儲存且僅顯示一次。

API的速率限制是什麼?

每個密鑰每分鐘300次請求,每個帳戶最多20個進行中驗證及20個活躍租用。

API訂單會比網站訂單貴嗎?

不會。API使用與控制台相同的價格及退款規則。

如何知道驗證碼已送達?

每隔幾秒輪詢GET /orders/{id}。狀態會從waiting變為received,code欄位會包含數字。

非VoIP SMS驗證API:透過REST提供美國號碼 | SNSPhone