🌿 OTP Shop Reseller API
API สำหรับตัวแทนจำหน่าย — ซื้อเบอร์ OTP, ตรวจสอบ SMS, จัดการออเดอร์ ทั้งหมดผ่าน REST API
Base URL:
รองรับทั้ง JSON body และ query parameters / ทุก response เป็น JSON
https://tangshop.site/cc/api/reseller/รองรับทั้ง JSON body และ query parameters / ทุก response เป็น JSON
📄 ไฟล์สำหรับส่งต่อ: README.md (คู่มือเชื่อมระบบ) และ openapi.json (OpenAPI 3.0)
🔑 การยืนยันตัวตน (Authentication)
ทุก request ต้องส่ง API Key — แนะนำให้ส่งผ่าน Header:
| วิธี | ตัวอย่าง |
|---|---|
| Header (แนะนำ) | Authorization: Bearer YOUR_API_KEY |
| Header | X-API-Key: YOUR_API_KEY |
| Query Param (ระบบเดิม) | ?api_key=YOUR_API_KEY |
| JSON Body (ระบบเดิม) | { "api_key": "YOUR_API_KEY" } |
ตัวอย่าง curlcurl -H "Authorization: Bearer YOUR_API_KEY" https://tangshop.site/cc/api/reseller/get_balance.php
วิธีสร้าง API Key: เข้าเมนู "API" ในเว็บร้านค้า แล้วตั้ง PIN + กดปุ่ม "สร้าง API Key"
ความปลอดภัย: ห้ามฝัง API Key ใน JavaScript ฝั่ง browser หรือเปิดเผยให้ผู้อื่น
⚠️ Error Codes
ทุก response จะมีรูปแบบเดียวกัน:
{
"success": true | false,
"message": "ข้อความ",
"data": { ... } | null
}
| HTTP Code | ความหมาย |
|---|---|
| 200 | สำเร็จ |
| 400 | ข้อมูลไม่ครบ / ไม่ถูกต้อง |
| 401 | API Key ไม่ถูกต้อง |
| 402 | ยอดเงินไม่เพียงพอ |
| 404 | ไม่พบข้อมูล |
| 500 | ระบบขัดข้อง |
| 503 | บริการไม่พร้อมชั่วคราว (เบอร์หมด) |
🌐 SMSBower-Compatible API
Endpoint นี้รับ request ในรูปแบบเดียวกับ https://smsbower.page/stubs/handler_api.php ทุกประการ — เปลี่ยน base URL อย่างเดียว client library ของ SMSBower เดิมก็ใช้ได้ทันที
Base URL:
Method: GET หรือ POST
Server: ใช้ได้กับ
https://tangshop.site/cc/api/reseller/handler_api.phpMethod: GET หรือ POST
Server: ใช้ได้กับ
server1 เท่านั้น (country = 52 = Thailand)Activation ID: ใช้
order_id ของระบบเรา (ที่ผูกกับบัญชีคุณ) — ปลอดภัยกว่าและตรวจสอบสิทธิ์ได้getBalance — ดูยอดเงิน
GET/api/reseller/handler_api.php?action=getBalance
ตัวอย่างhttps://tangshop.site/cc/api/reseller/handler_api.php?api_key=YOUR_API_KEY&action=getBalance
Response (text/plain)
ACCESS_BALANCE:1500.00
Errors
| Response | ความหมาย |
|---|---|
BAD_KEY | API key ไม่ถูกต้อง |
getNumber / getNumberV2 — ขอเบอร์
GET/api/reseller/handler_api.php?action=getNumber
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| service | string | required รหัสบริการ เช่น go, wa, tg |
| country | string | optional default 52 (ไทย) — ระบบรองรับเฉพาะ 52 |
| maxPrice / providerIds / etc. | — | ignored ระบบเรามี logic เลือก provider/maxPrice เอง (กันขาดทุน) |
Response (text/plain) สำเร็จ
ACCESS_NUMBER:123456:66812345678 │ │ │ └── เบอร์โทร └────────── activationId (ใช้เก็บไว้สำหรับ getStatus / setStatus)
Response (JSON) สำหรับ getNumberV2
{
"activationId": "123456",
"phoneNumber": "66812345678",
"activationCost": 9.00,
"countryCode": "52",
"canGetAnotherSms": true,
"activationTime": "2026-05-04 12:00:00",
"activationOperator": "auto"
}
Errors
| Response | ความหมาย |
|---|---|
BAD_KEY | API key ไม่ถูกต้อง |
BAD_SERVICE | รหัสบริการไม่ถูกต้องหรือถูกปิด |
BAD_COUNTRY | ระบุ country ที่ไม่ใช่ 52 |
NO_NUMBERS | ไม่มีเบอร์ว่าง / ต้นทุนสูงกว่าราคาขาย |
NO_BALANCE | ยอดเงินไม่พอ |
getStatus — เช็ค SMS
GET/api/reseller/handler_api.php?action=getStatus
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| id | integer | required activationId ที่ได้จาก getNumber |
Possible Responses
| Response | ความหมาย |
|---|---|
STATUS_WAIT_CODE | กำลังรอ SMS |
STATUS_OK:code | ได้รับรหัสแล้ว เช่น STATUS_OK:123456 |
STATUS_WAIT_RETRY:lastCode | รอ SMS รอบถัดไป (มีรหัสเก่าให้ดู) |
STATUS_CANCEL | ออเดอร์ถูกยกเลิก |
NO_ACTIVATION | ไม่พบรายการ |
setStatus — เปลี่ยนสถานะ
GET/api/reseller/handler_api.php?action=setStatus
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| id | integer | required activationId |
| status | integer | required 1=ready, 3=resend, 6=complete, 8=cancel |
ตัวอย่าง: ยกเลิกhttps://tangshop.site/cc/api/reseller/handler_api.php?api_key=YOUR_API_KEY&action=setStatus&id=123456&status=8
Possible Responses
| Response | ความหมาย |
|---|---|
ACCESS_READY | status=1: แจ้งพร้อมแล้ว |
ACCESS_RETRY_GET | status=3: รอ SMS ใหม่ (มีค่าใช้จ่ายตาม setting) |
ACCESS_ACTIVATION | status=6: ยืนยันใช้งานสำเร็จ |
ACCESS_CANCEL | status=8: ยกเลิกและคืนเงินแล้ว |
EARLY_CANCEL_DENIED | ยกเลิกเร็วเกินไป (ต้องรอ ≥2 นาที) |
BAD_STATUS | status ไม่ถูกต้อง / ออเดอร์ได้ rหัสแล้ว |
NO_ACTIVATION | ไม่พบรายการ |
getPrices / getPricesV2 / getPricesV3 — ดูราคา
GET/api/reseller/handler_api.php?action=getPrices
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| service | string | optional รหัสบริการ — ไม่ระบุ = ทุกบริการ |
| country | string | optional default 52 |
Response (getPrices) — JSON
{
"52": {
"go": { "cost": 9.00, "count": 999 },
"wa": { "cost": 12.00, "count": 999 }
}
}
Response (getPricesV3) — JSON
{
"52": {
"go": {
"auto": {
"count": 999,
"price": 9.00,
"provider_id": "auto"
}
}
}
}
หมายเหตุ: ราคาที่แสดงเป็น ราคาหลังหักส่วนลดของ user แล้ว — ใช้คำนวณยอดได้ตรงเลย
getServicesList — รายการบริการ
GET/api/reseller/handler_api.php?action=getServicesList
Response — JSON
{
"status": "success",
"services": [
{ "code": "go", "name": "Google" },
{ "code": "wa", "name": "WhatsApp" }
]
}
getCountries — รายการประเทศ
GET/api/reseller/handler_api.php?action=getCountries
Response — JSON
{
"52": {
"id": 52,
"rus": "Таиланд",
"eng": "Thailand",
"chn": "泰国"
}
}
หมายเหตุ: ระบบนี้รองรับเฉพาะประเทศไทย (server1)
💰 ดูยอดเงินคงเหลือ
GET/api/reseller/get_balance.php
ลองเลย
Response
{
"success": true,
"message": "ดึงยอดเงินสำเร็จ",
"data": {
"user_id": 42,
"balance": 1500.00,
"currency": "THB"
}
}
🌍 ดูรหัสประเทศ
GET/api/reseller/get_countries.php
ใช้รหัส id ที่ได้จาก endpoint นี้ไปส่งเป็น country ใน get_services.php และ buy_otp.php
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| server | string | optional server1 (default) หรือ server2 |
Response
{
"success": true,
"data": {
"server": "server1",
"source": "provider",
"count": 2,
"countries": [
{ "id": "52", "name": "Thailand", "name_th": "ไทย" },
{ "id": "4", "name": "Philippines", "name_th": "ฟิลิปปินส์" }
]
}
}
Fallback: ถ้าผู้ให้บริการล่ม ระบบจะส่งประเทศยอดนิยมพร้อม
source: "fallback" และ warning📦 ดูรายการบริการ
GET/api/reseller/get_services.php
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| server | string | optional server1 (default) หรือ server2 |
| country | string | optional รหัสประเทศจาก get_countries.php เช่น 52 — ถ้าส่ง จะกรองเฉพาะแอพที่รองรับประเทศนั้น |
| in_stock | string | optional 1 = เฉพาะบริการที่มีสต็อกมากกว่า 0 |
ลองเลย
บริการทั้งหมดที่เปิดขายhttps://tangshop.site/cc/api/reseller/get_services.php?api_key=YOUR_API_KEY&server=server1
ประเทศไทย + เฉพาะที่มีของhttps://tangshop.site/cc/api/reseller/get_services.php?api_key=YOUR_API_KEY&server=server1&country=52&in_stock=1
Response
{
"success": true,
"data": {
"server": "server1",
"country": "52",
"in_stock": true,
"count": 1,
"services": [
{
"id": 1,
"code": "tg",
"name": "Telegram",
"original_price": 10.00,
"price": 9.00,
"discount": 1.00,
"image_url": "https://...",
"category": null,
"server": "server1",
"stock_count": 24,
"available": true
}
]
}
}
เปิดขายเท่านั้น: ระบบกรอง
is_active = 1 ให้อัตโนมัติ และ price คือราคาหลังหักส่วนลดรายบุคคลแล้ว🛒 สั่งซื้อเบอร์ OTP
POST/api/reseller/buy_otp.php
Request Body (JSON)
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| service_id | integer | required ID บริการจาก get_services |
| server | string | optional server1 (default) หรือ server2 |
| quantity | integer | optional จำนวนเบอร์ 1-15 (default: 1) |
| country | string | optional รหัสประเทศจาก get_countries.php เช่น 52 — แนะนำให้ส่งทุกครั้ง |
Request ตัวอย่าง
{
"service_id": 1,
"server": "server1",
"quantity": 2,
"country": "52"
}
ส่ง API Key ผ่าน header
Authorization: Bearer YOUR_API_KEY (แนะนำ) หรือ X-API-KeyResponse (สำเร็จ)
{
"success": true,
"message": "สั่งซื้อสำเร็จ 2 เบอร์",
"data": {
"quantity": 2,
"unit_price": 9.00,
"total_price": 18.00,
"original_unit_price": 10.00,
"discount_per_unit": 1.00,
"remaining_balance": 1482.00,
"server": "server1",
"country": "52",
"order_ids": [501, 502],
"orders": [
{
"order_id": 501,
"activation_id": "123456789",
"phone_number": "+66812345678",
"price": 9.00
}
]
}
}
สำคัญ: ถ้าซื้อหลายเบอร์แต่ของผู้ให้บริการมีไม่ครบ
quantity จะเป็นจำนวนที่สำเร็จจริง และคิดเงินตามจำนวนนั้น — ควรใช้ order_ids จาก response📩 ตรวจสอบ SMS / OTP Code
POST/api/reseller/check_sms.php
Request Body (JSON)
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| order_id | integer | required ID ออเดอร์ที่ได้จาก buy_otp |
Request ตัวอย่าง
{
"api_key": "YOUR_API_KEY",
"order_id": 501
}
Response
{
"success": true,
"data": {
"order_id": 501,
"phone_number": "+66812345678",
"sms_code": "123456", // null = ยังไม่ได้รับ
"status": "COMPLETED",
"service_name": "Telegram"
}
}
สำคัญ: หาก
sms_code เป็น null ยังไม่ได้รับ SMS — ให้ poll ซ้ำทุก 5 วินาที (ไม่เกิน 2 นาที)⚡ ดำเนินการเบอร์ (ยกเลิก / อื่น ๆ)
POST/api/reseller/activation_action.php
Request Body (JSON)
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| order_id | integer | required ID ออเดอร์ |
| action | integer | required รหัสการดำเนินการ |
Action Codes
| Code | ความหมาย | คำอธิบาย |
|---|---|---|
1 | Ready | แจ้งว่าพร้อมรับ SMS |
3 | Resend | ขอส่ง SMS ซ้ำ |
6 | Complete | เสร็จสิ้นการใช้งานเบอร์ |
8 | Cancel | ยกเลิกเบอร์ (คืนเงิน) |
Request ตัวอย่าง
{
"api_key": "YOUR_API_KEY",
"order_id": 501,
"action": 8 // ยกเลิก
}
📋 ดูประวัติสั่งซื้อ
GET/api/reseller/get_orders.php
Query Parameters
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| page | integer | optional หน้าที่ (default: 1) |
| limit | integer | optional จำนวนต่อหน้า 1-100 (default: 20) |
| status | string | optional กรองสถานะ: WAITING, COMPLETED, CANCELLED |
ลองเลย
Response
{
"success": true,
"data": {
"page": 1,
"limit": 20,
"total": 156,
"total_pages": 8,
"orders": [
{
"id": 501,
"phone_number": "+66812345678",
"sms_code": "123456",
"price": 9.00,
"status": "COMPLETED",
"server": "server1",
"service_name": "Telegram",
"created_at": "2026-04-06 12:30:00"
}
]
}
}
🏷️ ส่วนลดรายบุคคล
ระบบรองรับส่วนลดรายบุคคลที่แอดมินตั้งค่าให้:
| ประเภท | คำอธิบาย | ตัวอย่าง |
|---|---|---|
| เปอร์เซ็นต์ (%) | ลดราคาเป็น % จากราคาเต็ม | ส่วนลด 10% → ราคา 10฿ เหลือ 9฿ |
| จำนวนเงิน (฿) | ลดราคาเป็นจำนวนเงินคงที่ | ส่วนลด 2฿ → ราคา 10฿ เหลือ 8฿ |
ส่วนลดเฉพาะบริการจะมีลำดับสำคัญกว่าส่วนลดทุกบริการ
ราคาหลังส่วนลดแสดงอัตโนมัติใน get_services และถูกใช้จริงใน buy_otp
🚀 ตัวอย่าง Flow การใช้งาน
ทุก request ส่ง API Key ผ่าน header
Authorization: Bearer YOUR_KEY1
2
3
สั่งซื้อเบอร์
ส่ง POST พร้อม JSON body:
{
"service_id": 1,
"server": "server1",
"quantity": 1,
"country": "52"
}จดจำ order_id จาก response ไว้ใช้ขั้นตอนถัดไป
4
รอรับ SMS (poll ทุก 5 วินาที)
ส่ง POST ซ้ำจนกว่า sms_code จะมีค่า:
{
"order_id": 501
}5
เสร็จสิ้น หรือ ยกเลิก
{
"order_id": 501,
"action": 6 // 6=เสร็จ, 8=ยกเลิก
}💻 ตัวอย่างโค้ด
Python
import requests, time API_KEY = "YOUR_API_KEY" BASE = "https://tangshop.site/cc/api/reseller" # 1. ดูยอดเงิน r = requests.get(f"{BASE}/get_balance.php?api_key={API_KEY}") print(r.json()) # 2. ดูบริการ r = requests.get(f"{BASE}/get_services.php?api_key={API_KEY}") services = r.json()["data"]["services"] # 3. สั่งซื้อ r = requests.post(f"{BASE}/buy_otp.php", json={ "api_key": API_KEY, "service_id": 1, "quantity": 1, "country": "52" }) order_id = r.json()["data"]["orders"][0]["order_id"] # 4. รอ SMS for _ in range(24): r = requests.post(f"{BASE}/check_sms.php", json={ "api_key": API_KEY, "order_id": order_id }) code = r.json()["data"].get("sms_code") if code: print(f"OTP: {code}") break time.sleep(5)
JavaScript
const API_KEY = "YOUR_API_KEY"; const BASE = "https://tangshop.site/cc/api/reseller"; // ดูยอดเงิน const res = await fetch(`${BASE}/get_balance.php?api_key=${API_KEY}`); console.log(await res.json()); // สั่งซื้อ const buy = await fetch(`${BASE}/buy_otp.php`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ api_key: API_KEY, service_id: 1, quantity: 1, country: "52" }) }); console.log(await buy.json());
PHP
$apiKey = "YOUR_API_KEY"; $base = "https://tangshop.site/cc/api/reseller"; // ดูยอดเงิน $res = file_get_contents("{$base}/get_balance.php?api_key={$apiKey}"); $data = json_decode($res, true); // สั่งซื้อ $ch = curl_init("{$base}/buy_otp.php"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ["Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode([ "api_key" => $apiKey, "service_id" => 1, "quantity" => 1, "country" => "52" ]) ]); $result = json_decode(curl_exec($ch), true);
ต้องการความช่วยเหลือ? ติดต่อแอดมินเพื่อขอ API Key และข้อมูลเพิ่มเติม