Get Channel HLS Protocol Stream URL
Updated: 2024-04-22 19:18:32
API Description
1、获取频道hls协议拉流地址
2、接口支持https协议
API URL
https://api.polyv.net/live/v3/channel/monitor/hls-pull-url
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Request Parameters Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details for obtaining key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be saved or used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server and obtain response data. See signature generation rules |
| channelId | true | String | Channel ID |
Example
https://api.polyv.net/live/v3/channel/monitor/hls-pull-url
Form Parameters:
appId=frlr1zazn3&sign=2A861BD280299A4D7E6FF556C77C88D2&channelId=2149710×tamp=1621843071824
Response Parameters Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure See global error description |
| status | String | Response status text |
| message | String | Response description message, assists in describing error reasons when code is 400 or 500 |
| data | String | Returns an empty string for both success and failure |
Java Request Example
For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own project source code. HttpUtil.java and LiveSignUtil.java in the test cases are included in the download file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 获取频道hls协议拉流地址
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testGetHlsPullUrl() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v3/channel/monitor/hls-pull-url";
String channelId = "2094979";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试获取频道hls协议拉流地址接口,返回值:{}", response);
//do somethings
}
Response Example
See Global Error Description for system-wide error explanations.
Success Example
{
"code":200,
"status":"success",
"message":"",
"data":"https://pull-t2.videocc.net/recordf/93837273272343dsfasdfasdfasdf.m3u8?txSecret=26d9998b71b58c8b6f14b27ccf6e285b&txTime=661d10c6"
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "forbidden",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "forbidden : not in ip list",
"data": ""
}
