API Specification

Contributors: Alicia Wang, Conner Swenberg

Values wrapped in < > are placeholders for what the field values should be. Also be sure to read the request route carefully when you implement it - typos WILL cause test cases to fail!

The server should return an error response for:

  • POST requests, if the user does not supply one of the fields in the body (e.g. title, link, username, text, etc.) with a status code of 400 (bad request)

  • Any request if the id in the URL does not exist, with a status code of 404 (not found)

Error Response
{
   "error": "Your error message here"
}

For each of the following routes, we will specify a success response that you must implement, but make sure to also implement error responses accordingly!

Expected Functionality

Get all posts

GET/api/posts/

Success Response
<HTTP STATUS CODE 200>
{
  "posts": [
    {
      "id": 0,
      "upvotes": 1,
      "title": "My cat is the cutest!",
      "link": "https://i.imgur.com/jseZqNK.jpg",
      "username": "alicia98"
    },
    {
      "id": 1,
      "upvotes": 3,
      "title": "Cat loaf",
      "link": "https://i.imgur.com/TJ46wX4.jpg",
      "username": "alicia98"
    },
    ...
  ]
}

Create a post

POST/api/posts/

Get a specific post

GET/api/posts/{id}/

Delete a specific post

DELETE/api/posts/{id}/

Get comments for a specific post

GET/api/posts/{id}/comments/

Post a comment for a specific post

POST/api/posts/{id}/comments/

Note: comments should have globally unique IDs! That is, if a comment on one post has ID 5, no other comments, even on other posts should have an ID of 5!

Edit a comment for a specific post

POST/api/posts/{pid}/comments/{cid}/

Last updated

Was this helpful?