API Documentation

Back to Dashboard
API Overview

ระบบ AI Database Advisor API ให้บริการการวิเคราะห์ฐานข้อมูลผ่าน REST API

Base URL
https://ama.sky168.info
Content Type
application/json
Main Endpoints
Method Endpoint Description Parameters
POST /query ประมวลผลคำถามภาษาธรรมชาติ query (string)
GET /schema ดูโครงสร้างฐานข้อมูล -
GET /health ตรวจสอบสถานะระบบ -
GET /recommendations ดูคำแนะนำการปรับปรุง -
GET /performance ดูข้อมูลประสิทธิภาพ -
Query API Example
Request
POST /query
Content-Type: application/json

{
    "query": "มีสมาชิกทั้งหมดกี่คน"
}
Response
{
    "success": true,
    "data": {
        "answer": "คุณมีสมาชิกทั้งหมด 80,377 คน",
        "confidence": 0.95,
        "generated_sql": "SELECT COUNT(*) FROM member",
        "execution_time": 0.234,
        "sql_result": {
            "rows": [{"COUNT(*)": 80377}],
            "affected_rows": 1
        }
    }
}
Error Response
{
    "success": false,
    "error": "Invalid query format",
    "suggestions": [
        "Try asking in natural language",
        "Example: How many users do we have?"
    ]
}
Security Notes
  • Read-only database access
  • Rate limiting enabled
  • Input validation & sanitization
  • CSRF protection
cURL Examples
Basic Query
curl -X POST https://ama.sky168.info/query \
  -H "Content-Type: application/json" \
  -d '{"query": "How many users do we have?"}'
Get Schema
curl https://ama.sky168.info/schema
Health Check
curl https://ama.sky168.info/health