-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapiary.apib
176 lines (135 loc) · 5.24 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
FORMAT: 1A
HOST: http://openelect.org/api/v1/
# OpenElect
A platform for secure, verifiable elections built in node.js.
# OpenElect API Root [/]
This resource does not have any attributes. Instead it offers the initial
API affordances in the form of the links in the JSON body.
## Retrieve the Entry Point [GET]
+ Response 200 (application/json)
{
"elections_url": "/api/v1/elections",
"create_election": "/api/v1/elections/create"
"update_electoin": "/api/v1/elections/{id}"
}
## Group Elections
Resources related to Elections in the API.
## Election [/elections]
Elections are the top-level organizational unit for OpenElect content. Elections contain polls, which contain questions.
+ question
+ published_at - An ISO8601 date when the question was published.
+ url
+ choices - An array of Choice objects.
+ Parameters
+ election_id (required, number, `1`) ... ID of the Election in form of an integer
### List all Elections [GET]
+ Response 200 (application/json)
[
{
"id": 2,
"owner_id": 1,
"name": "2016 Federal Electioons",
"description": "Federal elections for United States Presidency and Congress",
"start": "2016-11-08T08:00:00.000Z",
"end": "2016-11-10T08:00:00.000Z",
"timed": true,
"accepting_votes": null,
"locked": null,
"privacy_strategy": "secret",
"url_handle": null,
"randomize_answer_order": true,
"two_factor_auth": true,
"force_two_factor_auth": false,
"results": null,
"created_at": "2015-04-10T23:18:16.016Z",
"updated_at": "2015-04-10T23:18:16.016Z",
"poll": [ ]
}
]
## Choice [/questions/{question_id}/choices/{choice_id}]
+ Parameters
+ question_id (required, number, `1`) ... ID of the Question in form of an integer
+ choice_id (required, number, `1`) ... ID of the Choice in form of an integer
### Vote on a Choice [POST]
This action allows you to vote on a question's choice.
+ Response 201
+ Headers
Location: /questions/1
## Questions Collection [/questions{?page}]
+ Parameters
+ page (optional, number, `1`) ... The page of questions to return
### List All Questions [GET]
+ Response 200 (application/json)
+ Headers
Link: </questions?page=2>; rel="next"
+ Body
[
{
"question": "Favourite programming language?",
"published_at": "2014-11-11T08:40:51.620Z",
"url": "/questions/1",
"choices": [
{
"choice": "Swift",
"url": "/questions/1/choices/1",
"votes": 2048
}, {
"choice": "Python",
"url": "/questions/1/choices/2",
"votes": 1024
}, {
"choice": "Objective-C",
"url": "/questions/1/choices/3",
"votes": 512
}, {
"choice": "Ruby",
"url": "/questions/1/choices/4",
"votes": 256
}
]
}
]
### Create a New Question [POST]
You may create your own question using this action. It takes a JSON
object containing a question and a collection of answers in the
form of choices.
+ question (string) - The question
+ choices (array[string]) - A collection of choices.
+ Request (application/json)
{
"question": "Favourite programming language?",
"choices": [
"Swift",
"Python",
"Objective-C",
"Ruby"
]
}
+ Response 201 (application/json)
+ Headers
Location: /questions/2
+ Body
{
"question": "Favourite programming language?",
"published_at": "2014-11-11T08:40:51.620Z",
"url": "/questions/2",
"choices": [
{
"choice": "Swift",
"url": "/questions/2/choices/1",
"votes": 0
}, {
"choice": "Python",
"url": "/questions/2/choices/2",
"votes": 0
}, {
"choice": "Objective-C",
"url": "/questions/2/choices/3",
"votes": 0
}, {
"choice": "Ruby",
"url": "/questions/2/choices/4",
"votes": 0
}
]
}