Skip to content
Chris Dedman-Rollet edited this page Nov 1, 2024 · 2 revisions

API Documentation

This API documentation provides detailed information for our endpoint. Each section outlines the HTTP method, endpoint, a description of the operation, and the required request body, along with example curl commands to demonstrate how to interact with the API (or just use Postman).

1. Registration API

  • Endpoint: POST /register
  • Description: Registers a new user (select a role between Student and Educator)
  • Request Body:
    {
        "username": "dev",
        "email": "dev@csudh.edu",
        "password": "MyPasssword123",
        "confirm_password": "MyPasssword123",
        "role": "student"
    }
  • Example:
    curl -X POST http://localhost:4000/register -H "Content-Type: application/json" -d '{
        "username": "dev",
        "email": "dev@csudh.edu",
        "password": "MyPasssword123",
        "confirm_password": "MyPasssword123",
        "role": "student"
    }'

2. Login API

  • Endpoint: POST /login
  • Description: Logs in an existing user.
  • Request Body:
    {
        "email": "dev@csudh.edu",
        "password": "MyPasssword123"
    }
  • Example:
    curl -X POST http://localhost:4000/login -H "Content-Type: application/json" -d '{
        "email": "dev@csudh.edu",
        "password": "MyPasssword123"
    }'

3. Delete API

  • Endpoint: DELETE /delete
  • Description: Deletes a user by user_id.
  • Request Body:
    {
        "password": "Password1234",
        "user_id": "1"
    }
  • Example:
    curl -X DELETE http://localhost:4000/delete -H "Content-Type: application/json" -d '{
        "password": "Password1234",
        "user_id": "1"
    }'

3. User API

  • Endpoint: GET /user/:user_id
  • Description: Get user by user_id.
  • Example:
    curl -X GET http://localhost:4000/user/10
Clone this wiki locally