-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapiary.apib
More file actions
362 lines (308 loc) · 9.33 KB
/
apiary.apib
File metadata and controls
362 lines (308 loc) · 9.33 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
dFORMAT: 1A
HOST: http://libellis.herokuapp.com/
# libellis
Libellis is a ranked voting application with a simple API for users to create, share, and vote on surveys, where each survey question would effictively be a poll.
To start please create a user account - you will need a token to use many of our routes.
## User Resource [/users]
Create a user by supplying a username, password, first name, last name and email address. Your password will be stored as an encrypted password on our server. If you lose your password it is **impossible** for us to get it for you. We also do NOT keep server logs.
### Create a User [POST]
+ Request (application/json)
{
"username": "hackerman",
"password": "hackerman",
"first_name": "hacker",
"last_name": "man",
"email": "hackerman@hacker.com"
}
+ Response 200 (application/json)
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImhhY2tlcm1hbiIsImlzX2FkbWluIjpmYWxzZSwiaWF0IjoxNTQ2OTcwNDAzfQ.YfTiu1e1YPy8pa4need1m4rg3VGHzmcKepcUunHI_HA"
}
## Login Path [/login]
Log in with your username and password if you need a fresh token.
### Login for Token [POST]
+ Request (application/json)
{
"username": "hackerman",
"password": "hackerman"
}
+ Response 200 (application/json)
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImhhY2tlcm1hbiIsImlzX2FkbWluIjpmYWxzZSwiaWF0IjoxNTQ2OTcwNDAzfQ.YfTiu1e1YPy8pa4need1m4rg3VGHzmcKepcUunHI_HA"
}
## Surveys Resource [/surveys]
### List All Surveys [GET]
+ Response 200 (application/json)
{
"surveys": [
{
"title": "Best Dance Music 2019",
"date_posted": "2019-01-02T23:37:08.064Z",
"published": true,
"description": "Hottest dance hits from 2019 survey",
"anonymous": true,
"_id": 40,
"author": "Michael Jackson"
},
{
"title": "Favorite Spiritual Advisor",
"date_posted": "2019-01-03T21:02:05.064Z",
"published": true,
"description": "Newage Poll for Facebook Moms",
"anonymous": true,
"_id": 41,
"author": "Deepak Choprah"
}
]
}
### Create a Survey [POST]
You may create your own survey using this action.
This action takes a JSON payload as part of the request.
Response then return details about survey created.
+ Request (application/json)
{
"title": "Best Dance Music 2019",
"description": "Hottest dance hits from 2019 survey"
"_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IlVycGxlRWVwbGUiLCJpc19hZG1pbiI6ZmFsc2UsImlhdCI6MTU0Mjk1NTYwMn0.CfvAlM6xXS7uK0B5X1JwRj3lb5kGJSJ7qaCdWxyGgCQ"
}
+ Response 200 (application/json)
{
"survey": [
{
"title": "Best Dance Music 2019",
"date_posted": "2019-01-02T23:37:08.064Z",
"published": false,
"description": "Hottest dance hits from 2019 survey",
"anonymous": true,
"_id": 40,
"author": "Michael Jackson"
}
]
}
## Single Survey [/surveys/{survey_id}]
### Get One Survey [GET]
+ Response 200 (application/json)
{
"survey": [
{
"title": "Best Dance Music 2019",
"date_posted": "2019-01-02T23:37:08.064Z",
"published": true,
"description": "Hottest dance hits from 2019 survey",
"anonymous": true,
"_id": 40,
"author": "Michael Jackson",
"questions": [
{
"title": "Best House Music of the Year"
"type": "ranked",
"_survey_id": 40,
"_id": 20
},
{
"title": "Best Bass Music of the Year"
"type": "ranked",
"_survey_id": 40,
"_id": 21
}
]
}
]
}
## Questions Sub-Resource [/surveys/{survey_id}/questions]
### List All Questions by a Survey id [GET]
+ Response 200 (application/json)
{
"questions": [
{
"_id": 20,
"_survey_id": 40,
"type": "ranked",
"title": "Favorite Popsicle Flavor",
"choices": [
{
"_id": 68,
"_question_id": 20,
"content": null,
"title": "Strawberry",
"type": "text"
},
{
"_id": 69,
"_question_id": 20,
"content": null,
"title": "Vanilla",
"type": "text"
},
{
"_id": 70,
"_question_id": 20,
"content": null,
"title": "Cherry",
"type": "text"
},
{
"_id": 71,
"_question_id": 20,
"content": null,
"title": "Blueberry",
"type": "text"
}
]
}
]
}
### Create a New Question [POST]
You may create your own question using this action. It takes a JSON
object containing a question and an array of choices to pick from
+ Request (application/json)
{
"_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IlVycGxlRWVwbGUiLCJpc19hZG1pbiI6ZmFsc2UsImlhdCI6MTU0Mjk1NTYwMn0.CfvAlM6xXS7uK0B5X1JwRj3lb5kGJSJ7qaCdWxyGgCQ",
"title": "Favorite President",
"type": "ranked",
"choices": [
{
"type": "text",
"title": "FDR"
},
{
"type": "text",
"title": "Barack Obama"
},
{
"type": "text",
"title": "George Bush"
},
{
"type": "text",
"title": "George Washington"
}
]
}
+ Response 200 (application/json)
{
"_id": 3,
"_survey_id": 20,
"title": "Favorite President",
"type": "ranked",
"choices": [
{
"_id": 9,
"type": "text",
"title": "FDR",
"content": null,
"_question_id": 3
},
{
"_id": 10,
"type": "text",
"title": "Barack Obama",
"content": null,
"_question_id": 3
},
{
"_id": 11,
"type": "text",
"title": "George Bush",
"content": null,
"_question_id": 3
},
{
"_id": 12,
"type": "text",
"title": "George Washington",
"content": null,
"_question_id": 3
}
]
}
## Votes Sub-Resource [/surveys/{survey_id}/votes]
### Get Vote Tally for Survey [GET]
+ Response 200 (application/json)
{
"results": [
{
"question_id": 2,
"vote_results": [
{
"votes": 7,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Elie Schoppik"
},
{
"votes": 6,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Steve Jerbs"
},
{
"votes": 5,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Matthew Lane"
},
{
"votes": 2,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Chill Gates"
}
]
}
]
}
### Cast Votes for Survey [POST]
+ Request (application/json)
{
"_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IlVycGxlRWVwbGUiLCJpc19hZG1pbiI6ZmFsc2UsImlhdCI6MTU0Mjk1NTYwMn0.CfvAlM6xXS7uK0B5X1JwRj3lb5kGJSJ7qaCdWxyGgCQ",
"votes": [
{
"question_id": 2,
"vote_data": [
{
"choice_id": 5,
"score": 4
},
{
"choice_id": 6,
"score": 3
},
{
"choice_id": 7,
"score": 2
},
{
"choice_id": 8,
"score": 1
}
]
}
]
}
+ Response 200 (application/json)
{
"results": [
{
"question_id": 2,
"vote_results": [
{
"votes": 11,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Elie Schoppik"
},
{
"votes": 9,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Steve Jerbs"
},
{
"votes": 7,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Matthew Lane"
},
{
"votes": 3,
"question_title": "Favorite Bootcamp CEO",
"choice_title": "Chill Gates"
}
]
}
]
}