News Backend

Endpoints

GET /api

"description": "serves up a json representation of all the available endpoints of the api"

GET /api/topics

"description": "serves a json representation with the key of topics and the value of an array of topic objects.",

"queries": [],

"exampleResponse": {
        "topics": [
          {
            "slug": "football",
            "description": "Footie!"
          }
        ]
      }

GET /api/articles

"description": "serves a json representation with the key of articles and the value of an array of article objects. Accepts queries ( e.g /api/articles?sort_by=title&order=asc) : sort_by ( valid column, default 'created_at'), order ('asc' or 'desc', default 'desc')and topic (to filter articles by topic).",

"queries": [ "sort_by", "order", "topic" ],

"exampleResponse": {
        "articles": [
          {
            "title": "Seafood substitutions are increasing",
            "topic": "cooking",
            "author": "weegembump",
            "created_at": "2018-05-30T15:59:13.341Z",
            "votes": 0,
            "comment_count": 6
          }
        ]
      }

GET /api/articles/:article_id

"serves a json representation with the key of article and the value of an article object",

exampleResponse": {
        "article": {
          "article_id": 1,
          "title": "Running a Node App",
          "topic": "coding",
          "author": "jessjelly",
          "body": "This is part two of a series on how to get up and running with Systemd and Node.js. This part dives deeper into how to successfully run your app with systemd long-term, and how to set it up in a production environment.",
          "created_at": "2020-11-07T05:03:00.000Z",
          "votes": 0,
          "article_img_url": "https://images.pexels.com/photos/11035380/pexels-photo-11035380.jpeg?w=700&h=700"
        }
      }
    

GET /api/articles/:article_id/comments

"serves a json representation with the key of comments and the value of an array of comments with given id",

exampleResponse": {
          "article": {
            "article_id": 0,
            "title": "The Notorious Unlikely Formula For Success",
            "topic": "cooking",
            "author": "grumpy19",
            "body": "The 'umami' craze has turned a much-maligned and misunderstood food additive into an object of obsession for the world’s most innovative chefs. But secret ingredient monosodium glutamate’s biggest secret may be that there was never anything wrong with it at all.",
            "created_at": "2020-11-22T10:13:00.000Z",
            "votes": 0,
            "article_img_url": "https://images.pexels.com/photos/2403392/pexels-photo-2403392.jpeg?w=700&h=700"
          }
        }
  
    

POST /api/articles/:article_id/comments

"adds a comment with properties body and username",

exampleResponse": {
        "username": "John_Doe",
        "body": "This is an example of what John Doe might say"
      }
    

GET /api/users

"serves a json representation with the key of users and the value of an array of user objects.",

exampleResponse": {
        "users": [
          {
            "username": "butter_bridge",
            "name": "jonny",
            "avatar_url": "https://www.healthytherapies.com/wp-content/uploads/2016/06/Lime3.jpg"
          }
        ]
      }
    

PATCH /api/articles/:article_id

"Updates an article by article_id.",

exampleResponse": {
        "inc_votes": 12
      }
    

DELETE /api/comments/:comment_id

"Delete a comment by comment_id.,

exampleResponse": { }