Polyv Help Center

Help Center

Query Video Playback Geographic Distribution

Updated: 2025-01-14 16:19:19

API Description

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

API URL

http://api.polyv.net/v2/geo/{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 within 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 stored or 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
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/geo/1b448be323?start=2021-03-16&sign=DD025D6491BDBB57D3646AE23F19821A065BA2C5&end=2021-03-24&userId=1b448be323&ptime=1617875694840&dr=7days

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 additional error details.
data Array Returns geographic statistics on success [See Data field description](/vod/api/statistics/get_geo_stat.md?id=polyv1], returns empty on failure
Data Parameter Description
Field Type Description
province String Province
pcPlayDuration Integer PC playback duration, in seconds
formatPcPlayDuration String Formatted PC playback duration, format: HH:MM:SS, e.g., 00:00:00
pcFlowSize Long PC data consumption, in bytes
pcVideoView Integer PC play count
pcUniqueViewer Integer PC unique viewers
mobilePlayDuration Integer Mobile playback duration, in seconds
formatMobilePlayDuration String Formatted mobile playback duration, format: HH:MM:SS, e.g., 00:00:00
mobileFlowSize Long Mobile data consumption, in bytes
mobileVideoView Integer Mobile play count
mobileUniqueViewer Integer Mobile unique viewers

Error Code List

Error Code message Description
400 sign can not be empty. Signature is empty
400 ptime is too old. Timestamp has expired
400 ptime is illegal. Timestamp 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 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, 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 case files HttpUtil.java and VodSignUtil.java are included in the download package.

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);
/**
 * 查询视频播放的地理位置分布
 */
@Test
public void testGetGeoStat() 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/geo/%s", userId);
    String dr = "7days";
    String start = "2021-03-16";
    String end = "2021-03-24";

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("ptime", ptime);
    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": [{
        "province": "湖南",
        "pcPlayDuration": 190,
        "formatPcPlayDuration": "00:03:10",
        "pcFlowSize": 44231209,
        "pcVideoView": 17,
        "pcUniqueViewer": 4,
        "mobilePlayDuration": 57,
        "formatMobilePlayDuration": "00:00:57",
        "mobileFlowSize": 14242541,
        "mobileVideoView": 4,
        "mobileUniqueViewer": 3
    }]
}

Error Example

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