# 获取频道拉流地址接口

### 接口URL

```
https://api.polyv.net/live/v3/channel/detail/get-pull-url
```

### 接口说明

```
1、获取频道的拉流地址
2、接口支持https协议
```

### 支持格式

```
JSON
```

### 请求方式

```
GET,POST
```

### 请求数限制

```
TRUE
```

### 请求参数

| 参数名       | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| --------- | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId     | 是  | string | 从API设置中获取，在直播系统登记的appId                                                                                                                                                                                   |
| timestamp | 是  | string | 当前13位毫秒级时间戳，3分钟内有效                                                                                                                                                                                        |
| channelId | 是  | int    | 频道号                                                                                                                                                                                                       |
| sign      | 是  | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |

### 响应成功JSON示例：

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
     "flv": "https://pull-huk.videocc.net/recordf/1c6dc3c666201909261628019107.m3u8?auth_key=1584335309-0-0-c0017cb24300497adb87aee6f617fdbd",
     "m3u8": "https://pull-huk.videocc.net/recordf/1c6dc3c666201909206162819107.flv?auth_key=1584335309-0-0-7e5e327553f6800c148a485b6a8fff58"
    }
}
```

### 响应失败JSON示例：

未输入appId

```json
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
```

appId不正确

```json
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
```

时间戳错误

```json
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
```

签名错误

```json
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
```

非法的操作

```json
{
    "code": 400,
    "status": "error",
    "message": "illegal operation.",
    "data": ""
}
```

### 字段说明

| 参数名       | 说明            |
| --------- | ------------- |
| code      | 请求状态响应码       |
| status    | 请求状态          |
| message   | 错误信息          |
| data      | 返回的结果         |
| data.flv  | flv的拉流地址，字符串  |
| data.m3u8 | m3u8的拉流地址，字符串 |

### php请求示例

```php
<?php

//引用config.php
include 'config.php';


/接口需要的参数（非sign）赋值
$params = array(
    'appId'=>$appId,
	'channelId'=>$channelId,
    'timestamp'=>$timestamp
  );

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法

//接口请求url
$url = "http://api.polyv.net/live/v3/channel/detail/get-pull-url?appId=".$appId."&timestamp=".$timestamp."&sign=".$sign."&channelId=".$channelId;
//输出接口请求结果
echo file_get_contents($url);

?>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyv.gitbook.io/document/docs/unclassified/2020/33f3544b2027b791ee6d823b9569e16f.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
