Polyv Help Center

Help Center

Query Account Space Traffic Usage

Updated: 2025-01-14 16:13:16

API Description

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

API URL

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

Online API Call

Request Method

POST

API Constraints

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

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 See signature generation rules
date false String Date to query. If empty, queries all space and traffic usage from the start of the latest plan to the present. Format: yyyy-MM-dd, e.g., 2019-11-11

Example

http://api.polyv.net/v2/user/1b448be323/main

Form parameters:

date=2021-04-09&sign=1E839D5F6DEBDEE4BD8F8AA45F2F15BDBF15136D&ptime=1617954612523

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 for success, non-200 for failure See global error description
status String Response status text
message String Response description. When code is 400 or 500, provides error reason
data Object Returns user account space and traffic information on success See data field description
data Parameter Description
Parameter Type Description
videoCount Integer Number of videos in the user account
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
email String POLYV user email

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. HttpUtil.java and VodSignUtil.java in the test case are included in the download 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(VodStatisticsTest.class);
/**
 * 查询账号的空间流量使用
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetTotalUsage() 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="2021-04-09";

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

    String response = HttpUtil.postFormBody(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":57,
        "totalFlow":21474836480,
        "usedSpace":41850482,
        "usedFlow":82653532,
        "totalSpace":21474836480,
        "userId":"1b448be323",
        "email":"sdk-demo@polyv.net"
    }
}

Error Example

{
    "code":400,
    "status":"error",
    "message":"sign can not be empty.",
    "data":""
}
联系客服,在线咨询