📖 API Documentation

v2.0.0
Server Online 🏠 Dashboard

🚀 Multi-API Manager

REST API สำหรับเข้าถึงข้อมูลที่ดึงมาจาก API ต่างๆ แบบ Real-time รองรับ Authentication, Rate Limiting, และ CORS

🔑
API Key Auth
ปลอดภัยด้วย API Key
⚡
Real-time Data
ข้อมูลอัปเดตตลอด
🌍
CORS Enabled
เรียกจาก Frontend ได้

💡 Base URL: http://localhost:3001

🔐 Authentication

ทุก endpoint (ยกเว้น /public-api/docs และ /public-api/health) ต้องใช้ API Key ในการเข้าถึง

วิธีที่ 1: HTTP Header (แนะนำ)

curl -H "x-api-key: YOUR_API_KEY" http://localhost:3001/public-api/data

วิธีที่ 2: Query Parameter

curl "http://localhost:3001/public-api/data?api_key=YOUR_API_KEY"

⚠️ สำคัญ: ห้ามเปิดเผย API Key ใน client-side code ที่ public ควรเรียก API ผ่าน Backend ของคุณเท่านั้น

🌐 API Endpoints

GET /public-api/health 🔓 ไม่ต้องใช้ API Key

ตรวจสอบสถานะของระบบ

{
  "status": "ok",
  "uptime": 3600.5,
  "timestamp": "2026-08-14T10:00:00.000Z",
  "apisRunning": 1,
  "totalApis": 1,
  "totalItems": 150,
  "telegramEnabled": true
}
GET /public-api/apis 🔑 ต้องใช้ API Key

ดึงรายชื่อ API ที่เปิดใช้งานทั้งหมด

GET /public-api/data 🔑 ต้องใช้ API Key

ดึงข้อมูลทั้งหมด (รองรับ Pagination)

Query Parameters:

Parameter Type Default Description
limit number 100 จำนวนรายการ (max: 1000)
offset number 0 เริ่มที่รายการที่
api_id string - กรองเฉพาะ API ที่ระบุ
GET /public-api/data/:apiId 🔑 ต้องใช้ API Key

ดึงข้อมูลของ API ที่ระบุ

GET /public-api/data/:apiId/latest 🔑 ต้องใช้ API Key

ดึงข้อมูลล่าสุด 1 รายการ

GET /public-api/search 🔑 ต้องใช้ API Key

ค้นหาข้อมูล

Query Parameters:

Parameter Type Required Description
q string ✅ ใช่ คำค้นหา
field string ไม่ ฟิลด์ที่จะค้นหา
api_id string ไม่ กรองเฉพาะ API
limit number ไม่ จำนวนรายการ (default: 50)
GET /public-api/stats 🔑 ต้องใช้ API Key

สถิติทั้งหมด

GET /public-api/stats/:apiId 🔑 ต้องใช้ API Key

สถิติของ API ที่ระบุ

🧪 Interactive API Tester

ทดสอบ API ได้เลยจากหน้านี้

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

const API_BASE = 'http://localhost:3001';
const API_KEY = 'your-api-key-here';

// ดึงข้อมูลล่าสุด
async function getLatestMessages() {
  const response = await fetch(`${API_BASE}/public-api/data/line-message-boxes/latest`, {
    headers: { 'x-api-key': API_KEY }
  });
  const data = await response.json();
  console.log('ข้อความล่าสุด:', data.data);
  return data;
}

// ค้นหาข้อความ
async function searchMessages(keyword) {
  const response = await fetch(
    `${API_BASE}/public-api/search?q=${encodeURIComponent(keyword)}&api_id=line-message-boxes`,
    { headers: { 'x-api-key': API_KEY } }
  );
  const data = await response.json();
  
  for (const item of data.data) {
    console.log(`[${item.altText}] ${item.detail}`);
  }
}

// ใช้งาน
getLatestMessages();
searchMessages('โอนเงิน');

⚠️ Error Codes

Code Status Description วิธีแก้
401 Unauthorized ไม่ได้ส่ง API Key เพิ่ม header x-api-key
403 Forbidden API Key ไม่ถูกต้อง ตรวจสอบ API Key ใน .env
404 Not Found ไม่พบ API หรือข้อมูล ตรวจสอบ api_id ที่ใช้
429 Too Many Requests เรียก API ถี่เกินไป รอ 15 นาที แล้วลองใหม่
500 Internal Error API_KEY ยังไม่ได้ตั้งค่า ตั้งค่า API_KEY ใน .env

⏱️ Rate Limiting

100
Requests / 15 นาที
15
นาที (Window)
429
Error เมื่อเกิน Limit