This API enables the user to create bucketlist and list of items in the bucketlist. The items can be marked as done
when completed.
URL Endpoint | HTTP Methods | Summary |
---|---|---|
/api/v1/auth/register/ |
POST |
Register a new user |
/api/v1/auth/login/ |
POST |
Login and retrieve token |
/api/v1/bucketlists/ |
POST |
Create a new Bucketlist |
/api/v1/bucketlists/ |
GET |
Retrieve all bucketlists for user |
/api/v1/bucketlists/?limit=2&page=1 |
GET |
Retrieve one bucketlist per page |
/api/v1/bucketlists/<id>/ |
GET |
Retrieve bucket list details |
/api/v1/bucketlists/<id>/ |
PUT |
Update bucket list details |
/api/v1/bucketlists/<id>/ |
DELETE |
Delete a bucket list |
/api/v1/bucketlists/<id>/items/ |
POST |
Create items in a bucket list |
/api/v1/bucketlists/<id>/items/<item_id>/ |
DELETE |
Delete a item in a bucket list |
/api/v1/bucketlists/<id>/items/<item_id>/ |
PUT |
update a bucket list item details |
-
create a working directory
$ mkdir -p work-dir $ cd workdir
-
clone this repo to local
-
Via SSH
git clone [email protected]:brotich/CP2-bucket-list-api.git
-
via HTTPS
git clone https://github.com/brotich/CP2-bucket-list-api.git
-
-
Navigate to project directory
$ cd CP2-bucket-list-api $ git checkout develop
-
(Recommended)Create virtual environment
$ virtualenv bucketlist-venv $ source bucketlist-venv/bin/activate
-
Set up the development environment for the project
$ pip install -r requirements.txt $ python manage.py db init $ python manage.py db migrate $ python manage.py db upgrade
-
run server
$ python run.py Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
The API server is accessible on
http://0.0.0.0:5000/
Access the endpoints using your preferred client e.g Postman
-
POST
http://0.0.0.0:5000/auth/login/
register new user providing username and passwordbody:
username: brian2 password: password
response:
{ "message": "new user created successfully", "username": "brian2" }
-
POST
http://0.0.0.0:5000/auth/login/
login a user and get the token body:username: brian2 password: password
response:
{ "message": "new user created successfully", "username": "brian2" }
-
POST
http://localhost:5000/bucketlists/
create a new bucket listheaders:
Authorization: Token brian2.C1Y5JA.fXefAieGzWOviHlh3lYYLJphk98
body:
bucket_name: Christmas
response:
{ "data": { "created_by": 1, "date_created": "Tue, 10 Jan 2017 10:17:41 GMT", "date_modified": "Tue, 10 Jan 2017 10:17:41 GMT", "id": 1, "name": "Christmas" } }
-
GET
http://localhost:5000/bucketlists/
gets bucketlist for the user with the token suppliedheaders:
Authorization: Token brian2.C1Y5JA.fXefAieGzWOviHlh3lYYLJphk98
response:
{ "data": [ { "created_by": 1, "date_created": "Tue, 10 Jan 2017 10:17:41 GMT", "date_modified": "Tue, 10 Jan 2017 10:17:41 GMT", "id": 1, "name": "Christmas" } ], "next": null, "prev": null }