API Documentation

All data is sent and received as JSON.
Content-Type: application/json

Access API at:
https://pbsapi.now.sh/api/


Index of contents

User account | Private Bookmarks | Public Quotes | Public Blogging | Comments | Points


User account

Create User

The user name can only contain lower case letters, numbers and underline. [a-z0-9_]

REQUEST
POST /api/users

REQUEST BODY

{
  "user": {
    "login": "user_login_here",
    "password": "user_password_here"
  }
}

RESPONSE BODY

{
  "status": "success",
  "message": "User successfully registered. You can now log in (create sessions)."
}

Create Session

REQUEST
POST /api/session

REQUEST BODY

{
  "user": {
    "login": "user_login_here",
    "password": "user_password_here"
  }
}

RESPONSE BODY

{
  "status": "success",
  "message": "A user session was successfully created. Valid 800 hours.",
  "data": {
    "User-Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlYjZjOGJiZmE0ODJjODFhNDYwZmI5YSIsImxvZ2luIjoiY2F0IiwiaWF0IjoxNTg5MDM3NTAyLCJleHAiOjE1OTE5MTc1MDJ9.aB5jMQhRgkoct1y2pSrvMYRTa3C29sWrBifxNTkSYFA",
    "Login": "cat"
  }
}

Auth (User session)

Set Header X-Access-Token with your session token.
Examples:

Create new Quote

curl -X POST \
-H 'Content-Type: application/json' \
-H 'X-Access-Token: <here_user_token>' \
-d '{"quote": "Rome was not built in one day.", "author": "John Heywood"}' \
--url https://pbsapi.now.sh/api/quotes

Delete Quote

curl -X DELETE \
-H "X-Access-Token: <here_user_token>" \
https://pbsapi.now.sh/api/quote/5eb4716898a9ccc10638abca

Get User

REQUEST
GET /api/users/:login

RESPONSE BODY

{
  "status": "success",
  "message": "A user profile was found.",
  "data": {
    "login": "cat",
    "points": 100,
    "role": 1
  }
}

Update User

Note: User session required

REQUEST
PATCH /api/users

REQUEST BODY All fields are optional. Field yourPassword is always required.

{
  "user": {
    "yourPassword": "user_old_password",
    "newPassword": "user_new_password"
  }
}

RESPONSE BODY

{
  "status": "success",
  "message": "The user profile has been successfully updated.",
  "data": {
    "avatar": "/default.png",
    "banned": 0,
    "points": 100,
    "role": 1,
    "lastActivity": 1589038213050,
    "_id": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "password": "$2b$10$/Cn0bfUSvx6GuPV/b8zI5erDChbYPa9wuqAzgr2RmAQZbNAiUah1O",
    "createdOn": "2020-05-09T15:14:03.328Z",
    "__v": 0
  }
}

My Profile

Note: User session required

REQUEST
GET /api/user/me

RESPONSE BODY

{
  "status": "success",
  "message": "This is your profile.",
  "data": {
    "avatar": "/default.png",
    "banned": 0,
    "points": 100,
    "role": 1,
    "lastActivity": 1589038223213,
    "_id": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "password": "$2b$10$/Cn0bfUSvx6GuPV/b8zI5erDChbYPa9wuqAzgr2RmAQZbNAiUah1O",
    "createdOn": "2020-05-09T15:14:03.328Z",
    "__v": 0
  }
}


Private Bookmarks Storage

Create Bookmark

Note: User session required

REQUEST
POST /api/bookmarks

REQUEST BODY

{
  "bookmark": "https://blog.example.com/my-favorites-capcakes"
}

RESPONSE BODY

{
  "status": "success",
  "message": "You have added new bookmark.",
  "bookmark": {
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb6d4ffc8a3c3b3d188a9fc",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "bookmark": "https://blog.example.com/my-favorites-capcakes",
    "createdOn": "2020-05-09T16:06:23.982Z",
    "__v": 0
  }
}

Get Bookmarks

Note: User session required

REQUEST
GET /api/bookmarks

RESPONSE BODY

{
  "status": "success",
  "bookmarks": [
    {
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb6d4ffc8a3c3b3d188a9fc",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "bookmark": "https://blog.example.com/my-favorites-capcakes",
      "createdOn": "2020-05-09T16:06:23.982Z",
      "__v": 0
    },
    {
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb6d538c8a3c3b3d188a9fd",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "bookmark": "https://blog.example.com/my-favorites-fruits",
      "createdOn": "2020-05-09T16:07:20.741Z",
      "__v": 0
    }
  ]
}

Update Bookmark

Note: User session required

REQUEST
PATCH /api/bookmark/:id

REQUEST BODY

{
  "bookmark": "https://blog.example.com/my-favorites-veggies"
}

RESPONSE BODY

{
  "status": "success",
  "message": "Bookmark was updated successfully.",
  "data": {
    "updatedOn": "2020-05-09T16:12:02.611Z",
    "_id": "5eb6d538c8a3c3b3d188a9fd",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "bookmark": "https://blog.example.com/my-favorites-veggies",
    "createdOn": "2020-05-09T16:07:20.741Z",
    "__v": 0
  }
}

Delete Bookmark

Note: User session required

REQUEST
DELETE /api/bookmark/:id

RESPONSE BODY

{
  "status": "success",
  "message": "Bookmark has been removed."
}


Public Quotes Storage

Create Quote

Note: User session required

REQUEST
POST /api/quotes

REQUEST BODY

{
  "quote": "Life is not about how fast you run or how high you climb but how well you bounce.",
  "author": "Vivian KomORI"
}

RESPONSE BODY

{
  "status": "success",
  "message": "You have added a new quote.",
  "data": {
    "likes": 0,
    "dislikes": 0,
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb6f061149870084e77d6e9",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "quote": "Life is not about how fast you run or how high you climb but how well you bounce.",
    "author": "Vivian KomORI",
    "createdOn": "2020-05-09T18:03:13.054Z",
    "__v": 0
  }
}

Update Quote

Note: User session required

REQUEST
PATCH /api/quote/:id

REQUEST BODY

{
  "quote": "Life is not about how fast you run or how high you climb but how well you bounce.",
  "author": "Vivian Komorii"
}

RESPONSE BODY

{
  "status": "success",
  "message": "Your Quote was updated!",
  "quote": {
    "likes": 0,
    "dislikes": 0,
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb48fcdb4c66bdbcf87fe09",
    "createdBy": "5eb446eb43e2a517980fe850",
    "quote": "Trip owner up in kitchen i want food cat slap dog in face so throwup on your pillow...",
    "createdOn": "2020-05-07T22:46:37.832Z",
    "__v": 0
  }
}

Delete Quote

Note: User session required

REQUEST
DELETE /api/quote/:id

RESPONSE BODY

{
  "status": "success",
  "message": "The quote has been successfully deleted."
}

Get User Quotes

REQUEST
GET /api/quotes/user/:login

RESPONSE BODY

{
  "status": "success",
  "message": "These are all the quotes sent by user.",
  "data": [
    {
      "likes": 0,
      "dislikes": 0,
      "updatedOn": "2020-05-09T18:05:52.094Z",
      "_id": "5eb6f061149870084e77d6e9",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "quote": "Life is not about how fast you run or how high you climb but how well you bounce.",
      "author": "Vivian Komorii",
      "createdOn": "2020-05-09T18:03:13.054Z",
      "__v": 0
    },
    {
      "likes": 0,
      "dislikes": 0,
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb6f3ef003da51d194a4207",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "quote": "To effectively communicate, we must realize that we are all different in the way we perceive the world and use this understanding as a guide to our communication with others.",
      "author": "Tony Robbins",
      "createdOn": "2020-05-09T18:18:23.450Z",
      "__v": 0
    },
    {
      "likes": 0,
      "dislikes": 0,
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb6f4bb003da51d194a4208",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "quote": "Rome was not built in one day.",
      "author": "John Heywood",
      "createdOn": "2020-05-09T18:21:47.283Z",
      "__v": 0
    }
  ]
}

Get Quote by ID

REQUEST
GET /api/quote/:id

RESPONSE BODY

{
  "status": "success",
  "message": "The requested quote was found.",
  "data": {
    "likes": 0,
    "dislikes": 0,
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb6f4bb003da51d194a4208",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "quote": "Rome was not built in one day.",
    "author": "John Heywood",
    "createdOn": "2020-05-09T18:21:47.283Z",
    "__v": 0
  }
}

Get latest Quotes

REQUEST
GET /api/quotes/latest/:limit

RESPONSE BODY

{
  "status": "success",
  "message": "The last quote sent by users.",
  "data": [
    {
      "likes": 0,
      "dislikes": 0,
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb6f4bb003da51d194a4208",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "quote": "Rome was not built in one day.",
      "author": "John Heywood",
      "createdOn": "2020-05-09T18:21:47.283Z",
      "__v": 0
    },
    {
      "likes": 0,
      "dislikes": 0,
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb6f3ef003da51d194a4207",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "quote": "To effectively communicate, we must realize that we are all different in the way we perceive the world and use this understanding as a guide to our communication with others.",
      "author": "Tony Robbins",
      "createdOn": "2020-05-09T18:18:23.450Z",
      "__v": 0
    }
  ]
}

Like/Dislike a Quote

Note: User session required

like - parameter like or dislike

REQUEST
POST /api/quote/vote/:like/:id

RESPONSE BODY

{
  "status": "success",
  "message": "You voted for this quote successfully. ",
  "data": {
    "likes": 2,
    "dislikes": 0,
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb6f4bb003da51d194a4208",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "quote": "Rome was not built in one day.",
    "author": "John Heywood",
    "createdOn": "2020-05-09T18:21:47.283Z",
    "__v": 0
  }
}


Public Blogging Service

Create article

Note: User session required

HTML

<b>  <br>  <p>  <strong>  <em>  <code>
<a href="httpx://example.com">link description</a>

Markdown

**bold**  _italic_  [link description](https://example.com)  `code`
```
multi
line
code
```

REQUEST
POST /api/blog

REQUEST BODY

{
  "title": "Sweet Cat ipsum!!111one",
  "article": "Roll over and sun my belly licks your face love blinks and purr purr purr purr yawn love you, then bite you hiss and stare at nothing then run suddenly away cats secretly make all the worlds muffins cough hairball on conveniently placed pants. "
}

RESPONSE BODY

{
  "status": "success",
  "message": "You have added new article.",
  "data": {
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb71e8949b1072a9ef6d34e",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "title": "Sweet Cat ipsum!!111one",
    "article": "Roll over and sun my belly licks your face love blinks and purr purr purr purr yawn love you, then bite you hiss and stare at nothing then run suddenly away cats secretly make all the worlds muffins cough hairball on conveniently placed pants. ",
    "createdOn": "2020-05-09T21:20:09.047Z",
    "__v": 0
  }
}

Get latest articles

REQUEST
GET /api/blog

RESPONSE BODY

{
  "status": "success",
  "message": "100 recently added articles.",
  "data": [
    {
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb71e8949b1072a9ef6d34e",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "title": "Sweet Cat ipsum!!111one",
      "article": "Roll over and sun my belly licks your face love blinks and purr purr purr purr... ",
      "createdOn": "2020-05-09T21:20:09.047Z",
      "__v": 0
    },
    {
      "updatedOn": "2020-05-09T20:48:27.029Z",
      "_id": "5eb716ba4ea57a61f1164416",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "title": "My cat is as cupcake!!!111one",
      "article": "Your pillow is now my pet bed eat the rubberband but making bread on the bathrobe...",
      "createdOn": "2020-05-09T20:46:50.940Z",
      "__v": 0
    }
  ]
}

Get article via ID

REQUEST GET /api/blog/:id

RESPONSE BODY

{
  "status": "success",
  "message": "Article data",
  "data": {
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb71e8949b1072a9ef6d34e",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "title": "Sweet Cat ipsum!!111one",
    "article": "Roll over and sun my belly licks your face love blinks and purr purr purr purr yawn love you, then bite you hiss and stare at nothing then run suddenly away cats secretly make all the worlds muffins cough hairball on conveniently placed pants. ",
    "createdOn": "2020-05-09T21:20:09.047Z",
    "__v": 0
  }
}

Get user articles

REQUEST
GET /api/blog/user/:login

RESPONSE BODY

{
  "status": "success",
  "message": "All user articles",
  "data": [
    {
      "updatedOn": "2020-05-09T20:48:27.029Z",
      "_id": "5eb716ba4ea57a61f1164416",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "title": "My cat is as cupcake!!!111one",
      "article": "Your pillow is now my pet bed eat the rubberband but making bread on the bathrobe...",
      "createdOn": "2020-05-09T20:46:50.940Z",
      "__v": 0
    },
    {
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb721d349b1072a9ef6d34f",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "title": "I love my owner!",
      "article": "I love cuddles i could pee on this if i had the energy going to catch the red dot today going to catch the red....",
      "createdOn": "2020-05-09T21:34:11.019Z",
      "__v": 0
    }
  ]
}

Update article

Note: User session required

REQUEST
PATCH /api/blog/:id

REQUEST BODY

{
  "title": "My cat is NOT as cupcake!!!111one",
  "article": "EDIT: My CAT IS A BOT! Your pillow is now my pet bed eat the rubberband but making bread on the bathrobe..."
}

RESPONSE BODY

{
  "status": "success",
  "message": "Your Article was updated!",
  "data": {
    "updatedOn": "2020-05-09T21:40:52.377Z",
    "_id": "5eb716ba4ea57a61f1164416",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "title": "My cat is NOT as cupcake!!!111one",
    "article": "EDIT: My CAT IS A BOT! Your pillow is now my pet bed eat the rubberband but making bread on the bathrobe...",
    "createdOn": "2020-05-09T20:46:50.940Z",
    "__v": 0
  }
}

Delete article

Note: User session required

REQUEST
DELETE /api/blog/:id

RESPONSE BODY

{
  "status": "success",
  "message": "Your Article was deleted!"
}


Comments for the articles

Create comment for article ID

Note: User session required

REQUEST
POST /api/comments/:id

:id - Article ID

REQUEST BODY

{
  "comment": "I love cuddles i could pee on this if i had the energy going to catch the red dot today going to catch the red dot today.'",
  "parent_id": ""
}

RESPONSE BODY

{
  "status": "success",
  "message": "You have added new comment.",
  "data": {
    "parent_id": null,
    "updatedOn": "1970-01-01T00:00:00.000Z",
    "_id": "5eb849620eb1668f2f2b48a3",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "comment": "I love cuddles i could pee on this if i had the energy going to catch the red dot today going to catch the red dot today.'",
    "article_id": "5eb7c24461cb5c42f38e62e7",
    "createdOn": "2020-05-10T18:35:14.082Z",
    "__v": 0
  }
}

Update comment

Note: User session required

REQUEST
PATCH /api/comments/:id

:id - Comment ID

REQUEST BODY

{
  "comment": "I VERY love cuddles i could pee on this if i had the energy going to catch the red dot today going to catch the red dot today.'"
}

RESPONSE BODY

{
  "status": "success",
  "message": "Your comment was updated!",
  "data": {
    "parent_id": null,
    "updatedOn": "2020-05-10T19:24:05.291Z",
    "_id": "5eb849620eb1668f2f2b48a3",
    "createdBy": "5eb6c8bbfa482c81a460fb9a",
    "login": "cat",
    "comment": "I VERY love cuddles i could pee on this if i had the energy going to catch the red dot today going to catch the red dot today.'",
    "article_id": "5eb7c24461cb5c42f38e62e7",
    "createdOn": "2020-05-10T18:35:14.082Z",
    "__v": 0
  }
}

Delete comment

Note: User session required

REQUEST
DELETE /api/comments/:id

:id - Comment ID

RESPONSE BODY

{
  "status": "success",
  "message": "Your comment was deleted!"
}

Get article comments

REQUEST
GET /api/comments/:id

:id - Article ID

RESPONSE BODY

{
  "status": "success",
  "message": "All comments for the article.",
  "data": [
    {
      "parent_id": null,
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb83b42ca3747489375e4ee",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "comment": "Love shove bum in owner's face like camera lens freak human out make funny noise mow mow mow mow mow mow success now attack human yet leave dead animals as gifts.'",
      "article_id": "5eb7c24461cb5c42f38e62e7",
      "createdOn": "2020-05-10T17:34:58.308Z",
      "__v": 0
    },
    {
      "parent_id": null,
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb83b4eca3747489375e4ef",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "comment": "Why? Why? Why?'",
      "article_id": "5eb7c24461cb5c42f38e62e7",
      "createdOn": "2020-05-10T17:35:10.244Z",
      "__v": 0
    },
    {
      "parent_id": "5eb83b4eca3747489375e4ef",
      "updatedOn": "1970-01-01T00:00:00.000Z",
      "_id": "5eb83b62ca3747489375e4f0",
      "createdBy": "5eb6c8bbfa482c81a460fb9a",
      "login": "cat",
      "comment": "What, why?'",
      "article_id": "5eb7c24461cb5c42f38e62e7",
      "createdOn": "2020-05-10T17:35:30.412Z",
      "__v": 0
    }
  ]
}

Get user comments

REQUEST
GET /api/comments/user/:login


Get comment per ID

REQUEST
GET /api/comments/:id


Get latest comments

REQUEST
GET /api/comments



User Points

Write new articel: +3 points
Add new quote: +2 points

Delete yourself article: -3 points
Delete yourself quote: -2 points

Administrator delete your articel: -5 points
Administrator delete your quote: -4 points



Build by @aptitude

current: ver0.1.2 - updated at 2020/05/10

ver0.1.0 - updated at 2020/05/09
ver0.0.2 - updated at 2020/05/08
ver0.0.1 - created at 2020/05/07