Blog API

This is a minimal blog api with some advance features developed using NodeJS, ExpressJS and MongoDB. If you are looking for a free and robust RESTful API to interact with feel free to use this. It’s open source.

Developed by Reagan Ekhameye (Tech Reagan) reach me on twitter @techreagan

Authentication 8

Description

Add user to the database.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Body
{
    "firstName": "tech",
    "lastName": "reagan",
    "email": "reagan1@gmail.com",
    "password": "123456",
    "role": "guest"
}
Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Body
{
    "email": "reagan@gmail.com",
    "password": "1234567"
}
Description

Get current logged in user from the token.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Description

Update login user name and email

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "firstName": "Tech",
    "lastName": "Ray",
    "email": "reagan2@gmail.com"
}
Description

Update logged in user password, send in the body currentPassword and newPassword

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "currentPassword": "asdfgg",
    "newPassword": "123456"
}
Description

Reset password using the link sent to the user only if the token is stil valid. Token expires in ten(10) minutes.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Body
{
    "password": "1234567"
}
Description

Send email to user to reset password.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Body
{
    "email": "swreight0@mozilla.org"
}
Description

Clear token cookie

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Users 5

CRUD functionality for users only available to admins

Description

Get all users (admin) with pagination and also you can search, select and sort post, see instructions above.

Pagination

QueryDescription
?page=1The page number
?limit=10The number of items per page

Search, Select and Sort in Collections

QueryDescription
?title=helloSearch the collection where title equals hello (title and the value can be anything in the collection)
?select=title,userReturn the selected fields
?sort=-titleGet data in descending order using that field
?sort=titleGet data in ascending order using that field


Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "currentPassword": "asdfgg",
    "newPassword": "123456"
}
Description

Get single user by ID (admin)

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "currentPassword": "asdfgg",
    "newPassword": "123456"
}
Description

Add user to database (admin)

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "firstName": "Tech",
    "lastName": "Reagan",
    "email": "techreagan@gmail.com",
    "password": "123456"
}
Description

Update user in database (admin)

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "firstName": "Tech1",
    "lastName": "Reagan1",
    "email": "techreagan2020@gmail.com"
}
Description

Delete user from the database (admin)

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE

Posts 6

Description

Fetch all posts from the database with pagination also you can search, select and sort post.

Pagination

QueryDescription
?page=1The page number
?limit=10The number of items per page

Search, Select and Sort in Collections

QueryDescription
?title=helloSearch the collection where title equals hello (title and the value can be anything in the collection)
?select=title,userReturn the selected fields
?sort=-titleGet data in descending order using that field
?sort=titleGet data in ascending order using that field


Description

Add post to the database and return the created post.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "title": "Post one",
    "body": "hell world"
}
Description

Modify post in the database.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "title": "ddddddd",
    "body": "ddadfasdfsdf"
}
Description

Delete post from database using post ID.

Headers
KeyValueDescription
AuthorizationBearer TOKEN_HERE
Description

Upload image for a single post using ID.

Headers
KeyValueDescription
AuthorizationBearer TOKEN_HERE
Body
KeyValueDescription
file

Comments 3

Visitors can leave a comment on your post with their name and comment.

Description

Store comment for a particular post using post ID.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Body
{
    "name": "Comment thirteen",
    "body": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorem ut repudiandae numquam neque tempora officia pariatur enim laudantium! Cumque aliquam unde sunt corrupti quae amet cupiditate perspiciatis voluptatem ullam modi!. Lorem ipsum dolor sit amet consectetur adipisicing elit."
}
Description

Fetch all comments for a single post using post ID.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

Description

Delete comment in the database using comment ID only availabe to admin.

Headers
KeyValueDescription
Content-Typeapplication/json

JSON Type

AuthorizationBearer TOKEN_HERE
Body
{
    "name": "abc",
    "body": "very good post"
}