-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendpoints.json
562 lines (562 loc) · 17.9 KB
/
endpoints.json
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
{
"GET /api": {
"description": "serves up a json representation of all the available endpoints of the api"
},
"GET /api/topics": {
"description": "serves an array of all topics",
"details": {
"queries": [],
"exampleResponses": {
"200": {
"topics": [{ "slug": "football", "description": "Footie!" }]
},
"404": {
"description": "Returns an error message for invalid endpoint.",
"exampleResponse": {
"msg": "404 - Not Found: Endpoint does not exist"
}
}
}
}
},
"POST /api/topics": {
"description": "creates a new topic with a unique slug and description.",
"details": {
"requestBody": {
"slug": "string",
"description": "string"
},
"exampleResponses": {
"201": {
"description": "Returns the newly created topic object.",
"exampleResponse": {
"topic": {
"slug": "new-topic",
"description": "A new topic"
}
}
},
"400": {
"description": "Returns an error message when slug is empty.",
"exampleResponse": {
"msg": "400 - Bad Request: Slug or Description cannot be empty"
}
}
}
}
},
"GET /api/articles": {
"description": "serves an array of all articles",
"details": {
"queries": ["author", "topic", "sort_by", "order", "limit", "page"],
"queryDescriptions": {
"author": "Filter articles by the username of the author",
"topic": "Filter articles by the topic",
"sort_by": "Sort articles by a valid column. Defaults to 'created_at'. Valid columns: article_id, title, author, body, topic, created_at, votes, comment_count",
"order": "Specify 'asc' for ascending or 'desc' for descending order. Defaults to 'desc'",
"limit": {
"description": "limits the number of responses",
"default": 10
},
"page": {
"description": "page number",
"default": 1
}
},
"exampleQueries": [
{
"query": "?sort_by=created_at&order=asc",
"description": "Sort articles by created_at in ascending order"
},
{
"query": "?sort_by=votes&order=desc",
"description": "Sort articles by votes in descending order"
},
{
"query": "?topic='cooking'",
"description": "Filter articles by the topic 'cooking'"
},
{
"query": "?topic=cooking&sort_by=votes&order=asc",
"description": "Filter articles by the topic 'cooking' and sort by votes in ascending order"
}
],
"exampleResponses": {
"200": {
"articles": [
{
"article_id": 33,
"title": "Seafood substitutions are increasing",
"topic": "cooking",
"author": "weegembump",
"body": "Text from the article..",
"created_at": "2018-05-30T15:59:13.341Z",
"votes": 0,
"comment_count": 6
}
],
"total_count": 12
},
"404": {
"description": "Returns an error message for non-existent topic.",
"exampleResponse": {
"msg": "404 - Not Found: Topic not found"
}
}
}
}
},
"POST /api/articles": {
"description": "adds a new article and responds with the newly added article.",
"details": {
"requestBody": {
"description": "The article to be added.",
"example": {
"author": "butter_bridge",
"title": "New Article Title",
"body": "This is the body of the new article.",
"topic": "mitch",
"article_img_url": "http://example.com/img.png"
},
"properties": {
"author": {
"type": "string",
"description": "The username of the article's author."
},
"title": {
"type": "string",
"description": "The title of the article."
},
"body": {
"type": "string",
"description": "The content of the article."
},
"topic": {
"type": "string",
"description": "The topic of the article."
},
"article_img_url": {
"type": "string",
"description": "URL of the article's image. Defaults to a placeholder URL if not provided."
}
}
},
"exampleResponses": {
"201": {
"description": "Responds with the newly added article.",
"article": {
"article_id": 14,
"author": "butter_bridge",
"title": "New Article Title",
"body": "This is the body of the new article.",
"topic": "mitch",
"article_img_url": "http://example.com/img.png",
"votes": 0,
"created_at": "2024-07-19T10:11:10.086Z",
"comment_count": 0
},
"properties": {
"article": {
"type": "object",
"properties": {
"article_id": {
"type": "integer",
"description": "The unique identifier for the article."
},
"author": {
"type": "string",
"description": "The username of the article's author."
},
"title": {
"type": "string",
"description": "The title of the article."
},
"body": {
"type": "string",
"description": "The content of the article."
},
"topic": {
"type": "string",
"description": "The topic of the article."
},
"article_img_url": {
"type": "string",
"description": "URL of the article's image."
},
"votes": {
"type": "integer",
"description": "The number of votes for the article. Defaults to 0."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the article was created."
},
"comment_count": {
"type": "integer",
"description": "The number of comments on the article. Defaults to 0."
}
}
}
}
},
"errors": [
{
"status": 400,
"description": "Returns an error message when required fields are missing.",
"exampleResponse": {
"msg": "400 - Bad Request: Missing required fields"
}
},
{
"status": 404,
"description": "Returns an error message when author does not exist.",
"exampleResponse": {
"msg": "404 - Not Found: Article or User does not exist"
}
},
{
"status": 500,
"description": "Returns an error message when unexpected error occurred.",
"exampleResponse": {
"msg": "Internal Server Error"
}
}
]
}
}
},
"GET /api/articles/:article_id": {
"description": "serves an article object by its id",
"details": {
"queries": [],
"exampleResponse": {
"200": {
"article_id": 1,
"article_img_url": "https://images.pexels.com/photos/158651/news-newsletter-newspaper-information-158651.jpeg?w=700&h=700",
"author": "butter_bridge",
"body": "I find this existence challenging",
"created_at": "2020-07-09T20:11:00.000Z",
"title": "Living in the shadow of a great man",
"topic": "mitch",
"votes": 100,
"comment_count": 11
},
"errors": [
{
"status": 400,
"description": "Returns an error message for an invalid article_id.",
"exampleResponse": {
"msg": "400 - Bad Request: invalid_id"
}
},
{
"status": 404,
"description": "Returns an error message for a non-existent article_id.",
"exampleResponse": {
"msg": "404 - Not Found: Article not found"
}
}
]
}
}
},
"PATCH /api/articles/:article_id": {
"description": "Updates the vote count of an article by article_id",
"details": {
"requestBody": {
"inc_votes": "an integer that indicates how much the votes property should be updated by"
},
"exampleRequest": {
"inc_votes": 1
},
"exampleResponses": {
"200": {
"article": {
"article_id": 1,
"title": "Seafood substitutions are increasing",
"topic": "cooking",
"author": "weegembump",
"body": "Text from the article...",
"created_at": "2020-11-03T09:12:00.000Z",
"votes": 1
}
},
"errors": [
{
"status": 400,
"description": "Returns an error message for an invalid article_id.",
"exampleResponse": {
"msg": "400 - Bad Request: invalid_id"
}
},
{
"status": 400,
"description": "Returns an error message for an invalid inc_votes.",
"exampleResponse": {
"msg": "400 - Bad Request: inc_votes must be a number"
}
},
{
"status": 400,
"description": "Returns an error message when inc_votes is missing in request body.",
"exampleResponse": {
"msg": "400 - Bad Request: inc_votes must be a number"
}
},
{
"status": 404,
"description": "Returns an error message for non-existent article_id.",
"exampleResponse": {
"msg": "404 - Not Found: Article not found"
}
}
]
}
}
},
"DELETE /api/articles/:article_id": {
"description": "deletes an article by its id",
"details": {
"exampleResponses": {
"204": {
"description": "404 - Not Found: Article not found."
},
"errors": [
{
"status": 400,
"description": "Returns an error message for an invalid article_id.",
"exampleResponse": {
"msg": "400 - Bad Request: invalid_id"
}
},
{
"status": 404,
"description": "Returns an error message if the article does not exist.",
"exampleResponse": {
"msg": "404 - Not Found: Article not found"
}
}
]
}
}
},
"GET /api/articles/:article_id/comments": {
"description": "serves an array of comments for a given article_id",
"details": {
"queries": {
"limit": "Limits the number of responses (defaults to 10)",
"page": "Specifies the page at which to start (calculated using limit)"
},
"exampleResponses": {
"200": {
"comments": [
{
"comment_id": 31,
"votes": 11,
"created_at": "2020-09-26T00:17:16.000Z",
"author": "weegembump",
"body": "Oh, I've got compassion running out of my nose, pal! I'm the Sultan of Sentiment!",
"article_id": 1
},
{
"comment_id": 2,
"votes": 14,
"created_at": "2020-11-01T12:56:20.000Z",
"author": "butter_bridge",
"body": "The beautiful thing about treasure is that it exists. Got to find out what kind of sheets these are; not cotton, not rayon, silky.",
"article_id": 1
},
{
"comment_id": 3,
"votes": 100,
"created_at": "2020-03-05T16:46:20.000Z",
"author": "icellusedkars",
"body": "Replacing the quiet elegance of the dark suit and tie with the casual indifference of these muted earth tones is a form of fashion suicide, but, uh, call me crazy — onyou it works.",
"article_id": 1
}
],
"total_count": 3
},
"errors": [
{
"status": 400,
"description": "Returns an error message for an invalid article_id.",
"exampleResponse": {
"msg": "400 - Bad Request: invalid_id"
}
},
{
"status": 400,
"description": "Returns an error message for an invalid query parameters.",
"exampleResponse": {
"msg": "400 - Bad Request: Invalid query parameters"
}
},
{
"status": 404,
"description": "Returns an error message if the article does not exist.",
"exampleResponse": {
"msg": "404 - Not Found: Article not found"
}
}
]
}
}
},
"POST /api/articles/:article_id/comments": {
"description": "adds a comment for the specified article ID",
"details": {
"requestBody": {
"username": "string",
"body": "string"
},
"exampleRequestBody": {
"username": "butter_bridge",
"body": "This is a new comment!"
},
"exampleResponse": {
"comment_id": 14,
"votes": 0,
"created_at": "2024-07-16T00:00:00.000Z",
"author": "butter_bridge",
"body": "This is a new comment!",
"article_id": 1
}
}
},
"GET /api/comments/:comment_id": {
"description": "Retrieves a comment by its ID.",
"details": {
"queries": [],
"exampleResponse": {
"200": {
"comments": {
"comment_id": 1,
"body": "Oh, I've got compassion running out of my nose, pal! I'm the Sultan of Sentiment!",
"article_id": 9,
"author": "butter_bridge",
"votes": 16,
"created_at": "2020-04-06T12:17:00.000Z"
}
}
},
"errorResponses": {
"404": {
"description": "Comment not found for the given comment_id",
"exampleResponse": {
"msg": "404 - Not Found: Comment not found"
}
},
"400": {
"description": "Invalid comment_id syntax",
"exampleResponse": {
"msg": "400 - Bad Request: invalid_id"
}
}
}
}
},
"PATCH /api/comments/:comment_id": {
"description": "Updates the votes on a comment given the comment's comment_id. The request body should include `inc_votes` indicating how much to change the votes by.",
"details": {
"requestBody": {
"inc_votes": "number"
},
"exampleRequestBody": {
"inc_votes": 1
},
"exampleResponse": {
"comment": {
"comment_id": 1,
"votes": 101,
"created_at": "2020-03-28T00:10:20.000Z",
"author": "butter_bridge",
"body": "Oh, I've got compassion running out of my nose, pal! I'm the Sultan of Sentiment!",
"article_id": 9
}
},
"errorResponses": {
"404": {
"description": "Comment not found for the given comment_id",
"exampleResponse": {
"msg": "404 - Not Found: Comment not found"
}
},
"400": {
"description": "Bad Request. Invalid comment_id or inc_votes",
"exampleResponse": {
"msg": "400 - Bad Request: Invalid comment_id or inc_votes"
}
}
}
}
},
"DELETE /api/comments/:comment_id": {
"description": "Deletes the given comment by comment_id",
"details": {
"queries": [],
"exampleResponse": {
"204": {
"description": "The comment was successfully deleted. No content is returned."
},
"400": {
"description": "Bad Request. Invalid comment_id."
},
"404": {
"description": "Not Found. Comment not found."
}
},
"example": {
"request": {
"method": "DELETE",
"url": "/api/comments/1"
},
"response": {
"status": 204
}
}
}
},
"GET /api/users": {
"description": "Retrieves a list of all users from the database. Each user object contains the username, name, and avatar URL of the user.",
"details": {
"queries": [],
"exampleResponse": {
"users": [
{
"username": "bobbyG",
"name": "Bobby G",
"avatar_url": "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?q=80&w=1587&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
},
{
"username": "code-master",
"name": "Code Master",
"avatar_url": "https://images.unsplash.com/photo-1511376777868-611b54f68947?q=80&w=1740&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}
]
}
}
},
"GET /api/users/:username": {
"description": "Retrieves a user object by the given username",
"details": {
"queries": [],
"exampleResponse": {
"user": {
"username": "butter_bridge",
"avatar_url": "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?q=80&w=1587&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
"name": "jonny"
}
},
"errorResponses": {
"404": {
"description": "User not found for the given username",
"exampleResponse": {
"msg": "404 - Not Found: User not found"
}
}
}
}
}
}