Skip to Content

Videos API

The Videos API là điểm cuối cùng để lấy nội dung video. Nó hỗ trợ khả năng lọc, sắp xếp và đánh dấu mạnh mẽ.

Danh sách các Video

Lấy danh sách các video được phân trang. Điểm cuối này rất linh hoạt và chấp nhận nhiều tham số truy vấn để tinh chỉnh kết quả. Trả về một mảng của Object Tóm tắt Video.

GET /videos

Tham số Truy vấn

TênLoạiMô tả
pathstringBắt buộc. Lọc các video đến một đường dẫn cụ thể, ví dụ: root/movies.
filtersobjectBắt buộc. Lọc theo metadata. Xem Ví dụ về lọc bên dưới để biết cách sử dụng.
tagsstringBắt buộc. Một danh sách các thẻ được phân tách bằng dấu phẩy để lọc (ví dụ: laravel,api). Tìm kiếm các video có tất cả các thẻ được chỉ định.
sortstringBắt buộc. Sắp xếp kết quả. Sử dụng tiền tố - cho sắp xếp giảm dần. Các trường được phép sắp xếp: created_at, title, duration_in_seconds. Mặc định: -created_at.
per_pageintegerBắt buộc. Số lượng kết quả mỗi trang. Mặc định: 15, Giới hạn: 100.

Ví dụ về Lọc

Tham số filters là tính năng mạnh nhất. Cú pháp là filters[field_name][operator]=value.

Lọc theo Đường Dẫn

Này tìm tất cả các video bên trong thư mục education/php.

GET /api/client/v1/videos?path=root/education/php

Lọc Theo Một Trường Metadata (Bằng)

Này tìm tất cả các video nơi genre là ‘Action’, không phân biệt chữ hoa chữ thường. Sử dụng giá trị trực tiếp là một cách tắt cho toán tử eq.

GET /api/client/v1/videos?filters[genre]=Action

Lọc Theo Đường Dẫn và Metadata

Này tìm tất cả các video ‘bắt đầu’ cụ thể bên trong thư mục fitness/yoga.

GET /api/client/v1/videos?path=root/fitness/yoga&filters[difficulty]=beginner

Lọc Theo “Lớn Hơn” (gt)

Này tìm tất cả các video dài hơn 10 phút (600 giây).

GET /api/client/v1/videos?filters[duration_in_seconds][gt]=600

Lọc Theo “Nhỏ Hơn Hoặc Bằng” (lte)

Này tìm tất cả các video có đánh giá là 3 hoặc nhỏ hơn.

GET /api/client/v1/videos?filters[rating][lte]=3

Lọc Theo “Trong Danh Sách” (in)

Này tìm tất cả các video nơi độ khó là ‘bắt đầu’ hoặc ‘giữa’.

GET /api/client/v1/videos?filters[difficulty][in]=beginner,intermediate

Lọc Theo “Không Bằng” (neq)

Này tìm tất cả các video nơi người trình bày không phải là ‘Jane Doe’.

GET /api/client/v1/videos?filters[presenter][neq]=Jane Doe

Ví dụ về Sắp Xếp và Đánh Dấu

Lọc Theo Thẻ

Này tìm tất cả các video được đánh dấu với BOTH ‘yoga’ AND ‘bắt đầu’.

GET /api/client/v1/videos?tags=yoga,beginner

Sắp Xếp Theo Tiêu Đề (Tăng)

Này liệt kê tất cả các video được sắp xếp theo thứ tự abc của tiêu đề.

GET /api/client/v1/videos?sort=title

Sắp Xếp Theo Ngày (Giảm)

Này liệt kê tất cả các video với những video mới nhất đầu tiên. Đây là hành vi mặc định và tương đương với việc không cung cấp tham số sort.

GET /api/client/v1/videos?sort=-created_at

Trả Về Toàn Cầu: GET /videos

Đây là một ví dụ hoàn chỉnh, không bị cắt xén về phản hồi phân trang.

Response: 200 OK
{ "data": [ { "id": "9c1a9e3e-6c9b-4f8a-8e2d-9b3c1d4e0f6a", "title": "Nâng cao API Thiết Kế trong Laravel", "description": "Một cái nhìn sâu sắc vào việc xây dựng các API mạnh mẽ.", "duration_in_seconds": 3620, "thumbnail_url": "https://your-cdn.com/path/to/thumb1.jpg", "created_at": "2024-08-10T12:00:00Z", "metadata": { "difficulty": "advanced", "presenter": "Jane Doe" } }, { "id": "9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f", "title": "Giới thiệu về Yoga", "description": "Hướng dẫn cơ bản cho các động tác yoga.", "duration_in_seconds": 1800, "thumbnail_url": "https://your-cdn.com/path/to/thumb2.jpg", "created_at": "2024-08-09T10:00:00Z", "metadata": { "difficulty": "beginner", "presenter": "John Smith" } } ], "links": { "first": "https://your-app.com/api/client/v1/videos?page=1", "last": "https://your-app.com/api/client/v1/videos?page=5", "prev": null, "next": "https://your-app.com/api/client/v1/videos?page=2" }, "meta": { "current_page": 1, "from": 1, "last_page": 5, "links": [ { "url": null, "label": "« Previous", "active": false }, { "url": "https://your-app.com/api/client/v1/videos?page=1", "label": "1", "active": true }, { "url": "https://your-app.com/api/client/v1/videos?page=2", "label": "2", "active": false }, { "url": "https://your-app.com/api/client/v1/videos?page=3", "label": "3", "active": false }, { "url": "https://your-app.com/api/client/v1/videos?page=4", "label": "4", "active": false }, { "url": "https://your-app.com/api/client/v1/videos?page=5", "label": "5", "active": false }, { "url": "https://your-app.com/api/client/v1/videos?page=2", "label": "Next »", "active": true } ], "path": "https://your-app.com/api/client/v1/videos", "per_page": 2, "to": 2, "total": 10 } }

Lấy Một Video

Lấy dữ liệu chi tiết đầy đủ cho một video, phù hợp để sử dụng trong trình phát. Trả về một Object Video.

GET /videos/{videoId}

Tham số Đường Dẫn

TênLoạiMô tả
videoIduuidBắt buộc. ID duy nhất của video.

Ví dụ Yêu Cầu

GET /api/client/v1/videos/9c1a9e3e-6c9b-4f8a-8e2d-9b3c1d4e0f6a

Trả Về Toàn Cầu: GET /videos/{videoId}

Response: 200 OK
{ "data": { "id": "9c1a9e3e-6c9b-4f8a-8e2d-9b3c1d4e0f6a", "title": "Nâng cao API Thiết Kế trong Laravel", "description": "Một cái nhìn sâu sắc vào việc xây dựng các API mạnh mẽ.", "duration_in_seconds": 3620, "created_at": "2024-08-10T12:00:00Z", "manifest": { "hls_url": "https://your-cdn.com/path/to/master.m3u8", "dash_url": "https://your-cdn.com/path/to/manifest.mpd" }, "captions": [ { "label": "Tiếng Anh", "language": "en", "is_default": true, "url": "https://your-cdn.com/path/to/en.vtt" }, { "label": "Tiếng Tây Ban Nha", "language": "es", "is_default": false, "url": "https://your-cdn.com/path/to/es.vtt" } ], "transcript": { "type": "vtt", "url": "https://your-cdn.com/path/to/transcript.vtt" }, "thumbnails": [ { "url": "https://your-cdn.com/path/to/thumb1.jpg" }, { "url": "https://your-cdn.com/path/to/thumb2.jpg" } ], "tags": ["laravel", "api", "php"], "metadata": { "difficulty": "advanced", "presenter": "Jane Doe", "related_course": "API Mastery", "language": "en-US" } } }