API สำหรับนักพัฒนา Developer API

ข้อมูลเพลงไทยแบบอ่านอย่างเดียว เป็น JSON — ต้องมี API key ติดต่อขอได้ที่ [email protected] Read-only JSON data on Thai music releases. An API key is required — email us to get one.

การยืนยันตัวตน Authentication

curl -H "Authorization: Bearer tmt_…" \
  "https://thaimusictimeline.com/api/v1/search?q=bird"

ส่ง key ใน header เท่านั้น ห้ามใส่ใน URL หรือโค้ดฝั่งเบราว์เซอร์ Send the key in a header only — never in URLs or browser code.

Endpoint Endpoints

  • GET /api/v1/search?q={query}&limit={1-20}ค้นหาเพลงและศิลปิน Search songs and artists
  • GET /api/v1/songs/{slug}ข้อมูลเพลง Song details
  • GET /api/v1/artists/{slug}ศิลปิน + ผลงานตามเวลา Artist and works in time order
  • GET /api/v1/labels/{slug}ค่ายเพลง + ผลงาน Label and its songs
  • GET /api/v1/years/{yyyy}เพลงทั้งปี (ค.ศ. หรือ พ.ศ.) Songs of a year (CE or BE)

slug คือส่วนท้ายของ URL หน้าเว็บ เช่น /song/{slug} หรือได้จากผลค้นหา A slug is the last part of the page URL, or comes from search results.

รูปแบบข้อมูล Response format

{
  "data": {
    "slug": "…",
    "title_th": "…",
    "title_en": null,
    "release": { "date": "1995-06", "precision": "month",
                 "year_ce": 1995, "year_be": 2538 },
    "artists": [{ "slug": "…", "name_th": "…", "role": "main", "url": "…" }],
    "ids": { "musicbrainz": "…", "wikidata": "Q…" }
  },
  "attribution": { "source": "thaimusictimeline.com", … }
}
  • วันที่ออกตัดตามความแม่นยำที่รู้จริง (day / month / year) — ห้ามเติมวันหรือเดือนเอง Dates are truncated to their known precision — never pad unknown days or months.
  • ไม่มีเนื้อเพลงหรือท่อนฮุกใน API No lyrics or hook lines are available through the API.
  • youtube_video_id มีเฉพาะคลิปจากช่องทางการที่ทีมงานตรวจแล้ว youtube_video_id is set only for editor-verified official channels.

Sandbox และความปลอดภัยของ key Sandbox and key security

  • ผู้ขอรายใหม่ได้ sandbox key (ขึ้นต้น tmt_test_) ก่อน: ข้อมูลจริงชุดเดียวกัน แต่จำกัด 10 ครั้ง/นาที 500 ครั้ง/วัน และหมดอายุใน 30 วัน — ทุก response มี header X-API-Mode: sandbox New applicants first get a sandbox key (starting tmt_test_): the same real data, limited to 10 requests/minute and 500/day, expiring after 30 days. Every response carries X-API-Mode: sandbox.
  • เมื่อพร้อมใช้งานจริง ขอ live key (tmt_…) พร้อมบอกการใช้งานและ IP ของเซิร์ฟเวอร์ — key ผูกกับ IP นั้นได้ When you go to production, ask for a live key (tmt_…) and tell us your use and your server's IP; the key can be locked to it.
  • เรียก API จากเซิร์ฟเวอร์เท่านั้น ห้ามใส่ key ในแอปมือถือ เว็บฝั่ง browser หรือ repository สาธารณะ — key หลุดแจ้งเราเพื่อยกเลิกและออกใหม่ Call the API from your server only. Never put a key in a mobile app, browser code or a public repository; if one leaks, tell us so we can revoke it and issue a new one.
  • ส่ง key ทาง header เท่านั้น (ไม่รับใน URL) เพื่อไม่ให้ไปค้างใน log หรือประวัติ browser Keys are accepted in headers only, never in the URL, so they do not end up in logs or browser history.

ขีดจำกัดและ error Limits and errors

แต่ละ key มีขีดจำกัดต่อนาทีและโควตาต่อวัน (รีเซ็ต 00:00 UTC) ดูที่เหลือได้จาก header X-Quota-Remaining Each key has a per-minute limit and a daily quota (resets 00:00 UTC); see the X-Quota-Remaining header.

400bad_requestMissing or malformed parameter
401missing_key / invalid_key / expired_keyNo key, unknown or revoked key, or past its expiry date
403ip_not_allowedThe key is limited to other IP addresses
404not_foundNo such song, artist, label or year
429rate_limited / quota_exceededPer-minute limit or daily quota hit; see Retry-After

เงื่อนไขการใช้ Terms

  • แสดงเครดิต “ข้อมูลจาก thaimusictimeline.com” พร้อมลิงก์กลับหน้าที่เกี่ยวข้อง (ฟิลด์ url) Credit “Data from thaimusictimeline.com” with a link back to the relevant page (the url field).
  • ข้อมูลต้นทางจาก Wikidata และ MusicBrainz (CC0) Underlying data comes from Wikidata and MusicBrainz (CC0).
  • ห้ามแชร์ key; key ที่ใช้ผิดเงื่อนไขจะถูกยกเลิก Do not share keys; keys used against these terms are revoked.