📡 เอกสารการใช้งาน API คำคม

📡 เอกสารการใช้งาน API คำคม

🔑 การใช้งาน API Key

ทุกคำร้องขอ API ต้องส่ง ?api_key=YOUR_KEY

หากไม่มี หรือใส่ผิด จะได้รับ { success: false, error: "Invalid or missing API key" }

📋 Endpoint

https://k.omiomi.xyz/api/quotes.php?api_key=XXXX&limit=5&search=life&category=แรงบันดาลใจ&lang=th&random=1

🛠 พารามิเตอร์ที่ใช้ได้

📘 ตัวอย่างผลลัพธ์ (JSON)

{
  "success": true,
  "count": 1,
  "quotes": [
    {
      "id": 12,
      "quote": "จงใช้ชีวิตในแบบของคุณ",
      "quote_en": "Live your own life",
      "author": "นิรนาม",
      "image": "uploads/123abc.jpg",
      "category": "แรงบันดาลใจ"
    }
  ]
}

📦 ตัวอย่างโค้ดในแต่ละภาษา

PHP (cURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://k.omiomi.xyz/api/quotes.php?api_key=YOUR_KEY&limit=3');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$data = json_decode($res, true);
print_r($data);

JavaScript (fetch)

fetch('https://k.omiomi.xyz/api/quotes.php?api_key=YOUR_KEY&limit=3')
  .then(res => res.json())
  .then(data => console.log(data));

Python (requests)

import requests
res = requests.get('https://k.omiomi.xyz/api/quotes.php?api_key=YOUR_KEY&limit=3')
print(res.json())

cURL

curl "https://k.omiomi.xyz/api/quotes.php?api_key=YOUR_KEY&limit=3"

🧪 ทดสอบ API

© 2026 k.omiomi.xyz — เว็บไซต์คำคมแรกของไทยที่ให้ใช้งาน API ได้ฟรี