API สำหรับนักพัฒนา
ยืนยันตัวตนทาง SMS จากโค้ดของคุณโดยตรง
การเรียก HTTPS เพียงครั้งเดียวให้บอทหรือแพลตฟอร์มของคุณได้หมายเลขจริงสำหรับ WhatsApp, Telegram และบริการอื่นอีกมากมาย รับรหัสผ่านเว็บฮุกหรือ long polling และจ่ายเฉพาะหมายเลขที่ได้รับรหัส
- 2,281บริการ
- 200ประเทศ
- อัตโนมัติคืนเงินหากไม่ได้รับรหัส
curl
curl -s -X POST https://smsgrab.com/api/dev/v1/activations \
-H "Authorization: Bearer $SMSGRAB_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"service":"whatsapp","country":"indonesia"}'
Python
activation = requests.post(
"https://smsgrab.com/api/dev/v1/activations",
headers={"Authorization": f"Bearer {key}", "Idempotency-Key": str(uuid.uuid4())},
json={"service": "whatsapp", "country": "indonesia"},
timeout=30,
).json()
Node.js
const activation = await fetch('https://smsgrab.com/api/dev/v1/activations', {
method: 'POST',
headers: {
Authorization: `Bearer ${key}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({ service: 'whatsapp', country: 'indonesia' }),
}).then((response) => response.json());
PHP
$activation = json_decode((string) $client->post('activations', [
'json' => ['service' => 'whatsapp', 'country' => 'indonesia'],
'headers' => ['Idempotency-Key' => bin2hex(random_bytes(16))],
])->getBody(), true);
Go
order := map[string]any{"service": "whatsapp", "country": "indonesia"}
err := call("POST", "/activations", order, idempotencyKey(), &activation)
{
"id": "5c1d0c2e-9f3a-4b7e-8a61-2f0c9d4e7b10",
"compat_id": 100000123,
"status": "WAITING_SMS",
"service_id": "whatsapp",
"country_id": "indonesia",
"phone_number": "+6281234567890",
"price_minor": 17,
"currency": "USD",
"expires_at": "2026-09-27T10:25:00.000Z",
"sms": []
}
สร้างมาเพื่อระบบอัตโนมัติ
ทุกสิ่งที่การเชื่อมต่อของคุณต้องการ ด้วยคลังหมายเลข การบัญชี และการคืนเงินเดียวกับในแอป
-
REST API ที่เรียบง่าย
JSON ที่คาดเดาได้ การซื้อแบบ idempotent และเหตุผลข้อผิดพลาดที่ชัดเจนให้คุณจัดการได้
-
เว็บฮุกที่มีลายเซ็น
อีเวนต์ที่ลงลายเซ็น HMAC สำหรับทุกรหัสและการเปลี่ยนสถานะ พร้อมลองใหม่ได้ 24 ชั่วโมง
-
Long polling
ค้างคำขอไว้ได้ถึง 25 วินาทีและรับรหัสทันทีที่มาถึง
-
รองรับ sms-activate
ชี้เครื่องมือเดิมมาที่ปลายทางของเรา แอ็กชันและการตอบกลับยังเหมือนเดิม
-
คีย์ที่คุณควบคุม
คีย์อ่านอย่างเดียวหรือซื้อได้ รายการ IP ที่อนุญาต เพดานรายวัน วันหมดอายุ และหมุนเวียนโดยไม่หยุดระบบ
-
คืนเงินอัตโนมัติ
ไม่ได้รับรหัสก่อนหมายเลขหมดอายุ? เงินกลับเข้ายอดของคุณทันที
-
การใช้งานและบันทึกคำขอ
คำขอ ค่าใช้จ่าย และข้อผิดพลาดรายวันของแต่ละคีย์ พร้อมบันทึก 7 วันล่าสุดที่กรองได้
-
ราคาตามปริมาณ
ราคาเดียวกับในแอป พร้อมส่วนลดที่เพิ่มขึ้นอัตโนมัติตามปริมาณต่อเดือนของคุณ
เริ่มต้นใน 4 ขั้นตอน
อีกเพียงไม่กี่การเรียกก็ได้หมายเลขแรก
-
สร้างบัญชี
สมัครด้วยอีเมลและยืนยัน แอปและเว็บไซต์ใช้บัญชีเดียวกัน
-
สร้างคีย์ API
เลือกสิทธิ์ จำกัดคีย์ไว้ที่เซิร์ฟเวอร์ของคุณ และคัดลอกซีเคร็ตหนึ่งครั้ง
-
ซื้อหมายเลข
POST บริการและประเทศ หมายเลขและราคาจะกลับมาทันที
-
รับรหัส
รอผ่าน long polling หรือเว็บฮุก แล้วปิดการเปิดใช้งาน
ราคาที่ลดลงเมื่อคุณเติบโต
API คิดราคาเดียวกับแอป ส่วนลดขายส่งของคุณจะเพิ่มขึ้นตามยอดใช้จ่าย 30 วันล่าสุดในทุกช่องทาง
- ไม่แพงกว่าหมายเลขเดียวกันในแอป
- หมายเลขที่ไม่ได้รับรหัสจะคืนเงินอัตโนมัติ
- ระดับอัปเดตภายในไม่กี่นาทีหลังถึงเกณฑ์
- หักเป็น USD จากยอดเงินเดียวกับแอป
การย้ายระบบ
ย้ายจาก sms-activate ด้วยการแก้บรรทัดเดียว
ปลายทางที่รองรับของเราใช้โปรโตคอลเดียวกัน บอทและแผงควบคุมที่สร้างสำหรับ sms-activate จึงทำงานได้ทันทีที่เปลี่ยน URL หลักและคีย์
SMS-Activate ปิดตัวลงในเดือนธันวาคม 2025 ชี้เครื่องมือของคุณมาที่ SmsGrab แล้วใช้งานต่อได้ทันที
https://smsgrab.com/api/stubs/handler_api.php
- getNumber, getStatus, setStatus, getPrices และแอ็กชันมาตรฐานอื่น ๆ
- รหัสการเปิดใช้งานแบบตัวเลข รหัสบริการ และรหัสประเทศที่คุณใช้อยู่แล้ว
- คีย์ ขีดจำกัด ราคา การคืนเงิน และเว็บฮุกเดียวกับ REST API
curl
BASE="https://smsgrab.com/api/stubs/handler_api.php?api_key=$SMSGRAB_API_KEY"
curl -s -w '\n' "$BASE&action=getBalance"
curl -s -w '\n' "$BASE&action=getNumber&service=tg&country=6&maxPrice=0.30"
curl -s -w '\n' "$BASE&action=getStatus&id=100000123"
curl -s -w '\n' "$BASE&action=setStatus&id=100000123&status=6"
Python
import os
import time
import requests
BASE = "https://smsgrab.com/api/stubs/handler_api.php"
KEY = os.environ["SMSGRAB_API_KEY"]
def action(name: str, **params) -> str:
response = requests.get(BASE, params={"api_key": KEY, "action": name, **params}, timeout=30)
response.raise_for_status()
return response.text
print(action("getBalance"))
answer = action("getNumber", service="tg", country=6, maxPrice="0.30")
if not answer.startswith("ACCESS_NUMBER:"):
raise SystemExit(answer)
_, activation_id, number = answer.split(":")
print("Number:", number)
while True:
status = action("getStatus", id=activation_id)
if status.startswith("STATUS_OK:"):
print("Code:", status.split(":", 1)[1])
action("setStatus", id=activation_id, status=6)
break
if status == "STATUS_CANCEL":
print("Cancelled or expired, the charge was refunded")
break
time.sleep(5)
Node.js
const BASE = 'https://smsgrab.com/api/stubs/handler_api.php';
async function action(name, params = {}) {
const url = new URL(BASE);
url.search = new URLSearchParams({ api_key: process.env.SMSGRAB_API_KEY, action: name, ...params }).toString();
const response = await fetch(url, { signal: AbortSignal.timeout(30_000) });
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
return response.text();
}
console.log(await action('getBalance'));
const answer = await action('getNumber', { service: 'tg', country: '6', maxPrice: '0.30' });
if (!answer.startsWith('ACCESS_NUMBER:')) {
throw new Error(answer);
}
const [, id, number] = answer.split(':');
console.log('Number:', number);
for (;;) {
const status = await action('getStatus', { id });
if (status.startsWith('STATUS_OK:')) {
console.log('Code:', status.slice('STATUS_OK:'.length));
await action('setStatus', { id, status: '6' });
break;
}
if (status === 'STATUS_CANCEL') {
console.log('Cancelled or expired, the charge was refunded');
break;
}
await new Promise((resolve) => setTimeout(resolve, 5000));
}
PHP
<?php
function smsgrab(string $action, array $params = []): string
{
$query = http_build_query(['api_key' => getenv('SMSGRAB_API_KEY'), 'action' => $action] + $params);
$answer = file_get_contents('https://smsgrab.com/api/stubs/handler_api.php?'.$query, false, stream_context_create(['http' => ['timeout' => 30]]));
if ($answer === false) {
throw new RuntimeException('The request failed');
}
return $answer;
}
echo smsgrab('getBalance').PHP_EOL;
$answer = smsgrab('getNumber', ['service' => 'tg', 'country' => 6, 'maxPrice' => '0.30']);
if (! str_starts_with($answer, 'ACCESS_NUMBER:')) {
exit($answer.PHP_EOL);
}
[, $id, $number] = explode(':', $answer);
echo 'Number: '.$number.PHP_EOL;
while (true) {
$status = smsgrab('getStatus', ['id' => $id]);
if (str_starts_with($status, 'STATUS_OK:')) {
echo 'Code: '.substr($status, strlen('STATUS_OK:')).PHP_EOL;
smsgrab('setStatus', ['id' => $id, 'status' => 6]);
break;
}
if ($status === 'STATUS_CANCEL') {
echo 'Cancelled or expired, the charge was refunded'.PHP_EOL;
break;
}
sleep(5);
}
Go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
"time"
)
const base = "https://smsgrab.com/api/stubs/handler_api.php"
var client = &http.Client{Timeout: 30 * time.Second}
func action(name string, params url.Values) (string, error) {
query := url.Values{"api_key": {os.Getenv("SMSGRAB_API_KEY")}, "action": {name}}
for key, values := range params {
query[key] = values
}
response, err := client.Get(base + "?" + query.Encode())
if err != nil {
return "", err
}
defer response.Body.Close()
body, err := io.ReadAll(io.LimitReader(response.Body, 1<<20))
if err != nil {
return "", err
}
if response.StatusCode != http.StatusOK {
return "", fmt.Errorf("http %d: %s", response.StatusCode, body)
}
return string(body), nil
}
func main() {
answer, err := action("getNumber", url.Values{"service": {"tg"}, "country": {"6"}, "maxPrice": {"0.30"}})
if err != nil {
panic(err)
}
if !strings.HasPrefix(answer, "ACCESS_NUMBER:") {
fmt.Println(answer)
return
}
parts := strings.Split(answer, ":")
id := parts[1]
fmt.Println("Number:", parts[2])
for {
status, err := action("getStatus", url.Values{"id": {id}})
if err != nil {
panic(err)
}
if code, ok := strings.CutPrefix(status, "STATUS_OK:"); ok {
fmt.Println("Code:", code)
if _, err := action("setStatus", url.Values{"id": {id}, "status": {"6"}}); err != nil {
panic(err)
}
return
}
if status == "STATUS_CANCEL" {
fmt.Println("Cancelled or expired, the charge was refunded")
return
}
time.Sleep(5 * time.Second)
}
}
เรียลไทม์
รหัสส่งตรงถึงเซิร์ฟเวอร์ของคุณ
สมัครรับอีเวนต์ที่คุณสนใจ แล้วเราจะส่งไปยังปลายทาง HTTPS ของคุณพร้อมลายเซ็นที่ตรวจสอบได้
- ซื้อหมายเลขแล้ว
- ได้รับรหัสแล้ว
- การเปิดใช้งานเสร็จสิ้น
- ยกเลิกการเปิดใช้งาน
- การเปิดใช้งานหมดอายุ
- คืนเงินแล้ว
- ยอดเงินต่ำ
- สร้างการเติมเงินแล้ว
- กำลังยืนยันการเติมเงิน
- การเติมเงินเข้ายอดแล้ว
- การเติมเงินหมดอายุ
- การเติมเงินอยู่ระหว่างตรวจสอบ
- ทุกการส่งลงลายเซ็น HMAC-SHA256 พร้อมเวลาประทับ
- เฉพาะปลายทาง HTTPS สาธารณะ ตรวจสอบก่อนทุกการส่ง
- ส่งทดสอบ ประวัติ 30 วัน และส่งซ้ำในคลิกเดียว
คำถามจากนักพัฒนา
API สำหรับนักพัฒนาราคาเท่าไร
ไม่มีค่าสมาชิก แต่ละหมายเลขราคาเท่ากับในแอปและจ่ายจากยอดคงเหลือเดียวกัน ระดับตามปริมาณจะลดราคานี้เมื่อยอดใช้จ่าย 30 วันของคุณเพิ่มขึ้น และตัวแทนจำหน่ายที่ได้รับอนุมัติได้ส่วนลดคงที่ หมายเลขที่ไม่ได้รับรหัสจะคืนเงินอัตโนมัติ
ถ้าไม่ได้รับรหัสจะเป็นอย่างไร
หมายเลขใช้งานได้จนถึงเวลาหมดอายุที่แสดงไว้ โดยปกติ 10 ถึง 20 นาที หากไม่มีรหัสมาในช่วงนั้น หรือคุณยกเลิกหมายเลขขณะยังรออยู่ เงินจะกลับเข้ายอดของคุณโดยอัตโนมัติ
ใช้การเชื่อมต่อ sms-activate เดิมได้ไหม
ได้ เปลี่ยน URL หลักเป็นปลายทางที่รองรับของเราและใช้คีย์ SmsGrab แอ็กชันมาตรฐาน การตอบกลับ และรหัสตัวเลขยังเหมือนเดิม
ขีดจำกัดอัตราคืออะไร
โดยค่าเริ่มต้น แต่ละคีย์ส่งได้ 600 คำขอและซื้อได้ 60 ครั้งต่อนาที ทุกคีย์ในบัญชีรวมกันได้ 3000 คำขอต่อนาที และมีหมายเลขรอรหัสพร้อมกันได้สูงสุด 100 หมายเลข
จะปกป้องคีย์ได้อย่างไร
เก็บคีย์ไว้บนเซิร์ฟเวอร์เท่านั้น ให้แต่ละแอปมีคีย์ของตัวเอง จำกัดไว้ที่ที่อยู่เซิร์ฟเวอร์ และตั้งเพดานใช้จ่ายรายวัน หากคีย์อาจรั่วไหล ให้หมุนเวียนหรือเพิกถอนจากบัญชีของคุณ
คำตอบเพิ่มเติมใน ศูนย์ช่วยเหลือ