This API is designed to handle user registration, login, and OTP verification using a mobile number. It is built using Django and Django REST Framework.
http://localhost:8000/auth/
-
URL:
/register/ -
Method:
POST -
Headers:
Content-Type: application/json
-
Request Body:
{ "mobile": "1234567890", "password": "securepassword", "first_name": "Mahnegar", "last_name": "Eskandari", "email": "moon@example.com" } -
Success Response:
Code: 201 CREATED
-
Content:
{ "message": "User registered successfully." }
-
URL:
/otp/ -
Method:
POST -
Headers:
Content-Type: application/json
-
Request Body:
{
"mobile": "1234567890"
}-
Success Response:
-
Code: 201 CREATED -
Content:
-
{
"message": "OTP sent successfully."
}-
URL:
/verify-otp/ -
Method:
POST -
Headers:
Content-Type: application/json
-
Request Body:
{
"mobile": "1234567890",
"otp_code": "123456"
}-
Success Response:
-
Code: 200 OK -
Content:
-
{
"message": "OTP verified successfully."
}-
URL:
/login/ -
Method:
POST -
Headers:
Content-Type: application/json- Request Body:
{
"mobile": "1234567890",
"password": "securepassword"
}-
Success Response:
-
Code: 200 OK -
Content:
-
{
"token": "your_token_here"
}- Ensure the API is running locally on localhost:8000 before testing with Postman.
- Replace 1234567890 and other sample values with actual data as needed for testing.
- In case of authentication failures or invalid input, appropriate error messages and status codes will be returned.
-
Clone the repository and navigate to the project directory.
-
Install the required dependencies using pip install -r requirements.txt.
-
Apply migrations using python manage.py migrate.
-
Run the server using python manage.py runserver.
-
Use Postman or any API testing tool to interact with the endpoints.
A Postman collection has been provided to help test the API endpoints. You can use this collection to interact with the API. Import the achareh_project_postman_collection.json file into Postman to get started.
-
Method:
POST -
URL:
http://localhost:8000/auth/register/ -
Headers:
Content-Type: application/json- Body:
{
"mobile": "1234567890",
"password": "securepassword",
"first_name": "Mahnegar",
"last_name": "Eskandari",
"email": "moon@example.com"
}-
Method:
POST -
URL:
http://localhost:8000/auth/otp/ -
Headers:
- Content-Type:
application/json - Body:
- Content-Type:
{
"mobile": "1234567890"
}-
Method:
POST -
URL:
http://localhost:8000/auth/verify-otp/ -
Headers:
Content-Type: application/json- Body:
{
"mobile": "1234567890",
"otp_code": "123456"
}-
Method:
POST -
URL:
http://localhost:8000/auth/login/ -
Headers:
Content-Type: application/json- Body:
{
"mobile": "1234567890",
"password": "securepassword"
}