เอกสาร Movie API
ใช้สำหรับดึงข้อมูลภาพยนตร์เพื่อแสดงผลบนเว็บไซต์/แอป
Base URL:
https://movie.dooapi2.comตั้งค่าได้จากตัวแปร API_BASE_URL ในไฟล์ .env
Endpoints
- GET
https://movie.dooapi2.com/api/movie/:id– ดึงข้อมูลภาพยนตร์ตามid - GET
https://movie.dooapi2.com/api/movies– ค้นหารายการ (รองรับq, year, audio, genre, country, page, limit)
GET /api/movie/:id
ตัวอย่าง:
curl -s https://movie.dooapi2.com/api/movie/11 | jq
Response
{
"code": 1,
"msg": "ok",
"data": {
"URL_player": { "server_data": {
"thai_dub": "https://.../play/xxx",
"soundtrack": "https://.../play/yyy"
}},
"id": 11,
"name": "Harry Potter and the Philosopher's Stone (2001)",
"slug": "harry-potter-and-the-philosophers-stone",
"Audio_Subtitle_Options": "thai dub",
"year": "2001",
"release": "12-28-2023",
"genre": ["ผจญ","จินตนาการ"],
"poster_url": "https://image.tmdb.org/...",
"backdrop_url": "https://image.tmdb.org/...",
"country": ["United Kingdom","United States of America"],
"Synopsis": "..."
}
}
คำอธิบายฟิลด์
code– 1=สำเร็จ, 0=ล้มเหลวmsg– สถานะสั้นๆURL_player.server_data.thai_dub,soundtrack– ลิงก์ตัวเล่นyear,release- Year + release date (string)genre,country– อาร์เรย์ข้อความposter_url,backdrop_url– URL รูปภาพ
GET /api/movies
พารามิเตอร์:
q– ค้นหาชื่อเรื่องแบบ LIKEyear– ปี (string)audio– คำหลัก เช่นthai dub,soundtrack,subthaigenre,country– LIKE stringpage(เริ่ม 1),limit(เริ่ม 20, สูงสุด 100)
ตัวอย่าง:
curl -s "https://movie.dooapi2.com/api/movies?q=harry&year=2001&audio=thai%20dub&genre=จินตนาการ&page=1&limit=10" | jq
Response
{
"code": 1,
"msg": "ok",
"data": {
"items": [ { /* โครงเดียวกับ /api/movie/:id.data */ } ],
"page": 1,
"limit": 10,
"total": 123,
"pagecount": 13
}
}
การจัดการข้อผิดพลาด
{
"code": 0,
"msg": "not found",
"data": null
}
code=0, msg=not found– ไม่พบข้อมูลcode=0, msg=server error– ข้อผิดพลาดภายในเซิร์ฟเวอร์HTTP 429– ถูกจำกัดความถี่ (Rate limited)
แคช & Rate limit
- Redis Cache:
movie:<id>และ key รวมพารามิเตอร์ใน/api/movies(TTL = 300s) - Rate limit: 60 req / 60s