Skip to content
Alick Zhao edited this page Feb 27, 2015 · 6 revisions

GDanmaku Server APIs Reference

All responses are encoded in JSON. Authentication can be done by setting the HTTP header X-GDANMAKU-AUTH-KEY to the key. ##Get a list of existing APIs

###URL

/api/v1/channels

###Method GET ###Authorized false ###Request Params None ###Response Params

Key Force Type Comments
channels true array channels information
:name true string Channel name
:desc true string the password for user
###Example
Request:
GET /api/v1/channels HTTP 1.1

Response:

{"channels": [{"name": "demo", "desc": "\u6f14\u793a\u9891\u9053, \u53d1\u5e03\u3001\u8ba2\u9605\u5747\u65e0\u9700\u5bc6\u7801"}, {"name": "tuna", "desc": "TUNA \u534f\u4f1a\u9891\u9053"}]}

##Register for a new channel

###URL

/api/v1/channels

###Method POST ###Authorized false ###Request Type json/form ###Request Params

Key Force Type Comments
name true string Channel name
desc true string the password for user
ttl true integer time to use this channel (in hours)
sub_passwd true string password for danmaQ to get danmakus from server
pub_passwd false string password for user to post new danmakus to server
###Response Params
Key Force Type Comments
--- :-----: :----: :--------
url true string url to post danmakus from web
###Example
Request:
POST /api/v1/channels HTTP 1.1
{
"name":"hello",
"desc":"hellooooo",
"ttl":"2",
"sub_passwd":"hello"
}

Response:

{"url":"/channel/hello"}

##Post new danmaku to channel

###URL

/api/v1/channels/<cname>/danmaku

###Method POST ###Authorized true(if pub_passwd of channel is set) ###Request Type json/form ###Request Params

Key Force Type Comments
cname true string Channel name(in url)
text true string text to post
style false string color of this danmaku , values are only avaliable in ["blue","white","red","yellow","cyan","green","purple","black"], default value is white
position false string where to show the danmaku , values are only avaliable in ["top","buttom","fly"], default value is fly
###Response

###Example Request:

POST /api/v1/channels/hello/danmaku HTTP 1.1
X-GDANMAKU-AUTH-KEY: hello
{
"text":"ni hao",
"style":"white",
"position":"fly"
}

Response:

OK

##Get new danmaku from a channel

###URL

/api/v1/channels/<cname>/danmaku

###Method POST ###Authorized true(if sub_passwd of channel is set) ###Request Params

Key Force Type Comments
cname true string Channel name(in url)

###Response Params | :text | true | string | text to post | | :style | false | string | color of this danmaku , values are only avaliable in ["blue","white","red","yellow","cyan","green","purple","black"], default value is white | | :position | false | string | where to show the danmaku , values are only avaliable in ["top","buttom","fly"], default value is fly | ###Example Request:

GET /api/v1/channels/hello/danmaku HTTP 1.1
X-GDANMAKU-AUTH-KEY: hello

Response:

[
{
"text":"ni hao",
"style":"white",
"position":"fly"
},
{
"text":"hello how are you",
"style":"white",
"position":"fly"
}
]
Clone this wiki locally