Polyv Help Center

Help Center

Query User Space and Traffic

Updated: 2022-09-02 18:08:07

API Description

1、查询用户点播账户的空间及流量使用情况
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

API URL

http://api.polyv.net/v2/user/{userid}/main

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

Request Parameter Description

Parameter Required Type Description
userid true String POLYV VOD account ID. Refer to Get Secret Key for acquisition. Path: Official Website -> Login -> VOD (API Interface)
ptime true Long Current time in milliseconds timestamp, valid for 3 minutes
date true String Query date, format: yyyy-MM-dd
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 not be stored or used directly on the client. 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

Example

 http://api.polyv.net/v2/user/1b448be323/main?date=2020-10-13&sign=8F0200C2C04945C5BDEE48E0CF6DCDC3598DEA16&userid=1b448be323&ptime=1617012847252

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
data Object Returns channel details on success. See Data Field Description
Data Parameter Description
Field Type Description
totalFlow Long Total user traffic, in bytes
usedSpace Long Used space, in bytes
usedFlow Long Used traffic, in bytes
totalSpace Long Total user space, in bytes
userId String POLYV VOD account ID. Refer to Get Secret Key
email String POLYV user email

Java Request Example

For quick integration, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source 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 pool.

  private static final Logger log = LoggerFactory.getLogger(VodAccountTest.class);
    /**
     * 点播DEMO:获取用户空间及流量情况
     */
    @Test
    public void testGetAccountSpaceFlow() throws Exception, NoSuchAlgorithmException {
    
        //公共参数,填写自己的实际参数
        String secretKey = super.secretKey;
        String userId = super.userId;
        String ptime = String.valueOf(System.currentTimeMillis());
        //业务参数
        String url = "http://api.polyv.net/v2/user/"+userId+"/main";
        String date =  "2020-10-13";
    
        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("userid", userId);
        requestMap.put("ptime", ptime);
        requestMap.put("date", date);
        requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
        String response = HttpUtil.get(url, requestMap);
        log.debug("测试获取用户空间及流量情况成功,{}", response);
        //do somethings
    }

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "videoCount": 32,
        "totalFlow": 21474836480,
        "usedSpace": 0,
        "usedFlow": 0,
        "totalSpace": 21474836480,
        "userId": "1b448be323",
        "email": "sdk-demo@polyv.net"
    }
} 

Error Example

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