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
Add user to the database.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
{
"firstName": "tech",
"lastName": "reagan",
"email": "reagan1@gmail.com",
"password": "123456",
"role": "guest"
}| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
{
"email": "reagan@gmail.com",
"password": "1234567"
}Get current logged in user from the token.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
Update login user name and email
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"firstName": "Tech",
"lastName": "Ray",
"email": "reagan2@gmail.com"
}Update logged in user password, send in the body
currentPassword and newPassword
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"currentPassword": "asdfgg",
"newPassword": "123456"
}Reset password using the link sent to the user only if the token is stil valid. Token expires in ten(10) minutes.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
{
"password": "1234567"
}Send email to user to reset password.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
{
"email": "swreight0@mozilla.org"
}Clear token cookie
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
CRUD functionality for users only available to admins
Get all users (admin) with pagination and also you can search, select and sort post, see instructions above.
| Query | Description |
|---|---|
| ?page=1 | The page number |
| ?limit=10 | The number of items per page |
| Query | Description |
|---|---|
| ?title=hello | Search the collection where title equals hello (title and the value can be anything in the collection) |
| ?select=title,user | Return the selected fields |
| ?sort=-title | Get data in descending order using that field |
| ?sort=title | Get data in ascending order using that field |
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"currentPassword": "asdfgg",
"newPassword": "123456"
}Get single user by ID (admin)
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"currentPassword": "asdfgg",
"newPassword": "123456"
}Add user to database (admin)
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"firstName": "Tech",
"lastName": "Reagan",
"email": "techreagan@gmail.com",
"password": "123456"
}Update user in database (admin)
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"firstName": "Tech1",
"lastName": "Reagan1",
"email": "techreagan2020@gmail.com"
}Delete user from the database (admin)
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
Fetch all posts from the database with pagination also you can search, select and sort post.
| Query | Description |
|---|---|
| ?page=1 | The page number |
| ?limit=10 | The number of items per page |
| Query | Description |
|---|---|
| ?title=hello | Search the collection where title equals hello (title and the value can be anything in the collection) |
| ?select=title,user | Return the selected fields |
| ?sort=-title | Get data in descending order using that field |
| ?sort=title | Get data in ascending order using that field |
Add post to the database and return the created post.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"title": "Post one",
"body": "hell world"
}Modify post in the database.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"title": "ddddddd",
"body": "ddadfasdfsdf"
}Delete post from database using post ID.
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer TOKEN_HERE |
Upload image for a single post using ID.
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer TOKEN_HERE |
| Key | Value | Description |
|---|---|---|
| file |
Visitors can leave a comment on your post with their name and comment.
Store comment for a particular post using post ID.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
{
"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."
}Fetch all comments for a single post using post ID.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
Delete comment in the database using comment ID only availabe to admin.
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | JSON Type |
| Authorization | Bearer TOKEN_HERE |
{
"name": "abc",
"body": "very good post"
}