The Ecadamy backend provides a set of APIs to manage user authentication and registration through OTP (One-Time Password) verification. It supports sending OTPs, verifying phone numbers, and user management functionalities such as registration and login.
Base URL: https://ecadamy.onrender.com
- Method:
POST
- Endpoint:
{server}/api/otp/send
- Purpose: Checks if the phone number exists in the database. If not, generates and sends an OTP to the specified phone number.
- Request Body Example:
{ "phone": "+1234567890" }
- Method:
POST
- Endpoint:
{server}/api/otp/verify
- Purpose: Verifies the OTP sent to the phone number.
- Request Body Example:
{ "phone": "+1234567890", "otp": "123456" }
- Method:
POST
- Endpoint:
{server}/api/users/register
- Purpose: Allows new users to register their details in the database.
- Request Body Example:
{ "firstName": "John", "lastName": "Doe", "classTitle": "Web Development", "email": "johndoe@example.com", "phone": "+1234567890", "password": "securepassword" }
- Method:
POST
- Endpoint:
{server}/api/users/login
- Purpose: Allows existing users to log in using their phone number and password.
- Request Body Example:
{ "phone": "+1234567890", "password": "sample" }
- Method:
GET
- Endpoint:
{server}/api/users/getUser
- Purpose: Fetches the data of the logged in user.
- Note: Make sure to include token in your headers when sending request. This token expires after 1h.
- Request Body Example:
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }
The user object returned by the API contains the following fields:
- _id - Unique identifier for the user.
- firstName - The user's first name.
- lastName - The user's last name.
- classTitle - The class or course associated with the user.
- email - The user's email address.
- phone - The user's phone number.
Note: Ignore user _id as this will be given to the user once registered on the database.