Skip to content

tadesanya/bucketlist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bucketlist logo

Coverage Status Build Status

INTRODUCTION

Bucketlist is an API built using flask, where users can create and manage their bucketlists.

FEATURES

  • Supports multiple users
  • Token based authentication
  • Users can create multiple bucket lists and bucketlist items
  • Users can delete bucket lists and items in them

INSTALLATION

  • 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

version: 1.0.0

User Guide

Create A User

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"
}

create a user with Postman

Create A Token

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"
}

get a token with Postman

Create A Bucketlist

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"
}

create a bucketlist with Postman

Display All Bucketlists

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 all bucketlists with Postman

Display All Bucketlists With Query, Limit and Page

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 all bucketlists with query, limit and page with Postman

Display Single Bucket List

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"
}

get a single bucketlist with Postman

Update A Bucketlist

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"
}

update a bucketlist with Postman

Create A Bucketlist Item

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"
}

create a bucketlist item with Postman

Update A Bucketlist Item

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"
}

update a bucketlist item with Postman

Delete A Bucketlist item

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 a bucketlist item with Postman

Delete A Bucketlist

DELETE http://127.0.0.1:5000/api/v1.0/bucketlists/`<bucketlist_id>`

Request Header:
{
    'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0NjcyNjc3NiwiaWF0IjoxNDQ2NzI1NTc2fQ.eyJpZCI6MX0.uN8pUuUAhixYkmbNISsk5ruBZf6N6oSPd66K_c8dSvo'
}

Response:
{
  "message": "bucketlist deleted"
}

delete a bucketlist with Postman

IMPLEMENTATION

Config File

Two config files are used, 'test_config.py' and 'development_config.py' for testing and development/production environment respectively.

Authentication

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.

TESTS

Run coverage run test_bucketlist.py.

CREDITS

God and my two guardian angels(:angel: Google and Stackoverflow:angel:). Also got some great insights from the following links:

LICENSE

Free

About

An API built with Flask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages