Digital Madrasah API Documentation

Base URL: https://digitalmadrasah.onrender.com

1. User Authentication API

POST /api/user/register

Register a new user

Request Body:

{
  "fullName": "string",
  "email": "string",
  "password": "string",
  "gender": "string",
  "phoneNumber": "string",
  "referralCode": "string",
  "guardianEmail": "string"
  "countryCode": "string"
}
        

POST /api/user/register-email

Register a new user with email

Request Body:

        {verificationCode: "string",
         userId:"string"}
        

POST /api/user/login

Log in a user

Request Body:

{
  "email": "string",
  "password": "string"
}
        

POST /api/user/login-email

Log in a user with email

Request Body:

{
  "email": "string"
}
        

POST /api/user/verify-code

Verify OTP code

Request Body:

{
  "verificationCode": "string",
  "email": "string"
}
        

POST /api/user/forgotten-password

Forgotten password

Request Body:

{

  "email": "string"
}
        

PUT /api/user/reset-password

Reset user password

Request Body:

{
  "userId": "string",
  "newPassword": "string"
}
        

PUT /api/user/:userId/update

Update an existing user

Request Body:

{
  "fullName": "string",
  "gender": "string",
  "phoneNumber": "string",
  "guardianEmail": "string"
  "countryCode": "string"
}
        

PUT /api/user/:userId/password

Update user password

Request params:

{
  "userId": "string"
}
        

Request body:

    {
      "currentPassword": "string",
      "newPassword": "string"
    }
            

Delete /api/user/:userId

Delete a user account

Request params:

{
  "userId": "string"
}
        
Note : Private (Admin or account owner)

PUT /api/user/:userId/email

Update user email (with verification)

Request params:

{
  "userId": "string"
}
        

GET /api/user/getusers

Get All users

GET /api/user/getuser/:userId

Get a user by Id

Request Param:

{
  "userId": "string",
}
        

GET /api/user/getInstructors

Get All Instructors

GET /api/user/courses/:userId/:coursetype

Get user courses

Path Parameters:

PUT /api/user/:userId/course/:courseId/markAsDone

Mark a course as done

Path Parameters:

PUT /api/user/:userId/course/:courseId/updateCourseProgress

Update course Progress

Path Parameters:

Request Body:

{
  "progress": "Number",
  "currenLessonId": "string"
}
        

POST /api/user/upload-profile/:userId

Upload or update user profile picture

Path Parameters:

Request Files:

2. Course Management API

POST /api/courses/add-courses/:instructorId

Add a new course

Path Parameters:

Request Body:

{
  "title": "string",
  "shortdescription": "string",
  "description": "string",
  "category": "string",
  "price": "number",
  "duration": "string"
}
        

Request Files:

POST /api/courses/purchase-course/:courseId/:userId

Purchase a course

Path Parameters:

DELETE /api/courses/delete-courses/:instructorId

Delete a course

Path Parameters:

PATCH /api/courses/update-course/:courseId

Update a course

Path Parameters:

Request Body:

{
  // Updated course fields
}
        

GET /api/courses/get-All-Courses

Get all courses

GET /api/courses/get-Course/:courseId?userId=:userId

Get a specific course

Path Parameters:

Query Parameters:

Note: The userId query parameter is optional and allows you to retrieve the course for a specific user and get isEnrolled status to determine if current user has already purchase-course

GET /api/courses/search

Search and filter courses

Query Parameters:

Example Request:

/api/courses/search
Search by title /api/courses/search?title=python
Filter by category /api/courses/search?category=Programming
Price range /api/courses/search?minPrice=0&maxPrice=100
Instructor courses /api/courses/search?instructor=instructorObjectId // Minimum ratings /api/courses/search?minRatings=4 // Combined filters /api/courses/search?title=python&category=Programming&minPrice=0&maxPrice=100&minRatings=4

PATCH /api/courses/verify-course/:courseId

Verify a course

Path Parameters:

3. Lesson Management API

POST /api/lessons/add-lesson/:courseId

Add a new lesson to a course

Path Parameters:

Request Body:

{
  "title": "string",
  "shortdescription": "string",
  "description": "string",
  "duration": "string"
}
        

Request Files:

DELETE /api/lessons/delete-lesson/:lessonId

Delete a lesson

Path Parameters:

PATCH /api/lessons/update-lesson/:lessonId

Update a lesson

Path Parameters:

Request Body:

{
  // Updated lesson fields
}
        

GET /api/lessons/get-lesson/:lessonId

Get a specific lesson

Path Parameters:

4. Rating API

POST /api/user/rating

Create a new rating for a course

Request Body:

{
  "userId": "string",
  "courseId": "string",
  "rating": "number",
  "comment": "string"
}
        

GET /api/user/rating/:courseId

Get ratings for a specific course

Path Parameters:

5. Wishlist API

POST /api/user/wishlist

Add a course to wishlist

Request Body:

{
  
  • userId: string
  • courseId: string
  • }

    GET /api/user/wishlist/:userId

    Get user's wishlist

    Path Parameters:

    DELETE /api/user/wishlist/:userId/:courseId

    Remove a course from wishlist

    Path Parameters:

    6. Payment API

    POST /api/payment/pay

    creat payment after payments has been made to the insructor

    Request Body

          { "instructor": "string", 
            "course": "string", 
            "amountPaid": "Number",  
            "balance": "Number",  
            "status": "string"
           } 
        
    Note : status is a enum and only accepts : ['pending', 'cancelled', 'complete']

    GET /api/payment/:instructorId/payments

    Get all payments made to instructor

    Request Params

    GET /api/payment/allpayments

    Get all payments

    Request Params

    Note: Only pass the instructorId if you need payments for a specific instructor

    GET /api/payment/payments/:id

    Get a specific payment

    Path Parameters:

    DELETE /api/payment/payments/:id

    Delete a payment

    Path Parameters:

    7. Referral Code API

    POST /api/refferal/referral-codes

    Create a new referral code

    Request Body:

    {
      codeDiscount: number,
      code: string
    }
            

    GET /api/refferal/referral-codes

    Get all referral codes

    GET /api/refferal/referral-codes/:id

    Get a specific referral code

    Path Parameters:

    PUT /api/refferal/referral-codes/:id

    Update a referral code

    Path Parameters:

    Request Body:

    {
      codeDiscount: number,
      code: string
    }
            

    DELETE /api/refferal/referral-codes/:id

    Delete a referral code

    Path Parameters:

    GET /api/refferal/referral-codes/code/:code

    Get a referral code by code

    Path Parameters:

    8. Email Service API

    POST /api/user/broadcast-emails

    Broadcast message to registered users via email

    Request Body:

    {
      subject: string,
      message: string,
      broadcastType : enum:['general',instructors, admin] //set to general by default
    }
            

    9. Course Category API

    GET /api/category/all-categories

    Get all categories

    POST /api/category/create-category

    Create a new category

    Request Body:

    {
      name: string,
      description: string
    }
            

    Request Files:

    PUT /api/category/categories/update/:id

    Update a category

    Path Parameters:

    Request Body:

    {
      name: string,
      description: string
    }
            

    Request Files:

    DELETE /api/category/categories/delete/:id

    Delete a category

    Path Parameters:

    10. Course Completion Certification API

    GET /api/certificate/all-certifications/:userId

    Get all user certificates from all courses

    Path Parameters:

    GET /api/certificate/user/:userId/course/:courseId

    Get user certificate from a single course

    Path Parameters:

    11. Push Notifications

    POST /api/notifications/save-fcm-token

    Saves user FCM token for push notifications

    Request Body:

    {
      userId: string, 
      FCMToken: string
    }
        

    GET /api/notifications/get-all-fcm-tokens

    Get all FCM tokens for push notifications

    GET /api/notifications/user/:userId/fcm-tokens

    Get all FCM tokens for a specific user

    URL Parameters:

    userId: string (MongoDB ObjectId)
        

    DELETE /api/notifications/fcm-token/:tokenId

    Delete a specific FCM token

    URL Parameters:

    tokenId: string (MongoDB ObjectId)
        

    PUT /api/notifications/fcm-token/:tokenId

    Update a specific FCM token

    URL Parameters:

    tokenId: string (MongoDB ObjectId)
        

    Request Body:

    {
      FCMToken: string
    }
        

    DELETE /api/notifications/user/:userId/fcm-tokens

    Delete all FCM tokens for a specific user

    URL Parameters:

    userId: string (MongoDB ObjectId)
        

    POST /api/notifications/send

    Send push notifications to specific users or all users

    Request Body:

    {
      userIds: string[], // Array of user IDs (optional if messageType is "All")
      title: string,     // Required - notification title
      body: string,      // Required - notification body text
      data: object,      // Optional - additional data to send with notification
      messageType: string // Optional - defaults to "All", use specific userIds if not "All"
    }
        

    12. Contact Us API

    POST /api/contact/send-message

    Send a contact message to the admin

    Request Body:

    {
      "name": "string",
      "email": "string",
      "message": "string"
    }
        

    Request Files:

    Response:

    {
      "success": true,
      "message": "Message sent successfully"
    }