สำหรับนักพัฒนา

เอกสาร REST API

เข้าถึงบริการ 247xd ผ่าน API สำหรับระบบอัตโนมัติ

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

REST API ของ 247xd ให้คุณเข้าถึงบริการทั้งหมดผ่านโปรแกรม รวมถึงบริการ OTP, โซเชียลบูสเตอร์ และแอปพรีเมียม

Base URL:

https://247xd.com/api/v1

วิธีเริ่มต้น:

  1. ลงทะเบียนและเข้าสู่ระบบที่ 247xd.com
  2. ไปที่หน้าโปรไฟล์ > ตั้งค่า > สร้าง API Key
  3. คัดลอก API Key เก็บไว้ (แสดงเพียงครั้งเดียว)
  4. ใช้ API Key ในส่วนหัว Authorization ทุกครั้ง

2. การยืนยันตัวตน

ใช้ Bearer Token ในส่วนหัว Authorization สำหรับทุก request:

Header
Authorization: Bearer 247xd_a1b2c3d4e5f6...

API Key มีรูปแบบ 247xd_ ตามด้วย 40 ตัวอักษร หากคีย์ไม่ถูกต้องหรือหมดอายุ จะได้รับ HTTP 401

3. Rate Limits

จำกัดที่ 60 requests ต่อนาที ต่อผู้ใช้ ทุก response จะมีข้อมูล rate limit ในส่วนหัว:

Response Headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1709312400

เมื่อเกินขีดจำกัด จะได้รับ HTTP 429 พร้อมข้อความ RATE_LIMITED

4. รูปแบบ Response

ทุก response จะมีรูปแบบ JSON มาตรฐาน:

สำเร็จ
{
  "success": true,
  "data": { ... }
}
ข้อผิดพลาด
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "ไม่พบรายการ"
  }
}

5. ยอดเงินคงเหลือ

GET
/api/v1/balance

ดูยอดเหรียญคงเหลือในบัญชี

Response
{
  "success": true,
  "data": {
    "coins": 500.00
  }
}

6. บริการ OTP

GET
/api/v1/otp/services

ดูรายการบริการ OTP ทั้งหมดที่เปิดให้บริการ พร้อมตัวเลือกราคาและสต๊อก

POST
/api/v1/otp/orders

สั่งซื้อเบอร์ OTP

Request Body
{
  "serviceId": "uuid-of-service",
  "priceOptionId": "uuid-of-price-option"
}
Response (201)
{
  "success": true,
  "data": {
    "orderId": "uuid",
    "phoneNumber": "0812345678",
    "status": "waiting_sms",
    "price": 15.00,
    "expiresAt": "2024-01-01T00:20:00.000Z"
  }
}
GET
/api/v1/otp/orders/:orderId

ตรวจสอบสถานะคำสั่งซื้อ OTP รวมถึงรหัส OTP เมื่อได้รับแล้ว

POST
/api/v1/otp/orders/:orderId/cancel

ยกเลิกคำสั่งซื้อ (เฉพาะสถานะ waiting_sms)

POST
/api/v1/otp/orders/:orderId/refund

ขอคืนเงินจากคำสั่งซื้อที่ยกเลิกแล้ว

7. โซเชียลบูสเตอร์

GET
/api/v1/social/services

ดูรายการบริการโซเชียลบูสเตอร์ทั้งหมดที่เปิดให้บริการ

POST
/api/v1/social/orders

สั่งซื้อบริการโซเชียลบูสเตอร์

Request Body
{
  "optionId": "uuid-of-option",
  "link": "https://instagram.com/example",
  "quantity": 1000
}
Response (201)
{
  "success": true,
  "data": {
    "orderId": "uuid",
    "status": "pending",
    "price": 50.00
  }
}
GET
/api/v1/social/orders/:orderId

ตรวจสอบสถานะคำสั่งซื้อโซเชียลบูสเตอร์

POST
/api/v1/social/orders/:orderId/refund

ขอคืนเงินจากคำสั่งซื้อที่ถูกยกเลิก/ไม่สมบูรณ์

8. แอปพรีเมียม

GET
/api/v1/premium/services

ดูรายการแอปพรีเมียมทั้งหมดที่เปิดให้บริการ พร้อมสต๊อก

POST
/api/v1/premium/orders

สั่งซื้อแอปพรีเมียม

Request Body
{
  "serviceId": "uuid-of-service"
}
Response (201)
{
  "success": true,
  "data": {
    "orderId": "uuid",
    "credentials": { ... },
    "price": 99.00
  }
}
GET
/api/v1/premium/orders/:orderId

ดูรายละเอียดคำสั่งซื้อแอปพรีเมียม

9. รหัสข้อผิดพลาด

HTTPCodeคำอธิบาย
400VALIDATION_ERRORข้อมูลที่ส่งมาไม่ถูกต้อง
400BAD_REQUESTคำขอไม่ถูกต้อง
401UNAUTHORIZEDAPI Key ไม่ถูกต้องหรือไม่ได้ระบุ
403ACCOUNT_BANNEDบัญชีถูกระงับ
404NOT_FOUNDไม่พบข้อมูลที่ร้องขอ
429RATE_LIMITEDส่งคำขอมากเกินไป
500INTERNAL_ERRORข้อผิดพลาดภายในระบบ

10. ตัวอย่างโค้ด

cURL

ดูยอดเงิน
curl -X GET https://247xd.com/api/v1/balance \
  -H "Authorization: Bearer 247xd_your_api_key_here"
สั่งซื้อ OTP
curl -X POST https://247xd.com/api/v1/otp/orders \
  -H "Authorization: Bearer 247xd_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"serviceId": "...", "priceOptionId": "..."}'

Python

python
import requests

API_KEY = "247xd_your_api_key_here"
BASE_URL = "https://247xd.com/api/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

# ดูยอดเงิน
balance = requests.get(f"{BASE_URL}/balance", headers=HEADERS).json()
print(f"เหรียญ: {balance['data']['coins']}")

# ดูบริการ OTP
services = requests.get(f"{BASE_URL}/otp/services", headers=HEADERS).json()

# สั่งซื้อ OTP
order = requests.post(f"{BASE_URL}/otp/orders", headers=HEADERS, json={
    "serviceId": "...",
    "priceOptionId": "..."
}).json()

# ตรวจสอบสถานะ
order_id = order["data"]["orderId"]
status = requests.get(
    f"{BASE_URL}/otp/orders/{order_id}", headers=HEADERS
).json()
print(f"สถานะ: {status['data']['status']}")

JavaScript (Node.js)

javascript
const API_KEY = "247xd_your_api_key_here";
const BASE_URL = "https://247xd.com/api/v1";

const headers = {
  Authorization: `Bearer ${API_KEY}`,
  "Content-Type": "application/json",
};

// ดูยอดเงิน
const balance = await fetch(`${BASE_URL}/balance`, { headers });
const { data } = await balance.json();
console.log(`เหรียญ: ${data.coins}`);

// สั่งซื้อ OTP
const order = await fetch(`${BASE_URL}/otp/orders`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    serviceId: "...",
    priceOptionId: "...",
  }),
});
const result = await order.json();
console.log(`Order ID: ${result.data.orderId}`);
ติดต่อแอดมิน