Skip to content

Tanixq/blog-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

It is a Rest API for Blog website which has a login, register with OTP verification on mail, create a blog, comment on the blog, like on the blog, and Admin module for blog approval or rejection. It is made using express and mongodb.

API End Points

Admin Routes

User Routes

Blog Routes

Usage

Goto Section

Admin Routes

User Routes

Blog Routes

Admin Routes

For Admin Login

Make POST Request for Admin Login on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/login

Provide Following data in body

Fields Description TYPE Required
adminUsername Username of the admin. String Yes
adminPassword Password of the admin. String Yes

For Admin Logout

Make POST Request for logout on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/logout

Provide Admin Authorization Token in header.

For View Pending Blogs

Make GET Request for View Pending Blogs on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/view/pending-blogs

Provide Admin Authentication Token in Header.

Generate Token by Admin Login and Copy it.

For View Rejected Blogs

Make GET Request for View Rejected Blogs on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/view/rejected-blogs

Provide Admin Authentication Token in Header.

Generate Token by Admin Login and Copy it.

For View Approved Blogs

Make GET Request for View Approved Blogs on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/view/approved-blogs

Provide Admin Authentication Token in Header.

Generate Token by Admin Login and Copy it.

For Approve Blog

Make POST Request for Approve Blog on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/blog/approve

Provide Admin Authentication Token in Header. Generate Token by Admin Login and Copy it.

Provide blogId in body.

Example: -

{
    "blogId" : "5fe77e9c6ef2010017df962a"
}

For Reject Blog

Make POST Request for Reject Blog on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/blog/reject

Provide Admin Authentication Token in Header. Generate Token by Admin Login and Copy it.

Provide blogId in body.

Example: -

{
    "blogId" : "5fe77e9c6ef2010017df962a"
}

For View Blogs By User Admin Route

Make GET Request for View Blogs By User on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/view/blogs-by-user

Provide Admin Authentication Token in Header. Generate Token by Admin Login and Copy it.

Provide userId in body.

Example: -

{
    "userId" : "5fe77e9c6ef2010017df962a"
}

For View User Profile

Make GET Request for View User Profile on End Point - https://blog-api-tanixq.herokuapp.com/api/admin/view/user-profle

Provide Admin Authentication Token in Header. Generate Token by Admin Login and Copy it.

Provide userId in body.

Example: -

{
    "userId" : "5fe77e9c6ef2010017df962a"
}

User Routes

For Sign Up

Make POST Request for sign up on End Point - https://blog-api-tanixq.herokuapp.com/api/users/signup

Provide Following data in body

Fields Description TYPE Required
firstName First Name of the user String Yes
lastName Last Name of the user String Yes
email Email of the user. String Yes
password Password of the user. Must be of 8 characters. String Yes
bio bio of the user. Max 160 characters. String optional
profilePicture profile picture of user. file optional

For Login

Make POST Request for login on End Point - https://blog-api-tanixq.herokuapp.com/api/users/login

Provide Following data in body

Fields Description TYPE Required
email Email of the user. String Yes
password Password of the user. String Yes

Example :-

{
    "email": "test55@test.com",
    "password": "123456"
}

Description of Response data

Fields Description TYPE
id id of logged in the user. String
email Email of logged in the user. String
userIp ip Address of logged in user. String
token Authentication token of logged in user String

Example of API Response:

On Successful Login

{
    "statusCode": 7000,
    "message": "Login is successful",
    "data": {
        "user": {
            "id": "5fef460f026ca8254c5f998d",
            "email": "er.tanixq@gmail.com",
            "userIp": "::1"
        },
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVmZWY0NjBmMDI2Y2E4MjU0YzVmOTk4ZCIsImlhdCI6MTYwOTUxNzc2MCwiZXhwIjoxNjA5NTE5NTYwfQ.w0KURaS-XAJI6PLeS3UaVf_kWkardAuyFPKwMiNpn7k"
    }
}

For Logout

Make POST Request for logout on End Point - https://blog-api-tanixq.herokuapp.com/api/users/logout

Provide Authorization Token in header.

For Verify User Account

Make POST Request for Verify User Account on End Point - https://blog-api-tanixq.herokuapp.com/api/users/email/verify

Provide Following data in body

Fields Description TYPE Required
email Email of the user. String Yes
otp otp received in email String Yes

Example :-

{  
    "email": "er.tanixq@gmail.com",
    "otp": "187849"
}

Example of API Response:

On Successful Login

{
    "statusCode": 7000,
    "message": "Your account verificaiton is successful.",
    "data": ""
}

For Resend otp

Make POST Request for Resend otp on End Point - https://blog-api-tanixq.herokuapp.com/api/users/email/resend

Provide Following data in body

Fields Description TYPE Required
email Email of the user. String Yes

Example :-

{  
    "email": "er.tanixq@gmail.com",
}

For Edit User Bio

Make POST Request for Resend otp on End Point - https://blog-api-tanixq.herokuapp.com/api/users/profile/edit/bio

Provide Authentication token in header and Provide Following data in body

Fields Description TYPE Required
bio bio of the user. (max:160) String Yes

Example :-

{  
    "bio": "loremispusm etc etc ...",
}

For Password Reset

Make POST Request for Password Reset on End Point - https://blog-api-tanixq.herokuapp.com/api/users/password/reset

Provide Following data in body

Fields Description TYPE Required
email Email of the user. String Yes
otp otp generated from resend route. String Yes
newPassword new password of the user. String Yes

Example :-

{  
    "email": "er.tanixq@gmail.com",
    "otp": "122458",
    "newPassword": "12354567890",
}

For View User Profile

Make Get Request for View User Profile on End Point - https://blog-api-tanixq.herokuapp.com/api/users/profile

Provide Authentication Token in Header

Generate Token by Login and Copy it.

Blog Routes

For Creating Blog

Make POST Request for Creating Blog on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/create-new

Provide Authentication Token in Header

Generate Token by Login and Copy it.

Provide Following data in body

Fields Description TYPE Required
title Title of the blog. String required
content content of the blog. String required
thumbImage image for blog thumb. file required
category category for blog. String required
categories options: ['fashion', 'food', 'travel', 'music', 'lifestyle', 'fitness', 'diy', 'finance', 'technology', 'other'],

For Viewing User Blog

Make Get Request for View User Blogs on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/view/user-blogs

Provide Authentication Token in Header

Generate Token by Login and Copy it.

For Viewing Public Blog

Make Get Request for Public Blogs on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/view/

For View Blog by Category

Make GET Request for View by Category on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/view/category/:categoryName

replace categoryName with one of these ['fashion', 'food', 'travel', 'music', 'lifestyle', 'fitness', 'diy', 'finance', 'technology', 'other']

For View Blog by Title

Make GET Request for View by Category on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/view/:blogTitle

replace blogTitle with title of the blog.

For Delete Blog

Make DELETE request For Delete Blog End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/delete/by-id

Provide Authentication Token in Header. Generate Token by Admin Login and Copy it.

Provide blogId in body.

Example: -

{
    "blogId" : "5fe77e9c6ef2010017df962a"
}

For View Blogs By User

Make GET request For view Blogs by User End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/view/user/:userId

replace userId with userId of the user.

For Comment on Blog

Make POST Request for comment on blog on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/comment/new

Provide authentication token in header.

Provide Following data in body

Fields Description TYPE Required
blogId Id of the blog. String required
commentText comment Text. String required

Example: -

{
    "blogId" : "5fe77e9c6ef2010017df962a",
    "commentText" : "This is a comment"
}

For Reply on Comment on Blog

Make POST Request for Reply on Comment on Blog on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/comment/reply/new

Provide authentication token in header.

Provide Following data in body

Fields Description TYPE Required
blogId Id of the blog. String required
replyText Reply Text. String required

Example: -

{
    "blogId" : "5fe77e9c6ef2010017df962a",
    "replyText" : "This is a comment"
}

For Clap on Comment

Make POST Request for Clap on Comment on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/comment/clap

Provide authentication token in header.

Provide Following data in body

Fields Description TYPE Required
commentId Id of the comment. String required

Example: -

{
    "commentId" : "5fe77e9c6ef2010017df962a"
}

For Clap on Blog

Make POST Request for clap on blog on End Point - https://blog-api-tanixq.herokuapp.com/api/blogs/clap

Provide authentication token in header.

Provide Following data in body

Fields Description TYPE Required
blogId Id of the blog. String required

Example: -

{
    "blogId" : "5fe77e9c6ef2010017df962a"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published