Bucketlist is an API built using flask, where users can create and manage their bucketlists.
- Supports multiple users
- Token based authentication
- Users can create multiple bucket lists and bucketlist items
- Users can delete bucket lists and items in them
- Download the repo
- cd into the project root in your favorite commandline tool
- Run
pip install -r requirements.txt
to install all dependencies - Run
python runserver.py
to start the server - You can use Postman to send request to the server
version: 1.0.0
POST http://127.0.0.1:5000/api/v1.0/users
Request Body:
{
'username': 'kitty',
'password': 'wildcat',
}
Response:
{
"app_bucket_listing": [],
"id": 1,
"username": "kitty"
}
POST http://127.0.0.1:5000/api/v1.0/auth/login
Request Body:
{
'username': 'kitty',
'password': 'wildcat',
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjczMzkzMSwiaWF0IjoxNDQ2NzMyNzMxfQ.eyJpZCI6MX0.V-e2exs8HOmM_qr8y5w7FgzUaRhlq1GVPZzHtJ0BWQs"
}
POST http://127.0.0.1:5000/api/v1.0/bucketlists
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Request Body:
{
'name': 'Before I die',
}
Response:
{
"app_bucketlist_items": [],
"created_by": 1,
"date_created": "2015-11-05T15:14:14.851000+00:00",
"date_modified": "2015-11-05T15:14:14.851000+00:00",
"id": 1,
"name": "Before I die"
}
GET http://127.0.0.1:5000/api/v1.0/bucketlists
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Response:
{
"bucketlists": [
{
"app_bucketlist_items": [],
"created_by": 1,
"date_created": "2015-11-05T15:14:14.851000+00:00",
"date_modified": "2015-11-05T15:14:14.851000+00:00",
"id": 1,
"name": "Before I die"
}
],
"current_page": 1,
"has_next_page": false,
"has_previous_page": false,
"total_objects": 1,
"total_pages": 1
}
GET http://127.0.0.1:5000/api/v1.0/bucketlists?q=before%i%die&limit=20&page=1
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Response:
{
"bucketlists": [
{
"app_bucketlist_items": [],
"created_by": 1,
"date_created": "2015-11-05T15:45:30.576000+00:00",
"date_modified": "2015-11-05T15:45:30.576000+00:00",
"id": 1,
"name": "Before I die"
}
],
"current_page": 1,
"has_next_page": false,
"has_previous_page": false,
"total_objects": 1,
"total_pages": 1
}
GET http://127.0.0.1:5000/api/v1.0/bucketlists/<int:id>
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Response:
{
"app_bucketlist_items": [],
"created_by": 1,
"date_created": "2015-11-05T15:14:14.851000+00:00",
"date_modified": "2015-11-05T15:14:14.851000+00:00",
"id": 1,
"name": "Before I die"
}
PUT http://127.0.0.1:5000/api/v1.0/bucketlists/`<bucketlist_id>`
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Request Body:
{
'name': 'Before I live',
}
Response:
{
"app_bucketlist_items": [],
"created_by": 1,
"date_created": "2015-11-05T15:14:14.851000+00:00",
"date_modified": "2015-11-05T15:19:05.340000+00:00",
"id": 1,
"name": "Before I live"
}
POST http://127.0.0.1:5000/api/v1.0/bucketlists/`<bucketlist_id>`/items
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Request Body:
{
'name': 'learn to program',
}
Response:
{
"date_created": "2015-11-05T15:20:57.454000+00:00",
"date_modified": "2015-11-05T15:20:57.454000+00:00",
"done": false,
"id": 1,
"name": "learn to program"
}
PUT http://127.0.0.1:5000/api/v1.0/bucketlists/`<bucketlist_id>`/items/`<bucketlist_item_id>`
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Request Body:
{
'name': 'learn to dance',
'done': 'true'
}
Response:
{
"date_created": "2015-11-05T15:20:57.454000+00:00",
"date_modified": "2015-11-05T15:23:21.516000+00:00",
"done": true,
"id": 1,
"name": "learn to dance"
}
DELETE http://127.0.0.1:5000/api/v1.0/bucketlists/`<bucketlist_id>`/items/`<bucketlist_item_id>`
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Response:
{
"message": "bucketlist item deleted"
}
DELETE http://127.0.0.1:5000/api/v1.0/bucketlists/`<bucketlist_id>`
Request Header:
{
'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}
Response:
{
"message": "bucketlist deleted"
}
Two config files are used, 'test_config.py' and 'development_config.py' for testing and development/production environment respectively.
Tokens are used for authentication. You first create a user and create a token with the username and password. Tokens expire after every 20mins. Remember to always include a token variable in the header when making requests, except when creating a user.
Run coverage run test_bucketlist.py
.
God and my two guardian angels(:angel: Google and Stackoverflow:angel:). Also got some great insights from the following links:
Free