Giter Site home page Giter Site logo

diary-api's Introduction

Diary API

Build Status Requirements Status

Getting started

python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
export FLASK_APP=diary_api.py
export FLASK_ENV=development
export FLASK_RUN_PORT=5000
flask db upgrade
flask run

Routes

Users

  • POST v1/users - Create a new user
  • GET v1/users?email_address=<string:email_address> - Retrieve a user by email address
  • GET v1/users/<uuid:user_id> - Retrieve a specific user
  • PUT v1/users/<uuid:user_id>/profile - Update a specific users profile
  • PUT v1/users/<uuid:user_id>/password - Update a specific users password
  • DELETE v1/users/<uuid:user_id> - Delete a specific user

Authentication

  • POST v1/login - Authenticate user credentials

Children

  • POST v1/children - Create a new child
  • GET v1/children?user_id=<uuid:user_id> Retrieve a list of children for a user
  • GET v1/children/<uuid:child_id> - Retrieve a specific child
  • PUT v1/children/<uuid:child_id> - Update a specific child
  • DELETE v1/children/<uuid:child_id> - Delete a specific child

Events

  • POST v1/children/<uuid:child_id>/events - Create a new event for a child
  • GET v1/children/<uuid:child_id>/events - Retrieve a list of events for a child
  • GET v1/children/<uuid:child_id>/events/<uuid:event_id> - Retrieve a specific event for a child
  • PUT v1/children/<uuid:child_id>/events/<uuid:event_id> - Update a specific event for a child
  • DELETE v1/children/<uuid:child_id>/events/<uuid:event_id> - Delete a specific event for a child

More details are in the OpenAPI Specification

Event Types

Point-in-time events

These events occurred at a single point in time. They have a single occurred_at attribute set to the a valid ISO 8601 formatted timestamp.

  • Change

Period of time events

These events occurred over a period of time. The started_at attribute is always set. The ended_at attribute may be null if the event is currently ongoing, or a valid ISO 8601 formatted timestamp if the event has ended.

  • Sleep
  • Feed

Event Examples

Example requests to POST v1/children/<uuid:id>/events endpoint:

Sleep

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "sleep",
    "started_at": "2018-07-21T21:21:59.123456",
    "ended_at": null,
    "notes": "Very tired!"
}

Breast feed

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "feed",
    "feed_type": "breast",
    "started_at": "2018-07-21T21:21:59.123456",
    "ended_at": null,
    "side": "left",
    "notes": "Very hungry!"
}

Bottle feed

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "feed",
    "feed_type": "bottle",
    "started_at": "2018-07-21T21:21:59.123456",
    "ended_at": null,
    "amount": 12.5,
    "unit": "ml",
    "notes": "Very hungry!"
}

Formula feed

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "feed",
    "feed_type": "formula",
    "started_at": "2018-07-21T21:21:59.123456",
    "ended_at": null,
    "amount": 12.5,
    "unit": "ml",
    "notes": "Very hungry!"
}

Wet change

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "change",
    "change_type": "wet",
    "occurred_at": "2018-07-21T21:21:59.123456",
    "notes": "Small wee"
}

Soiled change

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "change",
    "change_type": "soiled",
    "occurred_at": "2018-07-21T21:21:59.123456",
    "notes": "Very smelly!"
}

Dry change

Request body:

{
    "user_id": "eac11681-532e-4ec1-8d33-18337485e083",
    "type": "change",
    "change_type": "dry",
    "occurred_at": "2018-07-21T21:21:59.123456",
    "notes": "Clean"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.