STAGING

คู่มือการเชื่อมต่อ API

REST API v1.0.0 สำหรับนักพัฒนาและเชื่อมต่อภายนอก


ยินดีต้อนรับสู่ระบบนักพัฒนาของ ThaiProMax คุณสามารถใช้ REST API ของเราเพื่อเชื่อมต่อบริการตรวจสอบข้อมูลและส่งเจเนอเรตข้อมูล AI จากระบบงานของคุณเองได้โดยตรงผ่านระบบ HTTP

1. การยืนยันตัวตน (Authentication)

การเรียกใช้งาน API ทุก Request จะต้องแนบ API Key ที่สร้างจากหน้าแดชบอร์ด "API Key" โดยส่งผ่าน HTTP Request Header ในรูปแบบ Bearer Token ดังนี้:

Authorization: Bearer your_api_key_here
2. ดึงข้อมูลผู้ใช้และเครดิต (GET /api/v1/me)

ใช้เพื่อตรวจสอบประเภทแผนสมัครสมาชิก ยอดพ๊อยต์รายเดือน และเครดิตสะสมในกระเป๋าเงินของคุณ

GET /api/v1/me

ตัวอย่างคำตอบรับกลับจากระบบ (JSON Response):

{
  "subscription": {
    "plan": "premium",
    "planName": "Premium Plan",
    "status": "active",
    "billingCycle": "monthly",
    "periodStart": "2026-06-01T00:00:00.000Z",
    "periodEnd": "2026-07-01T00:00:00.000Z",
    "pointsRemaining": 42500,
    "pointsLimit": 44000,
    "pointsUsed": 1500
  },
  "wallet": {
    "credits": 5000
  }
}
3. สั่งเจเนอเรตข้อมูล AI (GET /api/v1/generate)

ส่งคำสั่งเจเนอเรตตามประเภทบริการ (หักเครดิตหรือพ๊อยต์ตามโครงสร้างที่จำแนกไว้)

GET /api/v1/generate?capabilityKey=gen_light
Query Parameters:
ตัวแปร ประเภท คำอธิบาย
capabilityKey String (บังคับ) ระบุคีย์ความสามารถ: gen_light (10 Credits) หรือ gen_heavy (1,000 Credits)

ตัวอย่างคำตอบรับกลับจากระบบ (JSON Response):

{
  "ok": true,
  "newValue": 42,
  "capabilityKey": "gen_light",
  "costCredits": 10,
  "source": "points",
  "newCredits": null,
  "newPoints": 42490
}
4. ตัวอย่างการเขียนโปรแกรม (Code Snippets)
curl -X GET "https://example.com/api/v1/generate?capabilityKey=gen_light" \
  -H "Authorization: Bearer your_api_key_here"
const apiKey = 'your_api_key_here';
const url = 'https://example.com/api/v1/generate?capabilityKey=gen_light';

fetch(url, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Accept': 'application/json'
  }
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
import requests

api_key = "your_api_key_here"
url = "https://example.com/api/v1/me"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Accept": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())
AI Assistant
Please Sign In

Sign in to chat with our smart AI assistant in real-time.

Sign In