InstaClone Backend API Guide

Welcome! Use this page to test and understand the API routes. For every route marked Auth Required, send the header Authorization: Bearer <token>.

Auth Routes

POST/api/auth/register Public

Register a new user.

{
  "email": "user@example.com",
  "username": "newuser",
  "password": "strongPassword123"
}

POST/api/auth/login Public

Login using email or username with password.

{
  "email": "user@example.com",
  "password": "strongPassword123"
}

POST/api/auth/forget Public

Reset password (email and username must match an existing user).

{
  "email": "user@example.com",
  "username": "newuser",
  "password": "newPassword123"
}

User Routes

POST/api/user/pfp Auth Required

Upload a profile image. Use multipart/form-data with the field image-file.

DELETE/api/user/pfp Auth Required

Remove the profile image. No request body is required.

PATCH/api/user Auth Required

Update user details (partial body is allowed).

{
  "name": "New Name",
  "bio": "Hello world",
  "username": "updatedUsername"
}

Post Routes

GET/api/post Auth Required

Fetch all posts created by the authenticated user. No request body is required.

POST/api/post Auth Required

Create a new post using multipart/form-data:

DELETE/api/post/:postId Auth Required

Delete your own post using URL parameter postId. No request body is required.

Comment Routes

POST/comment/newComment Auth Required

Add a comment to a post.

{
  "postId": "",
  "text": "Nice post!"
}

GET/comment/:postId Auth Required

Fetch comments for a specific post.

DELETE/comment/:commentId Auth Required

Delete a comment. This controller reads data from body:

{
  "commentId": "",
  "postId": ""
}

Like Route

POST/api/like/post/:postId Auth Required

Toggle like/unlike for a post. No request body is required.