forked from jokamjohn/bucket_api_heroku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apid
648 lines (454 loc) · 15 KB
/
apiary.apid
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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
FORMAT: 1A
HOST: http://kbucket-api.herokuapp.com
# BucketList
Bucketlist is an API allowing a user to register, login to create a bucket and
bucket items.
## User Registration [/auth/register]
### Register a user [POST]
You can create a user by sending a json request with an email and password. The
password must be four(4) characters and more.
+ Request (application/json)
{
"email": "[email protected]",
"password": "123456"
}
+ Response 201 (application/json)
{
"auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MDM0ODQ5OTYsImlhdCI6MTUwMzM5ODU4Niwic3ViIjo1fQ.GC6IEOohdo_xrz9__UeugIlir0qtJdKbEzBtLgqjt5A",
"message": "Successfully registered",
"status": "success"
}
+ Response 202 (application/json)
{
"message": "Missing or wrong email format or password",
"status": "failed"
}
+ Response 202 (application/json)
{
"message": "Failed, User already exists, Please sign In",
"status": "failed"
}
+ Response 202 (application/json)
{
"message": "Content-type must be json",
"status": "failed"
}
## Login [/auth/login]
### Login a user [POST]
You can login a user by sending their email and password. Please take note
of the auth token for you will need it for all user requests.
+ Request (application/json)
{
"email": "[email protected]",
"password": "123456"
}
+ Response 201 (application/json)
{
"auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MDM0ODQ5OTYsImlhdCI6MTUwMzM5ODU4Niwic3ViIjo1fQ.GC6IEOohdo_xrz9__UeugIlir0qtJdKbEzBtLgqjt5A",
"message": "Successfully registered",
"status": "success"
}
+ Response 202 (application/json)
{
"message": "Content-type must be json",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "Missing or wrong email format or password is less than four characters",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "User does not exist or password is incorrect",
"status": "failed"
}
## Logout [/auth/logout]
### Log out a user [POST]
You can log out a user by sending a request with their email and address. The
auth token will then be invalidated.
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 200 (application/json)
{
"message": "Successfully logged out",
"status": "success"
}
+ Response 403 (application/json)
{
"message": "Provide a valid auth token",
"status": "failed"
}
+ Response 403 (application/json)
{
"message": "Provide an authorization header",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "Signature expired, Please sign in again",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "Invalid token. Please sign in again",
"status": "failed"
}
## Bucket Resources [/bucketlists{?page}{?q}]
You can create, read, update and delete buckets.
NOTE: A valid token should be present in the header else a 401 or 403 response
will be returned as seen in the log out section.
+ Parameters
+ page(optional, number, `1`) - The page number
+ q(optional, string) - Search query
### Create a Bucket [POST]
Add a new Bucket attached to the user
+ name (required, string) - Name of the Bucket
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Body
{
"name": "Travel"
}
+ Response 201 (application/json)
{
"createdAt": "Wed, 23 Aug 2017 10:14:52 GMT",
"id": 2,
"modifiedAt": "Wed, 23 Aug 2017 10:14:52 GMT",
"name": "Travel",
"status": "success"
}
+ Response 202 (application/json)
{
"message": "Content-type must be json",
"status": "failed"
}
+ Response 400 (application/json)
{
"message": "Missing name attribute",
"status": "failed"
}
### List all Buckets [GET]
You can get a list of all the Buckets that below to a user. The results are
paginated with the previous and next url.
You can also search for a Bucket by its name using the q query parameter.
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 200 (application/json)
{
"buckets": [
{
"createdAt": "2017-09-05T17:55:33.120344",
"id": 2,
"modifiedAt": "2017-09-05T17:55:33.120344",
"name": "Property & Casualty Insurance"
},
{
"createdAt": "2017-09-05T17:55:33.127347",
"id": 3,
"modifiedAt": "2017-09-05T17:55:33.127347",
"name": "Technology"
},
{
"createdAt": "2017-09-05T17:55:33.134350",
"id": 4,
"modifiedAt": "2017-09-05T17:55:33.134350",
"name": "Waste Management"
},
{
"createdAt": "2017-09-05T17:55:33.140357",
"id": 5,
"modifiedAt": "2017-09-05T17:55:33.140357",
"name": "Auto Parts Wholesale"
}
],
"count": 99,
"next": "http://127.0.0.1:5000/bucketlists/?page=2",
"previous": null,
"status": "success"
}
+ Response 200 (application/json)
{
"buckets": [],
"count": 0,
"next": null,
"previous": null,
"status": "success"
}
## Single Bucket Resources [/bucketlists/{bucket_id}]
+ Parameters
+ bucket_id (required,number) - Id of the bucket to be returned
### Get a Bucket [GET]
You get a single bucket by specifying its Id.
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 200 (application/json)
{
"bucket": {
"createdAt": "2017-08-24T19:56:07.942974",
"id": 3,
"modifiedAt": "2017-08-24T19:56:07.942974",
"name": "Travel"
},
"status": "success"
}
+ Response 400 (application/json)
{
"message": "Please provide a valid Bucket Id",
"status": "failed"
}
### Edit a Bucket [PUT]
You can update the name of the Bucket
+ name (required, string) - Name of the Bucket
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Body
{
"name": "Travel"
}
+ Response 201 (application/json)
{
"createdAt": "Tue, 05 Sep 2017 17:55:33 GMT",
"id": 2,
"modifiedAt": "Tue, 05 Sep 2017 17:55:33 GMT",
"name": "Cooking",
"status": "success"
}
+ Response 202 (application/json)
{
"message": "Content-type must be json",
"status": "failed"
}
+ Response 400 (application/json)
{
"message": "Please provide a valid Bucket Id",
"status": "failed"
}
+ Response 400 (application/json)
{
"message": "No attribute or value was specified, nothing was changed",
"status": "failed"
}
+ Response 404 (application/json)
{
"message": "The Bucket with Id does not exist",
"status": "failed"
}
### Delete a Buket [DELETE]
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 200 (application/json)
{
"message": "Successfully deleted the item from bucket with Id 3",
"status": "success"
}
+ Response 400 (application/json)
{
"message": "Please provide a valid Bucket Id",
"status": "failed"
}
+ Response 404 (application/json)
{
"message": "Bucket resource cannot be found",
"status": "failed"
}
## Bucket Item Resources [/bucketlists/{bucket_id}/items{?page}/{?q}]
You can create, read, update and delete bucket items.
NOTE: A valid token should be present in the header else a 401 or 403 response
will be returned as seen in the log out section.
The Bucket Id must be valid else a response with code status 401 will be returned
+ Parameters
+ bucket_id (required, number) - Id of the Bucket
+ page (optional, number, `1`) - Page to return
+ q (optional, string) - Search query string
### Get all items within a bucket [GET]
You can get all the items within the bucket if they exist others the items
list will be empty.
You can also use the query parameter q to search for an item name within the Bucket as showm below
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 200 (application/json)
{
"count": 9,
"items": [
{
"bucketId": 3,
"createdAt": "2017-09-05T17:55:34.814267",
"description": "sed",
"id": 88,
"modifiedAt": "2017-09-05T17:55:34.814267",
"name": "Tambee"
},
{
"bucketId": 3,
"createdAt": "2017-09-05T17:55:35.768740",
"description": "maecenas",
"id": 166,
"modifiedAt": "2017-09-05T17:55:35.768740",
"name": "Cogilith"
},
{
"bucketId": 3,
"createdAt": "2017-09-05T17:55:36.245435",
"description": "volutpat",
"id": 205,
"modifiedAt": "2017-09-05T17:55:36.245435",
"name": "Nlounge"
},
{
"bucketId": 3,
"createdAt": "2017-09-05T17:55:37.489873",
"description": "quam",
"id": 304,
"modifiedAt": "2017-09-05T17:55:37.489873",
"name": "Flashset"
}
],
"next": "http://127.0.0.1:5000/bucketlists/3/items/?page=2",
"previous": null,
"status": "success"
}
+ Response 200 (application/json)
{
"count": 0,
"items": [],
"next": null,
"previous": null,
"status": "success"
}
+ Response 401 (application/json)
{
"message": "Provide a valid Bucket Id",
"status": "failed"
}
### Add an item to the Bucket [POST]
You can also add an item to the Bucket by sending a name and an optional
description for the item.
+ name (required, string) - Name of the item
+ description (optional, string) - Description of the item
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Body
{
"name": "item",
"description": "loren ipsum"
}
+ Response 201 (application/json)
{
"item": {
"bucketId": 2,
"createdAt": "2017-09-06T19:44:14.606760",
"description": "loren ipsum",
"id": 1001,
"modifiedAt": "2017-09-06T19:44:14.606760",
"name": "item"
},
"status": "success"
}
+ Response 202 (application/json)
{
"message": "User has no Bucket with Id",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "No name or value attribute found",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "Content-type must be application/json",
"status": "failed"
}
## Single Bucket Items Resource [/bucketlists/{bucket_id}/item/{item_id}]
NOTE: A valid token should be present in the header else a 401 or 403 response
will be returned as seen in the log out section.
The Bucket Id must be valid else a response with code status 401 will be returned
+ Parameters
+ bucket_id (required, number) - Id of the Bucket
+ item_id (required, number) - Id of the Item
### Get an Item from the Bucket [GET]
You can get an Item from the Bucjet by specifying the Bucket Id and Item Id
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 201 (application/json)
{
"item": {
"bucketId": 2,
"createdAt": "2017-09-05T17:55:33.742090",
"description": "at",
"id": 2,
"modifiedAt": "2017-09-05T17:55:33.742090",
"name": "Feedmix"
},
"status": "success"
}
+ Response 202 (application/json)
{
"message": "Provide a valid item Id",
"status": "failed"
}
+ Response 202 (application/json)
{
"message": "User has no Bucket with Id",
"status": "failed"
}
### Edit an Item within a Bucket [PUT]
You can also edit an item within the Bucket.
+ name (required, string) - Name of the item
+ description (optional, string) - Description of the item
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Body
{
"name": "item",
"description": "loren ipsum"
}
+ Response 200 (application/json)
{
"item": {
"bucketId": 2,
"createdAt": "2017-09-05T17:55:33.742090",
"description": "loren ",
"id": 2,
"modifiedAt": "2017-09-05T17:55:33.742090",
"name": "travel"
},
"status": "success"
}
+ Response 401 (application/json)
{
"message": "No name or value attribute found",
"status": "failed"
}
+ Response 401 (application/json)
{
"message": "No attributes specified in the request",
"status": "failed"
}
### Delete an item from the Bucket [DELETE]
You can delete an item from a Bucket by sending a delete request, by specifying
the Bucket Id and Item Id.
+ Request (application/json)
+ Headers
Authorization: Bearer JWT Token
+ Response 200 (application/json)
{
"message": "Successfully deleted the item from bucket with Id 2",
"status": "success"
}
+ Response 404 (application/json)
{
"message": "Item not found",
"status": "failed"
}