直播流 API
直播流 API 提供了发现和获取有关您的直播事件的信息的端点。 这使您能够构建“直播中”目录并将直播播放器嵌入到应用程序中。
获取活跃直播流
这是发现当前“在线”的流的主要端点。它返回一个仅包含正在接收来自编码器信号的流的列表。
GET /live-streams/active
参数
此端点不接受任何参数。它将为您的帐户返回所有活跃流。
示例请求
GET /api/client/v1/live-streams/active
Host: https://your-app.com
Authorization: Bearer sk-your-api-key-here
响应:GET /live-streams/active
如果流是活跃的,则会收到一个 LiveStream
对象数组。状态将为“活跃”,并且将存在一个 manifest
对象。
Response: 200 OK (Streams Active)
{
"data": [
{
"id": "9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f",
"title": "Weekly Q&A Session",
"description": "Answering your questions live.",
"status": "active",
"manifest": {
"hls_url": "https://your-app.com/storage/live_media/live/9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f/adaptive/master.m3u8"
},
"metadata": {
"category": "Tech Talk",
"host": "Jane Doe"
},
"tags": ["live", "q&a"],
"created_at": "2024-08-01T10:00:00Z"
}
]
}
如果当前没有活跃流,则 API 将返回一个空数据数组。
Response: 200 OK (No Streams Active)
{
"data": []
}
获取所有直播流
此端点提供了一个分页目录,包含您的帐户中配置的所有直播流,无论其当前状态(活跃或非活跃)如何。这对于构建日程表或完整列表可用的频道非常有用。
GET /live-streams
参数
名称 | 类型 | 是否必填 | 描述 |
---|---|---|---|
per_page | integer | 可选 | 返回的流数。默认值:15 , 最大值:100 。 |
示例请求
GET /api/client/v1/live-streams?per_page=2
响应:GET /live-streams
响应是一个标准的分页列表。状态将为“活跃”或“非活跃”,并且仅在流是活跃时才会存在 manifest
对象。
Response: 200 OK
{
"data": [
{
"id": "9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f",
"title": "Weekly Q&A Session",
"description": "Answering your questions live.",
"status": "active",
"manifest": {
"hls_url": "https://your-app.com/storage/live_media/live/9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f/adaptive/master.m3u8"
},
"metadata": {
"category": "Tech Talk"
},
"tags": ["live", "q&a"],
"created_at": "2024-08-01T10:00:00Z"
},
{
"id": "9c1a9e3e-1a2b-3c4d-5e6f-7g8h9i0j1k2l",
"title": "Upcoming Product Launch",
"description": "Join us for the big reveal.",
"status": "inactive",
"metadata": {
"category": "Product"
},
"tags": ["launch", "event"],
"created_at": "2024-07-25T15:00:00Z"
}
],
"links": {
"first": "https://your-app.com/api/client/v1/live-streams?page=1",
"last": "https://your-app.com/api/client/v1/live-streams?page=3",
"prev": null,
"next": "https://your-app.com/api/client/v1/live-streams?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 3,
"path": "https://your-app.com/api/client/v1/live-streams",
"per_page": 2,
"to": 2,
"total": 6
}
}
获取单个直播流
通过其 ID 检索一个特定直播流的详细信息。这是您将调用来获取加载流到播放器所需的信息。
GET /live-streams/{streamId}
路径参数
名称 | 类型 | 描述 |
---|---|---|
streamId | uuid | **必填。**直播流的唯一标识符。 |
示例请求
GET /api/client/v1/live-streams/9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f
响应:GET /live-streams/{streamId}
响应是一个单个 LiveStream
对象。若流是活跃,则会包含 manifest
。
Response: 200 OK (Stream is Active)
{
"data": {
"id": "9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f",
"title": "Weekly Q&A Session",
"description": "Answering your questions live.",
"status": "active",
"manifest": {
"hls_url": "https://your-app.com/storage/live_media/live/9c1a9e3e-7d8c-5g9b-9f1c-8a2b0c3d9e8f/adaptive/master.m3u8"
},
"metadata": {
"category": "Tech Talk",
"host": "Jane Doe"
},
"tags": ["live", "q&a"],
"created_at": "2024-08-01T10:00:00Z"
}
}