Polyv Help Center

Help Center

Get Daily Statistics for a Live Channel

Updated: 2023-11-14 14:07:19

Interface URL

http://api.live.polyv.net/v2/statistics/{channelId}/summary

Interface Description

Retrieve live streaming statistics for a specific channel (channelId) over a given period.

Supported Format

JSON

Request Method

GET

Request Rate Limit

TRUE

Request Parameters

Parameter Required Type Description
startDay Yes Date string in yyyy-MM-dd format Start date of the data to query
endDay Yes Date string in yyyy-MM-dd format End date of the data to query
appId Yes string User's appId
timestamp Yes 10-digit or 13-digit timestamp Timestamp
sign Yes string Encryption string

Successful Response JSON Example:

{
    status: "success",
    result: [
    {
        currentDay: "2017-08-02",
        channelId: 101378,
        userId: "edv3kno3t5",
        pcPlayDuration: 18,
        pcFlowSize: 7533133,
        pcVideoView: 3,
        pcUniqueViewer: 1,
        mobilePlayDuration: 10,
        mobileFlowSize: 0,
        mobileVideoView: 6,
        mobileUniqueViewer: 2,
        createdTime: 1501697384000,
        lastModified: 1501697384000
    }, {
        currentDay: "2017-08-03",
        channelId: 101378,
        userId: "edv3kno3t5",
        pcPlayDuration: 34,
        pcFlowSize: 23014636,
        pcVideoView: 10,
        pcUniqueViewer: 1,
        mobilePlayDuration: 16,
        mobileFlowSize: 0,
        mobileVideoView: 5,
        mobileUniqueViewer: 2,
        createdTime: 1501783204000,
        lastModified: 1501783204000
    }, {
        currentDay: "2017-08-04",
        channelId: 101378,
        userId: "edv3kno3t5",
        pcPlayDuration: 3,
        pcFlowSize: 0,
        pcVideoView: 1,
        pcUniqueViewer: 1,
        mobilePlayDuration: 0,
        mobileFlowSize: 0,
        mobileVideoView: 0,
        mobileUniqueViewer: 0,
        createdTime: 1501816874000,
        lastModified: 1501816874000
    }
]}

Failed Response JSON Example:

{
    code: "invalid.request",
    msg: "signature error."
}

Field Description

Parameter Description
currentDay Current date: yyyy-MM-dd
channelId Live channel ID
userId User ID
pcPlayDuration PC playback duration, unit: minutes
pcFlowSize PC data consumption, unit: bytes
pcVideoView Total PC views, similar to PV
pcUniqueViewer Unique PC viewers, similar to UV
mobilePlayDuration Mobile playback duration, unit: minutes
mobileFlowSize Mobile data consumption, unit: bytes
mobileVideoView Total mobile views, similar to PV
mobileUniqueViewer Unique mobile viewers, similar to UV
mobileUniqueViewer Unique mobile viewers, similar to UV
mobileUniqueViewer Unique mobile viewers, similar to UV
createdTime Record creation time
lastModified Record modification time

PHP Request Example

<?php
    header("Content-type: textml; charset=utf-8"); 
    $startDay="2017-08-02";
    $endDay="2017-08-08";
    $appId="egzhqa99ud";
    $timestamp= time()*1000;
    $appSecret = "60a0563af8c141e3b2c5b91429fbbc66";
    $str=$appSecret."appId".$appId."endDay".$endDay."startDay".$startDay."timestamp".$timestamp.$appSecret;
    $sign = md5($str);
    $sign = strtoupper($sign);
    $url = "http://api.live.polyv.net/v2/statistics/101378/summary?timestamp=$timestamp&sign=$sign&endDay=$endDay&startDay=$startDay&appId=$appId";
    $ch = curl_init() or die ( curl_error() );
    curl_setopt( $ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 360);
    $response = curl_exec ( $ch );
    curl_close ( $ch );
    echo $response;
?>

Signature Rules:

Sign generation example:

  1. Arrange request parameters in dictionary order by parameter name:
ptime = "1501055103000"
startDay="2017-08-02"
endDay="2017-08-08"
appId="egzhqa99ud"
  1. Concatenate the string by joining parameter names and values, and prepend and append the secretkey (here the secretkey value is 60a0563af8c141e3b2c5b91429fbbc66), as follows:
"60a0563af8c141e3b2c5b91429fbbc66" + "appId" +
"egzhqa99ud" + "endDay" + "2017-08-08" + "ptime" +
"1501055103000" + "startDay" + "2017-08-02" +  "60a0563af8c141e3b2c5b91429fbbc66"
  1. The sign is a 32-character uppercase MD5 value:
C758DF8045929D51CA28D51B934C9AAC
联系客服,在线咨询