Authorization header when calling other endpoints. Keep your credentials and token secure. Obtaining a new token invalidates the previous one.
1.Get an access token
POST /wapi/token/ with a JSON body:
| Field | Description |
|---|---|
username | Account email; required |
passwd | Account password; required |
results.token as your access token:
2.Query Dynamic GB traffic usage
GET /wapi/consume/dynamic/chart/
| Query parameter | Description |
|---|---|
suname | Sub-account username; omit or leave empty to query the main account |
st | Start time, Unix seconds |
et | End time, Unix seconds |
GET /wapi/consume/dynamic/chart/?suname=sub_account&st=1735689600&et=1735776000
Accounts that have purchased a Dynamic GB or Advanced Dynamic GB package, or redeemed Dynamic traffic, can use this endpoint.
3.Query Premium Dynamic GB traffic usage
GET /wapi/consume/premium/chart/
Use the same header, query parameters, and response format as the Dynamic GB usage endpoint. Example: GET /wapi/consume/premium/chart/?suname=sub_account&st=1735689600&et=1735776000. Accounts that have purchased a Premium Dynamic GB package can use this endpoint.
Both usage endpoints follow these rules:
- If either
storetis omitted or not greater than 0, the query covers midnight to now in the account’s time zone. - If
stequalset, the query covers one day from that time. A start time after the end time produces a parameter error. - results
contains time-ordered data points.periodidentifies the time interval,timestampis its Unix timestamp in seconds, andtotal_traffic_count` is traffic used during that interval, in bytes. Intervals without usage return 0.
4.Create redemption codes (CDKs) in batch
POST /wapi/cdk/create/
| Field | Description |
|---|---|
cdk_type | Required: 1 Dynamic traffic, 2 IP count, 3 Mobile traffic |
flow | Required for types 1 and 3; traffic per code in GB, from 1 to 10000 |
ip | Required for type 2; IP count per code, from 1 to 10000 |
day | Validity period in days for types 1 and 3 |
num | Required; number of codes to create, from 1 to 10000 |
results lists the generated codes. Cdk is the redemption code, Type is its type, Flow is in bytes, Ip is the IP count, and Days is the validity period:
Common errors
Always check
code in the response: some business errors are returned with HTTP 200.