OTP24HR
เข้าสู่ระบบ

OTP24HR Reseller API

เชื่อมต่อระบบ OTP ของเราเข้ากับเว็บ/แอปของคุณ — ใช้ API key เดียวรับ OTP ได้จากทุกบริการ

API Key Auth JSON Response RESTful Custom Markup

เริ่มต้นใช้งาน

1. ขอ API Key

ติดต่อแอดมินเพื่อขอรับ API Key และเติมเงินเข้ากระเป๋าของบัญชีคุณ — ทุก request จะหักเงินจากกระเป๋านี้

2. Base URL

https://otp24hr.store/api/v1

3. Authentication — ส่ง API Key ได้ 4 วิธี

# 1) Header (แนะนำ) X-API-Key: your_api_key_here # 2) Bearer token Authorization: Bearer your_api_key_here # 3) Query string ?api_key=your_api_key_here # 4) JSON body {"api_key": "your_api_key_here"}

4. รูปแบบ Response

ทุก endpoint ตอบกลับเป็น JSON ที่มี field ok บอกสถานะ:

// สำเร็จ { "ok": true, /* ... data ... */ } // ผิดพลาด { "ok": false, "error": "ERROR_CODE", "message": "คำอธิบายเป็นภาษาไทย" }

Endpoints

GET /api/v1/services.php ดูรายการบริการ + ราคา (รวม markup ของคุณแล้ว)

Query Parameters

ParameterTypeDescription
country int optional รหัสประเทศ default = 52 (ไทย)

ตัวอย่าง Response

{ "ok": true, "country": 52, "count": 10, "services": [ { "code": "ka", "name": "SHOPEE", "price_thb": 15.00, "available": true } ] }
GET /api/v1/balance.php ดูยอดเงินคงเหลือในกระเป๋า
{ "ok": true, "balance_thb": 1500.00, "currency": "THB" }
POST /api/v1/buy.php ซื้อ OTP — ระบบหักเงินจากกระเป๋าทันที

Body (JSON)

ParameterTypeDescription
service string required service code เช่น ka, fb, tg
country int optional รหัสประเทศ default = 52
{ "ok": true, "order_id": 1672, "activation_id": 290188155, "phone": "66611529033", "service": "ka", "country": 52, "price_thb": 15.00, "expires_in_min": 20, "status": "waiting" }
curl -X POST "https://otp24hr.store/api/v1/buy.php" \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"service":"ka","country":52}'
$ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => 'https://otp24hr.store/api/v1/buy.php', CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'X-API-Key: YOUR_API_KEY', 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode([ 'service' => 'ka', 'country' => 52, ]), ]); $response = curl_exec($ch); $data = json_decode($response, true); if ($data['ok']) { echo "OTP เบอร์: " . $data['phone']; }
const res = await fetch('https://otp24hr.store/api/v1/buy.php', { method: 'POST', headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ service: 'ka', country: 52 }) }); const data = await res.json(); if (data.ok) console.log('Phone:', data.phone);
GET /api/v1/status.php เช็คสถานะ + รับ OTP code (ถ้ามาแล้ว)

Query Parameters

ParameterTypeDescription
order_id int required order ID จาก response ของ /buy

Response

{ "ok": true, "order_id": 1672, "phone": "66611529033", "status": "success", // waiting / success / cancel / timeout "otp_code": "123456", "price_thb": 15.00 }

💡 Tips: Poll endpoint นี้ทุก 5-10 วินาทีจนกว่า otp_code จะมีค่า หรือ status เปลี่ยนเป็น terminal state

POST /api/v1/cancel.php ยกเลิกออเดอร์ + คืนเงิน (ต้องผ่าน 2 นาทีหลังซื้อ)
ParameterTypeDescription
order_id int required order ID ที่ต้องการยกเลิก
{ "ok": true, "order_id": 1672, "refunded_thb": 15.00, "message": "ยกเลิก & คืนเงินเรียบร้อย" }
POST /api/v1/complete.php ยืนยันใช้ OTP สำเร็จ (เคลียร์ slot ที่ provider)
ParameterTypeDescription
order_id int required order ID
GET /api/v1/orders.php ประวัติออเดอร์ทั้งหมดที่ใช้ API key นี้
ParameterTypeDescription
limit int optional จำนวนรายการ default 50, max 200
offset int optional เริ่มที่รายการที่... default 0

Example Flow — ขั้นตอนการใช้งาน

ตัวอย่าง flow การซื้อ OTP สำหรับ Shopee:

// 1) เช็คยอดก่อน (ถ้าต้องการ) GET /api/v1/balance.php → { ok: true, balance_thb: 500 } // 2) ซื้อ OTP POST /api/v1/buy.php { service: "ka" } → { ok: true, order_id: 1672, phone: "66611529033", price_thb: 15 } // 3) ใช้เบอร์ที่ได้ไปสมัคร/login เว็บปลายทาง // 4) Poll สถานะทุก 5-10 วินาที GET /api/v1/status.php?order_id=1672 → { ok: true, status: "waiting", otp_code: "" } // ยังไม่มา → { ok: true, status: "success", otp_code: "123456" } // มาแล้ว! // 5) ยืนยันใช้แล้ว (optional) POST /api/v1/complete.php { order_id: 1672 } → { ok: true }

Error Codes

NO_API_KEYไม่ได้ส่ง API key มา
INVALID_API_KEYAPI key ไม่ถูกต้อง
API_KEY_DISABLEDAPI key ถูกปิดใช้งาน
IP_NOT_ALLOWEDIP ไม่อยู่ใน whitelist
RATE_LIMITส่ง request เกินขีดจำกัดต่อนาที
SERVICE_REQUIREDไม่ได้ระบุ service
SERVICE_NOT_FOUNDไม่พบ service code
INSUFFICIENT_BALANCEยอดในกระเป๋าไม่พอ
PROVIDER_ERRORprovider ปลายทางมีปัญหา
ORDER_NOT_FOUNDไม่พบออเดอร์ที่ระบุ
FORBIDDENออเดอร์นี้ไม่ใช่ของ key คุณ
EARLY_CANCEL_DENIEDยังยกเลิกไม่ได้ (ต้องผ่าน 2 นาที)