API Documentation¶
Register¶
API Docs for Register.
- POST /register/¶
Register a new user to the system.
{ "username": "username", "name": "name", "email": "email@user.com", "mobile": "9999999999", "password": "password" }
- JSON Parameters
username (str) – unique username
name (str) – name of the user
email (str) – unique email of user
mobile (str) – unique mobile number of user
password (str) – password of user
- Status Codes
201 Created – if supplied params are valid
400 Bad Request – if supplied params are invalid
Login¶
API Docs for Login.
- POST /login/¶
Login a user to the system.
{ "username": "username", "password": "my_secret_password", }
- JSON Parameters
username (str) – unique username
password (str) – password of user
- Status Codes
200 OK – if supplied params are valid
400 Bad Request – if some fields are missing
401 Unauthorized – if supplied params are invalid
Account¶
API Docs for Account.
- GET /account/¶
Get a user.
{ "id": 1, "username": "dummy_username", "name": "dummy_name", "email": "email@dummy.com", "mobile": "9999999999", "is_superuser": true, "is_staff": true }
- Status Codes
200 OK – if request is authenticated
401 Unauthorized – if request is not authenticated
- PUT /account/¶
Update all details of user.
{ "username": "updated_username", "name": "updated_name", "email": "email@updated.com", "mobile": "9999999999", "password": "updated_password" }
- JSON Parameters
username (str) – unique username
name (str) – name of the user
email (str) – unique email of user
mobile (str) – unique mobile number of user
password (str) – password of user
- Status Codes
200 OK – if request is authenticated
400 Bad Request – if any param is not supplied
401 Unauthorized – if request is not authenticated
- PATCH /account/¶
Update some details of user.
{ "name": "partial_updated_name", "email": "email@partial_updated.com", }
- JSON Parameters
username (str) – unique username, optional
name (str) – name of the user, optional
email (str) – unique email of user, optional
mobile (str) – unique mobile number of user, optional
password (str) – password of user, optional
- Status Codes
200 OK – if request is authenticated
400 Bad Request – if any param is not supplied
401 Unauthorized – if request is not authenticated
OTP¶
API Docs for OTP.
- POST /otp/¶
Generate, validate and login using OTP.
{ "destination": "1234567890", "email": "email@django.com", "verify_otp": "123456", "is_login": "True", "_comment1": "destination can be email/mobile", "_comment2": "when using mobile as destination, use email", "_comment3": "to verify otp, add verify_otp to request", "_comment4": "for log in, just add is_login to request", }
- JSON Parameters
destination (str) – destination where otp to be sent
email (str) – if mobile is used in destination then use this for email, optional
verify_otp (str) – to verify otp, optional
is_login (str) – to login user, optional
- Status Codes
201 Created – if supplied params are valid
400 Bad Request – if supplied params are invalid
403 Forbidden – if supplied otp is invalid
OTP Register Login¶
API Docs for OTP Register Login.
- POST /otpreglogin/¶
Register, Login using OTP.
{ "name": "some_awesome_name", "email": "email@django.com", "mobile": "1234567890", "verify_otp": "123456", }
- JSON Parameters
name (str) – name of user
email (str) – email of user
mobile (str) – mobile of user
verify_otp (str) – to verify otp, optional
- Status Codes
201 Created – if supplied params are valid
400 Bad Request – if supplied params are invalid
403 Forbidden – if supplied otp is invalid
Reset Password¶
API Docs for Reset Password.
- POST /password/reset/¶
Reset user’s password.
To reset user’s password, first you have to call /otp/ with is_login parameter value false.
Then call this API
{ "email": "email@django.com", "otp": "123456", "password": "my_new_secret_password", }
- JSON Parameters
email (str) – email of user
otp (str) – otp received on email
password (str) – new password
- Status Codes
202 Accepted – if supplied params are valid
400 Bad Request – if supplied params are invalid
403 Forbidden – if supplied otp is invalid
Is Unique¶
API Docs for Is Unique.
- POST /isunique/¶
Check uniqueness of username, email, mobile.
{ "prop": "email", "value": "email@django.com" }
- JSON Parameters
prop (str) – property to check for uniqueness, choices are username, email, mobile
value (str) – value to check for uniqueness
- Status Codes
200 OK – if supplied params are valid
400 Bad Request – if supplied params are invalid
Upload Image¶
API Docs for Upload Image.
- POST /upload-image/¶
Upload user’s profile image.
{ "profile_image": "<file_name>" }
- JSON Parameters
profile_image (file) – image file
- Status Codes
201 Created – if supplied params are valid
400 Bad Request – if image not passed
401 Unauthorized – if supplied token is invalid
Refresh Token¶
API Docs for Refresh Token.
- POST /refresh-token/¶
When short-lived access token expires, you can use the longer-lived refresh token to obtain another access token.
{ "refresh": "generated refresh token" }
- JSON Parameters
refresh (str) – refresh token
- Status Codes
200 OK – if supplied refresh token is valid
400 Bad Request – if refresh token is not passed
401 Unauthorized – if refresh token is invalid