คู่มือการใช้งาน API360 Web API
/keys/createX-API-KEY: <API_KEY> ในทุกคำขอ💡 วิธีขอ API Key
/loginX-API-KEY: sk_live_your_api_key_here{
"success": false,
"error": "Unauthorized",
"message": "Invalid or missing API key"
}GET /api/v1/products เพื่อดึงข้อมูลสินค้าทั้งหมดlimit (จำนวนต่อหน้า), offset (จำนวนที่ข้าม)GET https://webapi360.trirex.cloud/api/v1/products?limit=10&offset=0
X-API-KEY: sk_live_your_api_key_here{
"success": true,
"message": "Products retrieved successfully",
"data": [
{
"id": 1,
"name": "iPhone 15 Pro",
"price": 45900,
"description": "สมาร์ทโฟนรุ่นล่าสุด",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
],
"pagination": {
"total": 100,
"limit": 10,
"offset": 0,
"hasMore": true
},
"auditId": 123
}GET /api/v1/products/:id เพื่อดึงข้อมูลสินค้าตาม IDGET https://webapi360.trirex.cloud/api/v1/products/1
X-API-KEY: sk_live_your_api_key_herePOST /api/v1/products เพื่อสร้างสินค้าใหม่X-API-KEY: <API_KEY>name - ชื่อสินค้า (บังคับ)price - ราคา (บังคับ)description - คำอธิบาย (ไม่บังคับ)POST https://webapi360.trirex.cloud/api/v1/products
X-API-KEY: sk_live_your_api_key_here
Content-Type: application/json
{
"name": "iPhone 15 Pro Max",
"price": 49900,
"description": "สมาร์ทโฟนรุ่นล่าสุด พร้อมกล้อง Pro"
}{
"success": true,
"message": "Product created successfully",
"data": {
"id": 1,
"name": "iPhone 15 Pro Max",
"price": 49900,
"description": "สมาร์ทโฟนรุ่นล่าสุด พร้อมกล้อง Pro",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
},
"auditId": 123
}{
"success": false,
"error": "Bad Request",
"message": "Name and price are required"
}PUT /api/v1/products/:id เพื่ออัพเดทสินค้าPUT https://webapi360.trirex.cloud/api/v1/products/1
X-API-KEY: sk_live_your_api_key_here
Content-Type: application/json
{
"name": "iPhone 15 Pro Max (Updated)",
"price": 47900
}{
"success": true,
"message": "Product updated successfully",
"data": {
"id": 1,
"name": "iPhone 15 Pro Max (Updated)",
"price": 47900,
"description": "สมาร์ทโฟนรุ่นล่าสุด พร้อมกล้อง Pro",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T01:00:00.000Z"
},
"auditId": 124
}DELETE /api/v1/products/:id เพื่อลบสินค้าDELETE https://webapi360.trirex.cloud/api/v1/products/1
X-API-KEY: sk_live_your_api_key_here{
"success": true,
"message": "Product deleted successfully",
"auditId": 125
}POST /api/sqlquery/execute เพื่อรันคำสั่ง SQLX-API-KEY: <API_KEY>{sqlQuery: "SELECT * FROM Products"}POST /api/sqlquery/execute - รันคำสั่ง SQL (SELECT, INSERT, UPDATE, DELETE)GET /api/sqlquery/query - รันคำสั่ง SQL แบบ GET (SELECT, INSERT, UPDATE, DELETE)POST https://webapi360.trirex.cloud/api/sqlquery/execute
X-API-KEY: sk_live_your_api_key_here
Content-Type: application/json
{
"sqlQuery": "SELECT * FROM Product"
}GET https://webapi360.trirex.cloud/api/sqlquery/query?sqlQuery=SELECT * FROM Product
X-API-KEY: sk_live_your_api_key_here{
"success": true,
"type": "select",
"data": [
{
"id": 1,
"name": "iPhone 15 Pro",
"price": 45900,
"description": "สมาร์ทโฟนรุ่นล่าสุด"
}
],
"count": 1,
"message": "เรียกข้อมูลสำเร็จ",
"auditId": 123
}INSERT:
{
"success": true,
"type": "insert",
"rowsAffected": 1,
"message": "เพิ่มข้อมูลสำเร็จ",
"auditId": 124
}UPDATE:
{
"success": true,
"type": "update",
"rowsAffected": 1,
"message": "อัปเดตข้อมูลสำเร็จ",
"auditId": 125
}DELETE:
{
"success": true,
"type": "delete",
"rowsAffected": 1,
"message": "ลบข้อมูลสำเร็จ",
"auditId": 126
}SELECT * FROM Product - ดูข้อมูล Products ทั้งหมดSELECT COUNT(*) as TotalProducts FROM Product - นับจำนวน ProductsSELECT id, name, price FROM Product WHERE price > 10000 - ดู Products ที่ราคามากกว่า 10000INSERT INTO Product (name, price, description) VALUES ('iPhone 16', 49900, 'สมาร์ทโฟนรุ่นใหม่') - เพิ่มข้อมูลUPDATE Product SET price = 44900 WHERE id = 1 - อัปเดตข้อมูลDELETE FROM Product WHERE id = 999 - ลบข้อมูล{
"success": false,
"error": "Forbidden SQL Command",
"message": "คำสั่ง SQL นี้ไม่ได้รับอนุญาตเพื่อความปลอดภัย",
"details": "อนุญาตเฉพาะคำสั่ง SELECT, INSERT, UPDATE, DELETE เท่านั้น"
}🚫 คำสั่ง SQL ที่ไม่ได้รับอนุญาต
⚠️ สิทธิ์การเข้าถึง
API Key ต้องมีสิทธิ์ที่เหมาะสมสำหรับแต่ละคำสั่ง SQL:
SELECT - ต้องมีสิทธิ์ INSERT - ต้องมีสิทธิ์ UPDATE - ต้องมีสิทธิ์ DELETE - ต้องมีสิทธิ์ curl -X GET "https://webapi360.trirex.cloud/api/v1/products?limit=10&offset=0" \
-H "X-API-KEY: YOUR_API_KEY"curl -X POST "https://webapi360.trirex.cloud/api/v1/products" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "iPhone 15 Pro",
"price": 45900,
"description": "สมาร์ทโฟนรุ่นล่าสุด"
}'curl -X PUT "https://webapi360.trirex.cloud/api/v1/products/1" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "iPhone 15 Pro (Updated)",
"price": 44900
}'curl -X DELETE "https://webapi360.trirex.cloud/api/v1/products/1" \
-H "X-API-KEY: YOUR_API_KEY"curl -X POST "https://webapi360.trirex.cloud/api/sqlquery/execute" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sqlQuery": "SELECT * FROM Product"
}'curl -X POST "https://webapi360.trirex.cloud/api/sqlquery/execute" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sqlQuery": "INSERT INTO Product (name, price, description) VALUES ('iPhone 16', 49900, 'สมาร์ทโฟนรุ่นใหม่')"
}'curl -X POST "https://webapi360.trirex.cloud/api/sqlquery/execute" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sqlQuery": "UPDATE Product SET price = 44900 WHERE id = 1"
}'curl -X POST "https://webapi360.trirex.cloud/api/sqlquery/execute" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sqlQuery": "DELETE FROM Product WHERE id = 999"
}'⚠️ สิทธิ์การเข้าถึง
API Key ต้องมีสิทธิ์ที่เหมาะสมสำหรับแต่ละ endpoint:
GET - ต้องมีสิทธิ์ POST - ต้องมีสิทธิ์ PUT - ต้องมีสิทธิ์ DELETE - ต้องมีสิทธิ์ ℹ️ Audit Logs
ทุกการเรียก API จะถูกบันทึกใน Audit Logs อัตโนมัติ เพื่อความปลอดภัยและการตรวจสอบ
🚫 Rate Limiting
ระบบจำกัดการเรียก API ที่ 100 requests ต่อนาทีต่อ IP Address