Polyv Help Center

Help Center

Query Video Playback Domain Distribution

Updated: 2025-01-14 16:18:49

API Description

1、通过视频id查询视频播放域名分布数据
2、从播放行为产生到数据可查询的间隔时间为1~2小时
3、响应参数消耗流量(PCFlowSize字段)的计算依赖于CDN日志,为了保证数据完整性,流量数据需要间隔一个自然日才会生成
4、接口URL中的{userid}为点播账号userid,具体参考【获取密钥】
5、接口支持https协议

API URL

http://api.polyv.net/v2/domain/{userid}

Online API Call

Request Method

GET

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

  2. The request parameters start (start date) and end (end date) must be passed together; passing only one parameter is invalid.

  3. If both dr (time period) and start/end are passed, only start and end are effective. If none are passed, dr defaults to 7days.

Request Parameter Description

Parameter Required Type Description
ptime true Long Current time in milliseconds, valid for 3 minutes
sign true String Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must never be used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules
vid false String Video ID
dr false String Time period. Default value is 7days. Possible values:
today: Today
yesterday: Yesterday
this_week: This week
last_week: Last week
7days: Last 7 days
this_month: This month
last_month: Last month
this_year: This year
last_year: Last year
start false String Start date, format: yyyy-MM-dd, e.g., 2021-04-07
end false String End date, format: yyyy-MM-dd, e.g., 2021-04-10

Example

http://api.polyv.net/v2/domain/1b448be323?vid=1b448be323fb327a42539cbb788913b4_1&start=2021-03-16&sign=0134324F43514CC31B2F9F30273B4953BE37CB9C&end=2021-03-24&ptime=1617875628750&dr=last_month

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 indicates success, non-200 indicates failure. See global error description
status String Response status text
message String Response description. When code is 400 or 500, provides auxiliary error reason description.
data Array Returns domain statistics on success [See Data field description](/vod/api/statistics/get_domain_stat.md?id=polyv1], returns empty on failure.
Data Parameter Description
Field Type Description
domain String Domain name
pcPlayDuration Integer PC playback duration (in seconds)
pcFlowSize Long PC traffic consumed (in bytes)
pcVideoView Integer Total PC play count
pcUniqueViewer Integer Unique PC viewers
mobilePlayDuration Integer Mobile playback duration (in seconds)
mobileVideoView Integer Mobile play count
mobileUniqueViewer Integer Unique mobile viewers

Error Code List

Error Code message Description
400 sign can not be empty. Signature string is empty.
400 ptime is too old. Timestamp has expired.
400 ptime is illegal. Timestamp parameter format is incorrect or exceeds current time by 3 minutes.
400 Could not find user by userid. User ID does not exist.
400 the sign is not right. Signature string is incorrect.
401 start and end illegal. Start date is greater than end date.
500 query failed. Backend program threw an exception.

Java Request Example

For quick integration of the basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.

It is strongly recommended to use the VOD Java SDK for API integration. The VOD 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(VodVideoAdvertising.class);
/**
 * 查询视频播放的域名分布
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetDomainStat() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("http://api.polyv.net/v2/domain/%s", userId);
    String vid = "1b448be323fb327a42539cbb788913b4_1";
    String dr = "last_month";
    String start = "2021-03-16";
    String end = "2021-03-24";

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("ptime", ptime);
    requestMap.put("vid", vid);
    requestMap.put("dr", dr);
    requestMap.put("start", start);
    requestMap.put("end", end);
    requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));

    String response = HttpUtil.get(url, requestMap);
    log.debug("测试查询视频播放的域名分布,{}", response);
    //do somethings

}

Response Example

For global system error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": [{
        "domain": "share.plvideo.cn",
        "pcPlayDuration": 141,
        "pcFlowSize": 18318463,
        "pcVideoView": 12,
        "pcUniqueViewer": 2,
        "mobilePlayDuration": 57,
        "mobileVideoView": 4,
        "mobileUniqueViewer": 3
    }, {
        "domain": "my.polyv.net",
        "pcPlayDuration": 29,
        "pcFlowSize": 19190397,
        "pcVideoView": 3,
        "pcUniqueViewer": 2,
        "mobilePlayDuration": 0,
        "mobileVideoView": 0,
        "mobileUniqueViewer": 0
    }, {
        "domain": "live.polyv.net",
        "pcPlayDuration": 6,
        "pcFlowSize": 4158970,
        "pcVideoView": 1,
        "pcUniqueViewer": 1,
        "mobilePlayDuration": 0,
        "mobileVideoView": 0,
        "mobileUniqueViewer": 0
    }, {
        "domain": "live.polyv.cn",
        "pcPlayDuration": 14,
        "pcFlowSize": 2563379,
        "pcVideoView": 1,
        "pcUniqueViewer": 1,
        "mobilePlayDuration": 0,
        "mobileVideoView": 0,
        "mobileUniqueViewer": 0
    }]
}

Error Example

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}
联系客服,在线咨询