Skip to main content

Restful API

SwarmCloud’s API follows the REST principles. It has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

BASE URL

  • European cluster
https://cgi.cdnbye.com/v1
  • Hongkong cluster
https://cgi.swarmcloud.net/v1
  • American cluster
https://cgi.hdtvcloud.com/v1

Rate limiting: 2000 requests per minute

Get Token

You can use this API to get the token with your account

POST /user/token

POST Body

NameTypeDescriptionRequired
emailstringUser emailYes
passwdstringThe sha256 encrypted string of raw passwordYes

Response

Status: 200

{
"ret": 0,
"name": "token",
"data":
{
"id": 001,
"token": "xxxxxx"
}
}
NameTypeDescription
idintUser ID
tokenstringUser token, will expire in 14days

Get Domain List

You can use this API to get all domain/APP list of a user

GET /user/user_id/{user_id}/domain

HTTP Header

NameTypeDescriptionRequired
MyTokenstringThe token of userYes

Query

NameTypeDescriptionRequired
pageintThe specific page numberYes
page_sizeintThe specific page sizeYes

Response

Status: 200

{
"ret": 0,
"name": "domain"
"data":
[
{
"id": 001,
"domain": "xxx.com",
"uid": 001,
"native": false,
"isValid": false
}
]
}
NameTypeDescription
idintDomain/APP ID
domainstringDomain name or AppId
uidintUser ID
nativeboolIs native application
isValidboolIs domain verified

Set TimeZone

You can use this API to set the timezone

GET /user/user_id/{user_id}/timezone

HTTP Header

NameTypeDescriptionRequired
MyTokenstringThe token of userYes

Path Parameters

NameTypeDescriptionRequired
user_idstringUser IDYes

POST Body

NameTypeDescriptionRequired
utcintThe UTC offset of your timezoneYes

Get Realtime Information

You can use this API to get realtime information of a specific or all domain/APP

GET /user/user_id/{user_id}/domain/domain_id/{domain_id}

HTTP Header

NameTypeDescriptionRequired
MyTokenstringThe token of userYes

Path Parameters

NameTypeDescriptionRequired
user_idstringUser IDYes
domain_idstringDomain ID("0" means to get the summary data of all domain/APP)Yes

Response

Status: 200

{
"ret": 0,
"name": "domain",
"data":
{
"num_rt": 456,
"num_max": 892,
"traffic_p2p_day": 1022794195,
"traffic_http_day": 1022794195,
"api_frequency_day": 14805,
}
}
NameTypeDescription
num_rtintCurrent Online Viewers
num_maxintPeak Concurrent Viewers
traffic_p2p_dayintP2P Traffic Today (KB)
api_frequency_dayintPlayback Sessions Today

Get Historical P2P Traffic

You can use this API to get historical p2p traffic for a specific time period

GET /user/user_id/{user_id}/domain/domain_id/{domain_id}/p2p

HTTP Header

NameTypeDescriptionRequired
MyTokenstringThe token of userYes

Path Parameters

NameTypeDescriptionRequired
user_idstringUser IDYes
domain_idstringDomain ID("0" means to get the summary data of all domain/APP)Yes

Query

NameTypeDescriptionRequired
start_tsintThe start timestamp(UTC+8)Yes
end_tsintThe end timestamp(UTC+8)Yes
granintAlways equal to 1440Yes

Response

Status: 200

{
"ret": 0,
"name": "statistic",
"data":
{
"max":
{
"ts": 1591372800,
"value": 541188637412
},
"list":
[
{"ts":1590854400,"value":1591200000},
{"ts":1590940800,"value":194511284034},
{"ts":1591027200,"value":541188637412}
]
}
}
NameTypeDescription
maxobjectThe max value of all data
listarrayThe array of all data
tsintTimestamp
valueintP2P traffic(KB)

Get Historical Online Viewers

You can use this API to get historical online viewers for a specific time period

GET /user/user_id/{user_id}/domain/domain_id/{domain_id}/num

HTTP Header

NameTypeDescriptionRequired
MyTokenstringThe token of userYes

Path Parameters

NameTypeDescriptionRequired
user_idstringUser IDYes
domain_idstringDomain ID("0" means to get the summary data of all domain/APP)Yes

Query

NameTypeDescriptionRequired
start_tsintThe start timestamp(UTC+8)Yes
end_tsintThe end timestamp(UTC+8)Yes
granintMust be an integer multiple of 5 minutesYes

Response

Status: 200

{
"ret": 0,
"name": "statistic",
"data":
{
"max":
{
"ts": 1591372800,
"value": 109566
},
"list":
[
{"ts":1590854400,"value":66504},
{"ts":1590940800,"value":72373},
{"ts":1591027200,"value":78300}
]
}
}
NameTypeDescription
maxobjectThe max value of all data
listarrayThe array of all data
tsintTimestamp
valueintOnline viewers

Enable/Disable P2P

If you bind multiple domain names/APPID in one account, those which open P2P services share traffic packets together. You can save on packet consumption by shutting down P2P services of one or several domain names.

POST /user/user_id/{user_id}/domain/domain_id/{domain_id}/control

HTTP Header

NameTypeDescriptionRequired
MyTokenstringThe token of userYes

Path Parameters

NameTypeDescriptionRequired
user_idstringUser IDYes
domain_idstringDomain IDYes

POST Body

NameTypeDescriptionRequired
disableboolSet true disable p2p or false to enable p2pYes

Response

Status: 200

{
"ret":0,
"name":"control",
"data":
{
"allow":true,
"succeed":true
}
}