Polyv Help Center

Help Center

Batch Get VOD Video Completion Rate

Updated: 2022-05-16 10:08:41

Interface URL

https://api.polyv.net/v2/video/engagement/{userId}/getList

Interface Description

Supports batch paginated retrieval of video watch completion rates
Supports https

Supported Format

JSON

Request Method

POST, GET

Request Limit

TRUE

Request Parameters

Parameter Required Type & Scope Description
userid true string Path parameter, user userId
ptime true float Current time in milliseconds (13-digit timestamp)
sign true String Signature, a 40-character uppercase SHA1 value [See Signature Generation Rules]
field true string Query condition field. Options: video (search by video); viewer (search by viewer)
fieldValue true string Value of the query condition. If field = video, fill in vid; if field = viewer, fill in viewerId
filterValue false string Filter condition. If field = video, multiple viewerIds separated by commas can be filled; if field = viewer, multiple vids separated by commas can be filled
page false int Page number, default 1
size false int Number of items per page

Return Result

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "pageSize": 20,
        "pageNumber": 1,
        "totalItems": 1,
        "contents": [
            {
                "vid": "ee7fe7fbdadafe381e8e100669144e51_e",
                "viewerId": "1111",
                "watchPercentage": 0.05
            }
        ]
    }
}

Example JSON for Failed Request

// 签名错误
{
    "code": 400,
    "status": "error",
    "message": "the sign is not right.",
    "data": ""
}
// 类型错误
{
    "code": 400,
    "status": "error",
    "message": "field type error",
    "data": ""
}
// ...

Field Description

Field Type Description
code int Request return status code
status string Request return status
message string Request return message
data.pageSize int Number of items per page
data.pageNumber int Page number
data.totalItems int Total number of items
data.content[0].vid string Video vid
data.content[0].viewerId string Viewer viewerId
data.content[0].watchPercentage float Watch completion rate

Java Example Code

public class Test {

    public static void main(String[] args) throws Exception {
        String userId = "ee7fe7fbda";
        String secretkey = "2owGBAZsAY";
        String url = "https://api.polyv.net/v2/video/engagement/%s/getList";

        Map<String, String> maps = new HashMap<>();
        maps.put("field", "viewer");
        maps.put("fieldValue", "1111");
        maps.put("filterValue", "");
        maps.put("sign", getSign(maps, secretkey));

        url += "?" + buildUrl(maps);
        url = String.format(url, userId);
        HttpClient client = new HttpClient();
        GetMethod getMethod = new GetMethod(url);
        client.executeMethod(getMethod);
        System.out.println(url);
        System.out.println(getMethod.getResponseBodyAsString());
    }

    public static String buildUrl(Map<String, String> maps) {
        List<String> tmp = new ArrayList<>();
        for (Map.Entry<String, String> key : maps.entrySet()) {
            tmp.add(key.getKey() + "=" + key.getValue());
        }
        return String.join("&", tmp);
    }
}
联系客服,在线咨询