-
Notifications
You must be signed in to change notification settings - Fork 1
API Documentation
Andrew K edited this page Dec 7, 2022
·
37 revisions
### Get current User
* Require Authentication:
* Request
* Method: GET
* URL:
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
```
### Log in a User
* Require Authentication:
* Request
* Method: POST
* URL:
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
```
### Sign in a User
* Require Authentication:
* Request
* Method: POST
* URL:
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
```
### Update user
* Require Authentication:
* Request
* Method: PUT
* URL:
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
```
### Delete user
* Require Authentication:
* Request
* Method: DELETE
* URL:
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
```
## STORY
### Get all stories
* Require Authentication:
* Request
* Method: GET
* URL: /api/stories / all
* Headers:
* Content - Type: application / json
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"Stories": [
{
"Story": {
"UserId": 1,
"Story": "Story Body Goes Here",
"Tag": "Education",
"Title": "Story Title goes here",
"Image": "url",
"createdAt": "mm/dd/yyyy",
},
"User": {
"userId": 1,
"firstName": "John",
"lastName": "Doe",
"profileImage": "url"
}
}
]
}
- Require Authentication:
- Request
- Method: GET
- URL: /api/stories /: username
- Headers:
- Content - Type: application / json
- Body:
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"Stories": [
{
"Story": {
"UserId": 1,
"Story": "Story Body Goes Here",
"Tag": "Education",
"Title": "Story Title goes here",
"Image": "url",
"createdAt": "mm/dd/yyyy",
},
"Responses": {
"totalResponses": 10
},
"Claps": {
"totalClaps": 10
}
}
]
}
- Require Authentication:
- Request
- Method: GET
- URL: /api/stories /: userId / following
- Headers:
- Content - Type: application / json
- Body:
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"Stories": [
{
"Story": {
"UserId": 1,
"Story": "Story Body Goes Here",
"Tag": "Education",
"Title": "Story Title goes here",
"Image": "url",
"createdAt": "mm/dd/yyyy",
},
"User": {
"userId": 1,
"firstName": "John",
"lastName": "Doe",
"profileImage": "url"
}
}
]
}
- Require Authentication:
- Request
- Method: GET
- URL: /api/stories /: tag
- Headers:
- Content - Type: application / json
- Body:
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"Stories": [
{
"Story": {
"UserId": 1,
"Story": "Story Body Goes Here",
"Tag": "Education",
"Title": "Story Title goes here",
"Image": "url",
"createdAt": "mm/dd/yyyy",
},
"User": {
"userId": 1,
"firstName": "John",
"lastName": "Doe",
"profileImage": "url"
}
}
]
}
- Require Authentication:
- Request
- Method: GET
- URL: /api/stories /: storyId
- Headers:
- Content - Type: application / json
- Body:
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"User": {
"firstName": "John",
"lastName" : "Doe",
"profileImg" : "url",
"followers" : 5
}
"Story": {
"UserId": 1,
"Story": "Story Body Goes Here",
"Tag": "Education",
"Title": "Story Title goes here",
"Image": "url",
"createdAt": "mm/dd/yyyy",
},
"Responses": {
"totalResponses": 10
},
"Claps": {
"totalClaps": 10
}
}
```
### Get top 6 stories by number of claps
* Require Authentication:
* Request
* Method: GET
* URL: /api/stories / trending
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"Stories": [
{
"Story": {
"UserId": 1,
"Story": "Story Body Goes Here",
"Tag": "Education",
"Title": "Story Title goes here",
"Image": "url",
"createdAt": "mm/dd/yyyy",
},
"User": {
"userId": 1,
"firstName": "John",
"lastName": "Doe",
"profileImage": "url"
}
}
]
}
```
### Create a new story
* Require Authentication:
* Request
* Method: POST
* URL: /api/stories / new
* Headers:
* Content - Type: application / json
* Body:
```json
{
"title": "title",
"story": "story",
"image" : "url",
"tag" : "tag"
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"id" : 1,
"userId": 1,
"title": "title",
"story": "story",
"image" : "url",
"createdAt" : "mm/dd/yyyy"
}
```
### Update story by story id
* Require Authentication:
* Request
* Method: PUT
* URL: /api/stories /: storyId
* Headers:
* Content - Type: application / json
* Body:
```json
{
"title": "title",
"story": "story",
"image" : "url",
"tag" : "tag"
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"id" : 1,
"userId": 1,
"title": "title",
"story": "story",
"image" : "url",
"createdAt" : "mm/dd/yyyy"
}
```
### Delete story
* Require Authentication:
* Request
* Method: DELETE
* URL: /api/stories /: storyId
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"message": "Successfully Deleted",
"statusCode" : 200
}
```
## RESPONSES
### Get all responses by story id
* Require Authentication:
* Request
* Method: GET
* URL: /api/responses /: storyId
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
Responses: [
{
"id": 1,
"body": "body",
"userId" : "userId",
"storyId" : "storyId",
"createdAt" : "mm/dd/yyyy",
"updatedAt" : "mm/dd/yyyy"
}
]
}
```
### Get all responses by user id
* Require Authentication:
* Request
* Method: GET
* URL: /api/responses /: userId
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
Responses: [
{
"id": 1,
"body": "body",
"userId" : "userId",
"storyId" : "storyId",
"createdAt" : "mm/dd/yyyy",
"updatedAt" : "mm/dd/yyyy"
}
]
}
```
### Create a response by story id
* Require Authentication:
* Request
* Method: POST
* URL: /api/responses /: storyId
* Headers:
* Content - Type: application / json
* Body:
```json
{
"body" : "body",
"userId" : "userId",
"storyId" : "storyId"
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"id": 1,
"body": "body",
"userId" : "userId",
"storyId" : "storyId",
"createdAt" : "mm/dd/yyyy",
"updatedAt" : "mm/dd/yyyy"
}
```
### Update a response by response id
* Require Authentication:
* Request
* Method: PUT
* URL: /api/responses /: responseId
* Headers:
* Content - Type: application / json
* Body:
```json
{
"body": "body",
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"id": 1,
"body": "body",
"userId" : "userId",
"storyId" : "storyId",
"createdAt" : "mm/dd/yyyy",
"updatedAt" : "mm/dd/yyyy"
}
```
### Delete response
* Require Authentication:
* Request
* Method: DELETE
* URL: /api/responses/:responseId
* Headers:
* Content - Type: application / json
* Body:
```json
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"messsage" : "Successfully deleted",
"statusCode" : 200
}
```
## Follows
### Add new follows by user id
* Require Authentication:
* Request
* Method: POST
* URL: /api/: userId / following
* Headers:
* Content - Type: application / json
* Body:
```json
{
"followedId" : 10
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"followerId" : 4,
"followedId" : 10
}
```
### Delete follows by user id
* Require Authentication:
* Request
* Method: DELETE
* URL: /api/: userId / following
* Body:
```json
{
"followedId" : 10
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"message" : "User unfollowed",
"statusCode": 200
}
```
## Claps
### Add claps by story id and user id
* Require Authentication:
* Request
* Method: POST
* URL: /api/claps /: storyId
* Body:
```json
{
"storyId" : 1,
"userId" : 2
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"id": 10,
"storyId" : 1,
"userId" : 2,
"createdAt" : "mm/dd/yyyy",
"updatedAt" : "mm/dd/yyyy"
}
```
### Add claps by response id and user id
* Require Authentication:
* Request
* Method: POST
* URL: /api/claps /: responseId
* Body:
```json
{
"userId" : 2,
"responseId" : 1
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"id": 10,
"responseId" : 1,
"userId" : 2,
"createdAt" : "mm/dd/yyyy",
"updatedAt" : "mm/dd/yyyy"
}
```
### Delete claps by story id and user id
* Require Authentication:
* Request
* Method: PUT
* URL: /api/claps /: storyId
* Body:
```json
{
"storyId" : 1,
"userId" : 2
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"message" : "Successfully unclapped",
"statusCode" : 200
}
```
### Delete claps by response id and user id
* Require Authentication:
* Request
* Method: PUT
* URL: /api/claps /: userId
* Body:
```json
{
"userId" : 2,
"responseId" : 1
}
```
* Successful Response
* Status Code:
* Headers:
* Content - Type: application / json
* Body:
```json
{
"message" : "Successfully unclapped",
"statusCode" : 200
}
```