-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapiary.apib
More file actions
259 lines (223 loc) · 9 KB
/
apiary.apib
File metadata and controls
259 lines (223 loc) · 9 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
FORMAT: 1A
HOST: http://askuw.sahiljain.ca/api
# WaterlooAnswers
The WaterlooAnswers API is a university-wide answer service similar to Yahoo Answers.
# WaterlooAnswers API Root [http://askuw.sahiljain.ca/api/]
# Group Login Flow
How to get a session token on login, and sign up.
## /login{?email,password}
### POST
Log in.
+ Parameters
+ email (required, string, `abc`) ... account login email
+ password (required, string, `123`) ... account password
+ Response 200 (application/json; charset=utf-8)
+ Body
{
"sessionToken": "xyzxyzxyzxyzxyzyxyzx323"
}
## /signup{?email,password,firstName}
### POST
Sign up.
+ Parameters
+ email (required, string, `abc`) ... account login email
+ password (required, string, `123`) ... account password
+ firstName (required, string, `Bob`) ... account first name
+ Response 200 (application/json; charset=utf-8)
+ Body
{
"success": true,
"username": "bob@uwaterloo.ca",
"firstName": "Bob",
"token": "some-token"
}
# Group User
Information about the user that is currently logged in
## /user{?token}
### GET
Get user information
+ Parameters
+ token (string, required, `xyzxyzxyyzyyzxy`) ... Your web token given by the '/login' endpoint.
+ Response 200 (application/json; charset=utf-8)
+ Body
{
"userId": "some-id",
"firstName": "bob",
"email": "bob@uwaterloo.ca",
"dateJoined": "2015-02-25T07:22:32.648Z",
"questionsAsked": [
{
"__v": 0,
"_id": "547d6f480f55b4000019be6b",
"asker": "5312dfedd9e81a00002e7c17",
"category": "CS241",
"name": "What are the two ways to branch to a label?",
"numAnswers": 2,
"text": "This was a question from the 2015 final.",
"viewers": [],
"answers": [
"54800991e5588670dad8b401",
"54ed289b7bdd153a9f590781"
],
"time": "2014-12-02T07:50:32.200Z",
"favourites": []
}
],
"answersGiven": [
{
"questionId": "547d6f480f55b4000019be6b",
"questionName": "What are the two ways to branch to a label?",
"questionDescription": "This was a question from the 2015 final.",
"answerId": "54800991e5588670dad8b401",
"answerText": "You can either write beq $0, $0, label, or store the label's address in a register and jr to the register.",
"answerTime": "2014-12-04T07:13:21.906Z"
}
]
}
# Group Questions
## Get Single Question [/questions/{id}]
### GET
Get a single question by ID:
+ Parameters
+ id (required, string, `5317e88ad5dcc70c283f450a`) ... ID of the question you want
+ Response 200 (application/json; charset=utf-8)
+ Body
{
questionId: "5331b06a5c1ad0f0bfa1f8cc",
name: "What course do I choose?",
description: "Chem or physics",
askerName: "sahil",
askerId: "5312dfedd9e81a00002e7c17",
askerEmail: "abc",
category: "Course Selection",
numAnswers: 3,
answers: [
{
answererId: "5312dfedd9e81a00002e7c17",
text: "dfhfsz",
answerId: "53e4f91207e37a00008f3658",
timeAnswered: "2014-08-08T16:21:38.494Z"
},
{
answererId: "5312dfedd9e81a00002e7c17",
text: "dfsdfgzdfgsz",
answerId: "53e4f91507e37a00008f3659",
timeAnswered: "2014-08-08T16:21:41.809Z"
},
{
answererId: "5312dfedd9e81a00002e7c17",
text: "xfzcvbx",
answerId: "53e4f91807e37a00008f365a",
timeAnswered: "2014-08-08T16:21:44.043Z"
}
],
favourites: [ ],
numVotes: 0,
timeAsked: "2014-03-25T16:35:54.021Z"
}
## Questions [/questions]
### DELETE
Delete a single question by ID:
+ Request (application/json)
{
"id": "question_id",
"token": "login_token"
}
+ Response 204
### POST
Add a question to the database:
+ Request (application/json)
{
"questionTitle": "My Question Title",
"questionDescription": "The rest of my question",
"categoryIndex": 3,
"token": "login_token"
}
+ Response 200
## TODO Upvote a question [/questions/{id}/upvote{?token}]
### PUT
+ Parameters
+ id (required, string, `5317e88ad5dcc70c283f450a`) ... ID of the question you want to upvote
+ token (string, required, `xyzxyzxyyzyyzxy`) ... Your web token given by the '/login' endpoint.
+ Response 200 (application/json; charset=utf-8)
+ Body
{
"success":true
}
## TODO Downvote a question [/questions/{id}/downvote{?token}]
### PUT
+ Parameters
+ id (required, string) ... ID of the question you want to downvote
+ token (string, required, `xyzxyzxyyzyyzxy`) ... Your web token given by the '/login' endpoint.
+ Response 200 (application/json; charset=utf-8)
+ Body
{
"success":true
}
## Get a Set of Questions by parameters [/questions{?questionsPerPage,pageNumber,sortOrder,categoryId}]
### GET
+ Parameters
+ questionsPerPage = `20` (optional, number) ... the number of questions you want to recieve
+ pageNumber = `1` (optional, number) ... the page of questions you want to recieve
+ sortOrder = `mostRecent` (optional, string) ... how you want the questions to be sorted
+ Values
+ `mostRecent`
+ `mostFavourited`
+ `mostViewed`
+ categoryId (optional, integer) ... which category of questions you want to see (find the categoryId from the /categories endpoint)
+ Response 200 (application/json; charset=utf-8)
+ Body
[
{
"askerId" : "5312dfedd9e81a00002e7c17",
"askerName" : "sahil",
"category" : "Technology/Startups",
"description" : "",
"name" : "How do I start a start up?",
"numAnswers" : 1,
"questionId" : "5326041c21e726653736276f",
"timeAsked" : "2014-03-16T20:05:48.647Z"
},
{
"askerId" : "5312dfedd9e81a00002e7c17",
"askerName" : "sahil",
"category" : "Course Selection",
"description" : "Chem or physics",
"name" : "What course do I choose?",
"numAnswers" : 0,
"questionId" : "5331b06a5c1ad0f0bfa1f8cc",
"timeAsked" : "2014-03-25T16:35:54.021Z"
},
{
"askerId" : "5312dfedd9e81a00002e7c17",
"askerName" : "sahil",
"category" : "Finances",
"description" : "ggfdgfdg",
"name" : "gtgfd",
"numAnswers" : 0,
"questionId" : "5335c0495c1ad0f0bfa1f8ce",
"timeAsked" : "2014-03-28T18:32:41.512Z"
}
]
# Group Answers
## Post an Answer to a Question [/answers]
### POST
+ Request (application/json)
{
"questionId": "question-id",
"answerBody": "This is my answer",
"token": "login-token"
}
+ Response 200 (application/json; charset=utf-8)
+ Body
{
result: "Successfully added answer!",
questionId: "question_id",
answerId: "answerSaved_id"
}
# Group Categories
### Get all of the question category ID's, and their names.
## GET /categories
+ Response 200 (application/json; charset=utf-8)
+ Body
[{"categoryId":0,"categoryName":"Admissions/Program Advice"},{"categoryId":1,"categoryName":"Campus Facilities"},{"categoryId":2,"categoryName":"Co-op/Jobmine"},{"categoryId":3,"categoryName":"Course Selection"},{"categoryId":4,"categoryName":"Extracurriculars"},{"categoryId":5,"categoryName":"Finances"},{"categoryId":6,"categoryName":"General Advice"},{"categoryId":7,"categoryName":"Homework/Exams"},{"categoryId":8,"categoryName":"Parties/Student Life"},{"categoryId":9,"categoryName":"Programming"},{"categoryId":10,"categoryName":"Residence"},{"categoryId":11,"categoryName":"Technology/Startups"},{"categoryId":12,"categoryName":"Other"}]