- Heroku
- Flask
- Flask-sqlAlchemy
- postgres
- json, (demo data from http://demo9197058.mockable.io/users)
-
/api/test/multipleUsers
-POST
- To add multiple users- Post request must send data in
json
format to populate db - Response with HTTP status code
201
on success{}
- Post request must send data in
-
/api/test/multipleUsers
-DELETE
- To delete all users in db -
/api/users
-GET
- To list the users.- Response with HTTP status code
200
on success. - Also, supports some query parameters:-
page
- a number for paginationlimit
- no. of items to be returned, default limit is 5name
- search user by name as a substring in First Name or Last Name (Note, use substring matching algorithm/pattern to match the name)Sort
- name of attribute, the items to be sorted. By default it returns items in ascending order if this parameter exist, and if the value of parameter is prefixed with โ-โ character, then it should return items in descending order.- Sample query endpoint:-
/api/users?page=1&limit=10&name=James&sort=-age
. This endpoint should return list of 10 users whose first name or last name contains substring given name and sort the users by age in descending order of page 1.
- Response with HTTP status code
-
/api/users
-POST
- To create a new user- Request Payload should be like in json format :-
- Response with HTTP status code
201
on success and{}
- This endpoint will create a new user inside the database
-
/api/users/{id}
-GET
- To get the details of a user- Here
{id}
will be the id of the user in path parameter - Response with HTTP status code
200
on success - Sample query looks like:-
/api/users/1
ofGET
type
- Here
-
/api/users/{id}
-PUT
- To update the details of a user- Here
{id}
will be the id of the user in path parameter - Request Payload should be like in
json
format for updating first name, last name and age:- - Response with HTTP status code
200
on success and{}
- Here
-
/api/users/{id}
-DELETE
- To delete the user- Here {id} will be the id of the user in path parameter
- Response with HTTP status code 200 on success
{}