Skip to content

Latest commit

 

History

History
94 lines (45 loc) · 2.11 KB

README.md

File metadata and controls

94 lines (45 loc) · 2.11 KB

REST API for team management

This API service is hosted live on the endpoint https://usersappudbhav.herokuapp.com

An example app using this API endpoint is hosted on https://users-app-frontend.vercel.app and the source code for this app can be found on https://github.com/Udbhav8/usersAppFrontend

Live API ENDPOINT

 https://usersappudbhav.herokuapp.com

Live Nextjs/React app using the endpoint

https://users-app-frontend.vercel.app

Installing Dependencies

pip install -r requirements.txt

making migrations

python manage.py makemigrations

applying migrations

python manage.py migrate

Run the app

python manage.py runserver

REST API

The REST API to the example app is described below.

Get list of all users in JSON format

Request

GET /users/

curl -X GET http://127.0.0.1:8000/users 

Create a new user

Request

POST /users/

curl -X POST -H "Content-Type: application/json" http://127.0.0.1:8000/users/ -d "{\"firstName\":\"Udbhav\",\"lastName\":\"Agarwal\",\"email\":\"[email protected]\",\"role\":\"Regular\",\"number\":\"250-891-8441\"}"

Response

{"message": "New User Udbhav Agarwal with email:[email protected] created successfully"}

Get a specific User by ID

Request

GET /user/id

curl -X GET http://127.0.0.1:8000/user/1

Response

{"id":"1", "firstName": "Udbhav", "lastName": "Agarwal", "email": "[email protected]", "role":"Regular"}

Change a Users's details

Request

PATCH /update-user/id

curl -X PATCH -H "Content-Type: application/json" http://127.0.0.1:8000/update-user/1 -d "{\"firstName\":\"Udbhav\",\"lastName\":\"agarwal\",\"email\":\"[email protected]\",\"role\":\"Regular\",\"number\":\"250-891-8441\"}"

Response

        {'message':"User Udbhav Agarwal with email:[email protected] updated successfully"}

Delete a User

Request

DELETE /update-user/id

curl -X DELETE http://127.0.0.1:8000/update-user/1

Response

 {'message':"User Udbhav Agarwal  with email:[email protected] deleted successfully"}