文档

视频监控服务API

更新时间:
一键部署

1接口定义

1.1 请求视频直播

路径

/vision/stream/query

版本号

2.1.1

协议

HTTP, HTTPS

请求方法

POST

授权类型

app签名

超时时间

3000

请求参数

名称

类型

是否必选

描述

iotId

String

设备ID。

streamType

Int

码流类型。

encrypted

Boolean

是否加密。

encryptType

Int

加密类型,I帧加密为0。

forceIFrame

Boolean

强制I帧。

scheme

String

协议类型,rtmp/hls。

返回数据

名称

类型

描述

code

Int

接口返回码。200表示成功。

message

String

调用失败时,返回的出错信息。

localizedMsg

String

本地语言的错误消息。

data

JSON

响应结果

响应结果data

名称

类型

描述

path

String

播放地址。

supportRelayPrePlay

BOOL

是否支持链路预热。

decryptKey

JSON

解密密钥。

解密密钥decryptKey

名称

类型

描述

iv

String

向量base64编码结果。

key

String

密钥base64编码结果。

示例

请求示例:

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("2.1.1");
// 设置参数
request.putParam("iotId","value1");
request.putParam("streamType","value2");
request.putParam("encrypted","value3");
request.putParam("encryptType","value4");
request.putParam("forceIFrame","value5");
request.putParam("scheme","value6");
request.putParam("cacheDuration","value7");
request.putParam("enablePrePlay","value8");
request.putParam("needDomainName","value9");
request.putParam("playUnlimited","value10");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/vision/stream/query", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

正常返回示例:

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": "success",
    "localizedMsg": "success",
    "data": {
        "path": "rtmp://11.164.XX.XX:8000/live?token=8da2&session=b52d&cacheDuration=1/5RnS_0",
        "decryptKey": {
            "iv": "aa",
            "key": "bb"
        }
    }
}

异常返回示例:

{
    "id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
    "code": 403,
    "message": "request forbidden.",
    "localizedMsg": "请求被禁止",
    "data": null
}

1.2 停止直播推流

路径

/vision/stream/stop

版本号

1.0.4

协议

HTTPS

请求方法

POST

授权类型

app签名

超时时间

3000

请求参数

名称

类型

是否必选

描述

iotId

String

设备ID。

streamType

Int

码流类型。

返回数据

名称

类型

描述

code

Int

接口返回码。200表示成功。

message

String

调用失败时,返回的出错信息。

localizedMsg

String

本地语言的错误消息。

示例

请求示例:

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("1.0.4");
// 如果需要登录,设置当前的会话的token,token通过登录api获取
request.setIotToken("你的<IoTToken>");
// 设置参数
request.putParam("iotId","value1");
request.putParam("streamType","value2");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/vision/stream/stop", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

正常返回示例:

{
"code":200,
"message":"success",
"data":{}
}

1.3 按时间请求本地录像播放地址

路径

/vision/vod/localfile/getbytime

版本号

2.0.1

协议

HTTPS

请求方法

POST

授权类型

app签名

超时时间

3000

请求参数

名称

类型

是否必选

描述

iotId

String

设备ID。

beginTime

Int

录像开始时间,1970年1月1日开始的秒数。

endTime

Int

录像结束时间,1970年1月1日开始的秒数。

encrypted

Boolean

是否加密。

encryptType

Int

加密类型。

seekTime

Int

相对于beginTime的偏移量,单位秒。

scheme

字符串

播放协议,输入内容包括:rtmp、flv。

recordType

整型

录像类型。

返回数据

名称

类型

描述

code

Int

接口返回码。200表示成功。

message

String

调用失败时,返回的出错信息。

localizedMsg

String

本地语言的错误消息。

data

JSON

响应结果。

响应结果data

名称

类型

描述

vodUrl

String

播放地址。

decryptKey

JSON

解密密钥。

解密密钥decryptKey

名称

类型

描述

iv

String

向量base64编码结果。

key

String

密钥base64编码结果。

示例

请求示例:

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("2.0.1");
// 设置参数
request.putParam("iotId","value1");
request.putParam("beginTime","value2");
request.putParam("endTime","value3");
request.putParam("encrypted","value4");
request.putParam("encryptType","value5");
request.putParam("seekTime","value6");
request.putParam("scheme","value7");
request.putParam("recordType","value8");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/vision/vod/localfile/getbytime", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

正常返回示例:

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": null,
    "localizedMsg": null,
    "data": {
        "vodUrl":"rtmp://106.14.XX.XX:8000/vod?token=c0cf&session=b350/1602863385"
    }
}

异常返回示例:

{
    "id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
    "code": 403,
    "message": "request forbidden.",
    "localizedMsg": "请求被禁止"
}

1.4 按文件名请求本地录像播放地址

路径

/vision/vod/localfile/getbyname

版本号

2.0.0

协议

HTTPS

请求方法

POST

授权类型

app签名

超时时间

3000

请求参数

名称

类型

是否必选

描述

iotId

String

设备ID。

fileName

String

文件名。

encrypted

Boolean

是否加密。

encryptType

Int

加密类型。

scheme

String

协议类型,支持 rtmp/hls。

seekTime

整型

相对于beginTime的偏移量,单位秒。

返回数据

名称

类型

描述

code

Int

接口返回码。200表示成功。

message

String

调用失败时,返回的出错信息。

localizedMsg

String

本地语言的错误消息。

data

JSON

响应结果。

响应结果data

名称

类型

描述

vodUrl

String

播放地址。

decryptKey

JSON

解密密钥。

解密密钥decryptKey

名称

类型

描述

iv

String

向量base64编码结果。

key

String

密钥base64编码结果。

示例

请求示例:

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("2.0.0");
// 如果需要登录,设置当前的会话的token,token通过登录api获取
request.setIotToken("你的<IoTToken>");
// 设置参数
request.putParam("iotId","value1");
request.putParam("fileName","value2");
request.putParam("encrypted","value3");
request.putParam("encryptType","value4");
request.putParam("scheme","value5");
request.putParam("seekTime","value6");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/vision/vod/localfile/getbyname", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

正常返回示例:

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": null,
    "localizedMsg": null,
    "data": "请补充具体返回业务参数!"
}

异常返回示例:

{
    "id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
    "code": 403,
    "message": "request forbidden.",
    "localizedMsg": "请求被禁止",
    "data": null
}
  • 本页导读 (0)
文档反馈