视频 API
The Videos API 是用于检索视频内容的主要端点。它支持强大的过滤、排序和标记功能。
列出视频
检索分页列表中的视频。这一端点非常灵活,接受多个查询参数来精细化结果。响应包含一个 VideoSummary 对象 数组。
GET /videos
查询参数
名称 | 类型 | 描述 |
---|---|---|
path | string | **可选。**过滤视频到特定集合路径,例如 root/movies 。 |
filters | object | **可选。**根据元数据进行过滤。请参阅 过滤示例 以获取语法。 |
tags | string | **可选。**以逗号分隔的标签列表,用于过滤(例如 laravel,api )。找到包含所有指定标签的视频。 |
sort | string | **可选。**对结果进行排序。使用 - 前缀为降序排序。允许字段: created_at 、title 、duration_in_seconds 。默认值: -created_at 。 |
per_page | integer | **可选。**每页显示的结果数量。默认值: 15 ,最大值: 100 。 |
过滤示例
filters
参数是最强大的功能。语法为 filters[field_name][operator]=value
。
根据集合路径过滤
这将找到所有位于 education/php
文件夹中的视频。
GET /api/client/v1/videos?path=root/education/php
根据单个元数据字段(等于)过滤
这将找到所有标题为 ‘Action’ 的视频,忽略大小写。使用直接值是 eq
(等于) 运算符的快捷方式。
GET /api/client/v1/videos?filters[genre]=Action
根据路径和元数据过滤
这将找到所有 ‘初学者’ 视频,具体位于 ‘健身/瑜伽’ 集合中。
GET /api/client/v1/videos?path=root/fitness/yoga&filters[difficulty]=beginner
根据 “大于” (gt
) 过滤
这将找到所有长度超过 10 分钟(600 秒)的视频。
GET /api/client/v1/videos?filters[duration_in_seconds][gt]=600
根据 “小于或等于” (lte
) 过滤
这将找到所有评分为 3 或以下的视频。
GET /api/client/v1/videos?filters[rating][lte]=3
根据 “在列表中” (in
) 过滤
这将找到所有难度等级为 ‘初学者’ 或 ‘中级’ 的视频。它适用于单选和多选字段。
GET /api/client/v1/videos?filters[difficulty][in]=beginner,intermediate
根据 “不等于” (neq
) 过滤
这将找到所有演讲者不是 ‘Jane Doe’ 的视频。
GET /api/client/v1/videos?filters[presenter][neq]=Jane Doe
排序和标记示例
根据标签过滤
这将找到所有同时具有 ‘瑜伽’ 和 ‘初学者’ 标签的视频。
GET /api/client/v1/videos?tags=yoga,beginner
根据标题(升序)排序
这将按字母顺序对所有视频进行排序。
GET /api/client/v1/videos?sort=title
根据日期(降序)排序
这将按最新的视频排列。这个是默认行为,等同于不提供 sort
参数。
GET /api/client/v1/videos?sort=-created_at
全部响应: GET /videos
这是分页响应的完整、未截断示例。
Response: 200 OK
{
"data": [
{
"id": "9c1a9e3e-6c9b-4f8a-8e2d-9b3c1d4e0f6a",
"title": "Advanced API Design in Laravel",
"description": "A deep dive into building robust APIs.",
"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": "Introduction to Yoga",
"description": "A beginner's guide to basic yoga poses.",
"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
}
}
获取单个视频
检索单个视频的详细数据,适合播放器。响应是单个 Video 对象。
GET /videos/{videoId}
路径参数
名称 | 类型 | 描述 |
---|---|---|
videoId | uuid | **必需。**视频的唯一标识符。 |
示例请求
GET /api/client/v1/videos/9c1a9e3e-6c9b-4f8a-8e2d-9b3c1d4e0f6a
全部响应: GET /videos/{videoId}
Response: 200 OK
{
"data": {
"id": "9c1a9e3e-6c9b-4f8a-8e2d-9b3c1d4e0f6a",
"title": "Advanced API Design in Laravel",
"description": "A deep dive into building robust APIs.",
"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": "English",
"language": "en",
"is_default": true,
"url": "https://your-cdn.com/path/to/en.vtt"
},
{
"label": "Español",
"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"
}
}
}