Skip to content

API Documentation

David L edited this page Dec 19, 2022 · 37 revisions

USER

Get current User

  • Require Authentication: True

  • Request

    • Method: GET
    • URL:
    • Headers: *Content-Type: application/json
    • Body: None
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "id": 1,
    "firstName": "John",
    "lastName": "Smith",
    "profileImage": "profilepic.url",
    "bio": "about me"
}

Update user

  • Require Authentication: True

  • Request

    • Method: PUT
    • URL:
    • Headers: *Content-Type: application/json
    • Body: None
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "id": 1,
    "firstName": "John",
    "lastName": "Smith",
    "profileImage": "profilepic.url",
    "bio": "about me"
}

Delete user

  • Require Authentication: True

  • Request

    • Method: DELETE
    • URL:
    • Headers: *Content-Type: application/json
    • Body: None
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
     "message" : "Successfully Deleted",
     "statusCode" : 200
}

STORY

Get all stories

  • Require Authentication: False

  • Request

    • Method: GET
    • URL: /api/stories
    • Headers:
      • Content - Type: application/json
  • Successful Response

    • Status Code:
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "Stories": [
        {
            "Story": {
                "UserId": 1,
                "Story": "Story Body Goes Here",
                "Tag": "Education",
                "Title": "Story Title goes here",
                "Image": "url",
                "createdAt": "mm/dd/yyyy",
                "updatedAt": "mm/dd/yyyy"
            },
             "User": {
                "id": 1,
                "firstName": "John",
                "lastName": "Doe"
             }
        }
    ]
}

Get all stories by current user

  • Require Authentication: True

  • Request

    • Method: GET
      • URL: /api/stories/:userId
    • Headers: *Content-Type: application/json
  • Body: None

  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "User": {
                "id": 1,
                "firstName": "John",
                "lastName": "Doe",
                "stories": [{
                     "id": 2
                     "story": "Story Body Goes Here",
                     "tag": "Education",
                     "title": "Story Title goes here",
                     "image": "url",
                     "createdAt": "mm/dd/yyyy",
                     "updatedAt": "mm/dd/yyyy"
                    }]
             }
}

Get all stories by authors the user is following

  • Require Authentication: True

  • Request

    • Method: GET
    • URL: /api/stories/:userId/following
    • Headers:
      • Content-Type: application/json
  • Body: None

  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "Stories": [
        {
            "Story": {
                "UserId": 2,
                "Story": "Story Body Goes Here",
                "Tag": "Education",
                "Title": "Story Title goes here",
                "Image": "url",
                "createdAt": "mm/dd/yyyy",
                "updatedAt": "mm/dd/yyyy"
            },
             "User": {
                "id": 1,
                "firstName": "John",
                "lastName": "Doe"
             }
        }
    ]
}

Get all stories by tag

  • Require Authentication: False

  • Request

    • Method: GET
    • URL: /api/stories/:tag
    • Headers:
      • Content-Type: application/json
  • Body: None

  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "Stories": [
        {
            "Story": {
                "UserId": 1,
                "Story": "Story Body Goes Here",
                "Tag": "Education",
                "Title": "Story Title goes here",
                "Image": "url",
                "createdAt": "mm/dd/yyyy",
                "updatedAt": "mm/dd/yyyy"
            },
             "User": {
                "id": 1,
                "firstName": "John",
                "lastName": "Doe"
             }
        }
    ]
}

Get story by id

  • Require Authentication: False

  • Request

    • Method: GET
    • URL: /api/stories/:storyId
    • Headers:
      • Content-Type: application/json
  • Body: None

  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
        {
            "Story": {
                "UserId": 1,
                "Story": "Story Body Goes Here",
                "Tag": "Education",
                "Title": "Story Title goes here",
                "Image": "url",
                "createdAt": "mm/dd/yyyy",
                "updatedAt": "mm/dd/yyyy"
            },

            "Responses": {
                "totalResponses": 10
            },

            "Claps": {
                "totalClaps": 10
            },
             "User": {
                "id": 1,
                "firstName": "John",
                "lastName": "Doe"
             }
        }

Create a new story

  • Require Authentication: True
  • Request
    • Method: POST
    • URL: /api/stories/new
    • Headers:
      • Content-Type: application/json
    • Body:
    {
        "title": "title",
        "story": "story",
        "image" : "url",
        "tag" : "tag"
    }
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
     {
        "id" : 1,
        "userId": 1,
        "title": "title",
        "story": "story",
        "image" : "url",
        "createdAt" : "mm/dd/yyyy"
        "updatedAt": "mm/dd/yyyy"
     }

Update story by story id

  • Require Authentication: True
  • Request
    • Method: PUT
    • URL: /api/stories/:storyId
    • Headers:
      • Content-Type: application/json
    • Body:
{
        "title": "title",
        "story": "story",
        "image" : "url",
        "tag" : "tag"
    }
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
    {
        "id" : 1,
        "userId": 1,
        "title": "title",
        "story": "story",
        "image" : "url",
        "createdAt" : "mm/dd/yyyy"
        "updatedAt": "mm/dd/yyyy"
     }

Delete story

  • Require Authentication: True

  • Request

    • Method: DELETE
    • URL: /api/stories/:storyId
    • Headers:
      • Content-Type: application/json
    • Body: None
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "message": "Successfully Deleted",
    "statusCode" : 200
}

RESPONSES

Create a response by story id

  • Require Authentication: True
  • Request
    • Method: POST
    • URL: /api/responses/:storyId
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "body" : "body"
}
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
 {
            "id": 1,
            "body": "body",
            "userId" : "userId",
            "storyId" : "storyId",
            "createdAt" : "mm/dd/yyyy",
            "updatedAt" : "mm/dd/yyyy"
        }

Update a response by response id

  • Require Authentication: True
  • Request
    • Method: PUT
    • URL: /api/responses/:responseId
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "body": "body",
}
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
 {
            "id": 1,
            "body": "body",
            "userId" : "userId",
            "storyId" : "storyId",
            "createdAt" : "mm/dd/yyyy",
            "updatedAt" : "mm/dd/yyyy"
        }

Delete response

  • Require Authentication: 200

  • Request

    • Method: DELETE
    • URL: /api/responses/:responseId
    • Headers:
      • Content-Type: application/json
    • Body: None
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "messsage" : "Successfully deleted",
    "statusCode" : 200
}

Follows

Add new follows by user id

  • Require Authentication: True
  • Request
    • Method: POST
    • URL: /api/:userId/following
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "followedId" : 10
}
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
   "message": "Successfully followed",
   "statusCode": 200
}

Delete follows by user id

  • Require Authentication: True
  • Request
    • Method: DELETE
    • URL: /api/:userId/following
    • Body:
{
    "followedId" : 10
}
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "message" : "User unfollowed",
    "statusCode": 200
}

Claps

Add claps by story id and user id

  • Require Authentication: True

  • Request

    • Method: POST
    • URL: /api/:storyId/claps
    • Body: none
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "message" : "Successful Clap",
    "statusCode" : 200
}

Add claps by response id and user id

  • Require Authentication: True
  • Request
    • Method: POST
    • URL: /api/claps/:responseId
    • Body:
{
    "userId" : 2,
    "responseId" : 1
}
  • Successful Response
    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
{
    "id": 10,
    "responseId" : 1,
    "userId" : 2,
    "createdAt" : "mm/dd/yyyy",
    "updatedAt" : "mm/dd/yyyy"
}