-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
497 lines (424 loc) · 17.4 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
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
FORMAT: 1A
HOST: http://www.google.com
# SickSense
Crowd-sourcing epidemic detection. Collect reports from people to detect the disease or epidemic early.
# Group User
User related API.
## User [/users]
User resource.
+ Parameters
+ id (string) ... User ID.
+ Model (application/hal+json)
HAL+JSON representation of Gist Resource.
+ Headers
Links: <http://api.doctormesurveillance.com/users/3>;rel="self"
+ Body
{
"meta": {
"status": 200
},
"response": {
"_links": {
"self": { "href": "/users/3" }
},
"id": "3",
"email": "[email protected]",
"tel": "0841291342",
"gender": "male",
"birthYear": 1986,
"address": {
"subdistrict": "Samsen-Nok",
"district": "Huay Kwang",
"city": "Bangkok"
},
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"createdAt": "2014-05-02T19:00:00.000Z"
}
}
### Create new user [POST]
Create new user or you can called it "Registration". Return User object with additional fields:
- accessToken (string) ... Use for later request to all other APIs.
+ Parameters
+ email (string, `[email protected]`) ... E-mail for registration.
+ password (string) ... Password.
+ tel (string, `0841291342`) ... Telephone number. Valid with country prefix or dash.
+ gender (string, `male`) ... Specify user gender. Valid only *male*, *female*.
+ birthYear (number, `1986`) ... User's birth year. Must use C.E.
+ address (json) ... Contains address fields: subdistrict, district, city.
+ location (json) ... Current GPS location.
+ Request (application/json)
{
"email": "[email protected]",
"password": "1z2x3c4v",
"tel": "0841291342",
"gender": "male",
"birthYear": 1986,
"address": {
"subdistrict": "Samsen-Nok",
"district": "Huay Kwang",
"city": "Bangkok"
},
"location": {
"latitude": 13.1135,
"longitude": 105.0014
}
}
+ Response 200 (application/hal+json)
{
"meta": {
"status": 200
},
"response": {
"_links": {
"self": { "href": "/users/3" }
},
"id": "3",
"email": "[email protected]",
"tel": "0841291342",
"gender": "male",
"birthYear": 1986,
"address": {
"subdistrict": "Samsen-Nok",
"district": "Huay Kwang",
"city": "Bangkok"
},
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"accessToken": "CAACEdEose0cBAARMdeXJe0AjxDbs6039b9mb5kPqwSxTjdZBUOa4ZAlgW1IwEhGXhduR1abOeOj7S9mp2uXBHbkJRJCSzYeMtXQPALM66ahlnh3ZB4U8hCCDbPR4rC9GeiGsYyjfUUUUvPZBkgHJeoVlNUpLnEgzEqOuvD0ol8hn5zQVBojFMxDLt3HeuAbBdOtEggwMEQZDZD",
"createdAt": "2014-05-02T19:00:00.000Z"
}
}
+ Response 400 (application/json)
{
"meta": {
"status": 400,
"errorType": "Bad Request",
"errorMessage": "Invalid parameters : E-mail field is required.",
"developerMessage": "E-mail field is required",
"invalidFields": [
"email": "E-mail field is required",
"password": "Password field is required"
]
}
}
+ Response 409 (application/json)
{
"meta": {
"status": 409,
"errorType": "Conflict",
"errorMessage": "This e-mail is already registered, please login or try another e-mail",
"developerMessage": "This e-mail is already taken."
}
}
## Report History [/users/{id}/reports{?accessToken,offset,limit}]
List of user reports. Show reports by most latest date.
+ Parameters
+ id (string) ... User ID.
+ accessToken (string) ... Required. Must match with requesting `id`.
+ offset (number, optional) ... Offset. Default to `0`
+ limit (number, optional) ... Limit. Default to `10`
### Get user history [GET]
Get user illness history.
+ Response 200 (application/hal+json)
+ Headers
Links: <http://api.doctormesurveillance.com/users/3/reports>;rel="self"
+ Body
{
"meta": {
"status": 200
},
"response": {
"reports": {
"count": 2,
"items": [
{
"_links": {
"self": { "href": "/reports/1" }
},
"symptoms": [
{
"_links": {
"self": { "href": "/symptoms/1" },
},
"id": "1",
"name": "Fever"
}
],
"id": "1",
"isFine": false,
"animalContact": true,
"startedAt": "2014-03-01T10:00:00.000Z",
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"moreInfo": "Symptoms of H1N1 swine flu are like regular flu symptoms and include fever, cough, sore throat, runny nose, body aches, headache, chills, and fatigue. Many people with swine flu have had diarrhea and vomiting.",
"createdAt": "2014-05-02T19:00:00.000Z"
},
{
"_links": {
"self": { "href": "/reports/2" }
},
"symptoms": [],
"id": "1",
"isFine": true,
"animalContact": false,
"startedAt": "2014-02-01T10:00:00.000Z",
"location": {
"latitude": 13.1134,
"longitude": 105.0015
},
"moreInfo": "",
"createdAt": "2014-05-02T20:00:00.000Z"
}
]
}
}
}
## Login [/login]
Authentication process.
### Login [POST]
Login to use the system. Force using HTTPS (SSL). Return User object with additional fields:
- accessToken (string) ... Use for later request to all other APIs.
+ Parameters
+ email (string, `[email protected]`) ... E-mail that already registered.
+ password (string) ... Password.
+ Request (application/json)
{
"email": "[email protected]",
"password": "1z2x3c4v"
}
+ Response 200 (application/hal+json)
{
"meta": {
"status": 200
},
"response": {
"_links": {
"self": { "href": "/users/3" }
},
"id": "3",
"email": "[email protected]",
"tel": "0841291342",
"gender": "male",
"birthYear": 1986,
"address": {
"subdistrict": "Samsen-Nok",
"district": "Huay Kwang",
"city": "Bangkok"
},
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"accessToken": "CAACEdEose0cBAARMdeXJe0AjxDbs6039b9mb5kPqwSxTjdZBUOa4ZAlgW1IwEhGXhduR1abOeOj7S9mp2uXBHbkJRJCSzYeMtXQPALM66ahlnh3ZB4U8hCCDbPR4rC9GeiGsYyjfUUUUvPZBkgHJeoVlNUpLnEgzEqOuvD0ol8hn5zQVBojFMxDLt3HeuAbBdOtEggwMEQZDZD",
"createdAt": "2014-05-02T19:00:00.000Z"
}
}
# Group Report
Illness (or just fine) report from users.
## Report [/reports]
+ Model (application/hal+json)
+ Headers
Links: <http://api.doctormesurveillance.com/reports/1a2b>;rel="self"
+ Body
{
"meta": {
"status": 200
},
"response": {
"_links": {
"self": { "href": "/reports/1" }
},
"isFine": false,
"symptoms": [ "fever", "cough" ],
"id": "1",
"animalContact": true,
"startedAt": "2014-03-01T10:00:00.000Z",
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"moreInfo": "Symptoms of H1N1 swine flu are like regular flu symptoms and include fever, cough, sore throat, runny nose, body aches, headache, chills, and fatigue. Many people with swine flu have had diarrhea and vomiting.",
"createdAt": "2014-05-02T19:00:00.000Z"
}
}
### GET /reports{?offset,limit,sw,ne}
Return list of reports determine by provided criterias (parameters).
+ Parameters
+ offset (number, optional) ... Offset. Default to `0`
+ limit (number, optional) ... Limit. Default to `10`
+ sw (float, optional) ... Required if `ne` is provided. Boundary query. Latitude and longitude coordinates of the south-west boundary.
+ ne (float, optional) ... Required if `sw` is provided. Boundary query. Latitude and longitude coordinates of the north-east boundary.
+ Response 200 (application/hal+json)
+ Headers
Links: <http://api.doctormesurveillance.com/reports>;rel="self"
+ Body
{
"meta": {
"status": 200
},
"response": {
"reports": {
"count": 2,
"items": [
{
"_links": {
"self": { "href": "/reports/1" }
},
"id": "1",
"isFine": false,
"symptoms": [ "fever", "cough" ],
"animalContact": true,
"startedAt": "2014-03-01T10:00:00.000Z",
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"moreInfo": "Symptoms of H1N1 swine flu are like regular flu symptoms and include fever, cough, sore throat, runny nose, body aches, headache, chills, and fatigue. Many people with swine flu have had diarrhea and vomiting.",
"createdAt": "2014-05-02T19:00:00.000Z"
},
{
"_links": {
"self": { "href": "/reports/2" }
},
"id": "1",
"isFine": true,
"symptoms": [],
"animalContact": false,
"startedAt": "2014-02-01T10:00:00.000Z",
"location": {
"latitude": 13.1134,
"longitude": 105.0015
},
"moreInfo": "",
"createdAt": "2014-05-02T20:00:00.000Z"
}
]
}
}
}
### GET /reports/{id}{?accessToken}
+ Parameters
+ id (string) ... Report ID.
+ accessToken (string) ... Current user must match with report `id` or else will return `403 forbidden`
+ Response 200 (application/hal+json)
[Report][]
### POST /reports{?accessToken}
+ Parameters
+ accessToken (string) ... Current user access token.
+ isFine (boolean) ... If fine set this to `true`, else is `false`.
+ symptoms (array) ... List of symptoms ID. Required if `isFine` is `true`.
+ animalContact (boolean) ... Whether if contact animal recently.
+ startedAt (datetime) ... When the illness happened.
+ location (json) ... Get from GPS location data when user report.
+ moreInfo (string) ... More details about the illness.
+ Request (application/json)
{
"isFine": false,
"symptoms": [ "fever", "cough" ],
"animalContact": true,
"startedAt": "2014-03-01T10:00:00.000Z",
"location": {
"latitude": 13.1135,
"longitude": 105.0014
},
"moreInfo": "Symptoms of H1N1 swine flu are like regular flu symptoms and include fever, cough, sore throat, runny nose, body aches, headache, chills, and fatigue. Many people with swine flu have had diarrhea and vomiting.",
}
+ Response 200 (application/hal+json)
[Report][]
+ Response 400 (application/json)
{
"meta": {
"status": 400,
"errorType": "Bad Request",
"errorMessage": "Please tell us did you contact with animal before?",
"developerMessage": "animalContact field is required",
"invalidFields": [
"animalContact": "animalContact field is required",
"location": "location field is required"
]
}
}
# Group Dashboard
## Dashboard [/dashboard]
### Get dashboard data [GET]
Get all data ready to show on dashboard. These contains:
- Reports by city.
- ILI statistics.
- Number of reporters.
- BoE ILI data.
- SickSense ILI data.
- List of symptoms order by most report.
+ Parameters
+ city (string, `Bangkok`) ... Specify city to get data of.
+ date (string, optional) ... Date in the week to display as last week. May use the first day of the week.
+ Response 200 (application/hal+json)
{
"meta": {
"status": 200
},
"response": {
"reports": {
"count": 305,
"items": [
{
"subdistrict": "Samsen Nok",
"district": "Huai Khwang",
"city": "Bangkok",
"latitude": 13.1001,
"longitude": 105.0011,
"fineCount": 100,
"sickCount": 4
},
{
"subdistrict": "Samsen Nai",
"district": "Huai Khwang",
"city": "Bangkok",
"latitude": 13.2501,
"longitude": 105.4511,
"fineCount": 80,
"sickCount": 19
}
]
},
"ILI": {
"thisWeek": 3.0,
"lastWeek": 3.7,
"delta": -0.7
},
"numberOfReporter": 124,
"numberOfReports": 362,
"numberOfPeopleFine": 180,
"numberOfPeopleSick": 20,
"percentOfPeopleFine": 90,
"percentOfPeopleSick": 10,
"graphs": {
"BOE": [
0.0, 0.0, 0.0, 0.3, 0.5, 0.8, 1.6, 3.2, 6.4, 7.2, 7.8, 7.85, 7.8,
7.2, 6.4, 3.2, 1.6, 0.8, 0.5, 0.3, 0.2, 0.0, 0.0
],
"SickSense": [
0.0, 0.3, 0.5, 0.8, 1.6, 3.2, 6.4, 7.2, 7.8, 7.85, 7.8, 7.2, 6.4,
3.2, 1.6, 0.8, 0.5, 0.3, 0.2, 0.0, 0.0, 0.0, 0.0
]
},
"topSymptoms": [
{
"name": "Headache",
"percentOfReports": 7.25,
"numbersOfReports": 9
},
{
"name": "Trauma",
"percentOfReports": 4.03,
"numbersOfReports": 5
}
]
}
}