Giter VIP home page Giter VIP logo

heart_rate_databases_introduction's Introduction

heart_rate_databases_starter Build Status

This code creates an API that fetches and persists heart rate data to a mongodb database. The assignement outline can be found here.

Getting started

To get the API up and running, perform the following commands in the root directory of this repository:

  1. create a virtual environment: virtualenv env
  2. start the virtual environment: source env/bin/activate
  3. install all requirements: pip install -r requirements.txt
    NOTE: the use of screens is helpful for the following steps
  4. run docker run -v $PWD/db:/data/db -p 27017:27017 mongo
  5. run gunicorn --bind 0.0.0.0:5003 api:app (you can select the port you'd like gunicorn to listen to requests on - this repo defaults to 5003)

Exposed endpoints

Note: all endpoints return additional info when an error is thrown. This info is to help the end user deduce the issue(s) that cause the request to fail.

  • POST /api/heart_rate with
    {
        "user_email": REQUIRED,
        "user_age": REQUIRED, // in years
        "heart_rate": REQUIRED
    }
    returns:
    {
        "success": 1 OR 0  
    }
  • GET /api/heart_rate/<user_email>
    returns all heart rate measurements for given user:
    {
        "status": 1 OR 0,
        "user_data": {
            "age": int,
            "email": string,
            "hr_readings": array,
            "readings_ts": array
        }
    }
  • GET /api/heart_rate/average/<user_email>
    returns the user's average heart rate over all measurements:
    {
        "status": 1 OR 0,
        "user_data": {
            "age": int,
            "email": string,
            "hr_average": float,
            "is_user_tachycaric": boolean,
            "num_readings": int
        }
    }
  • POST /api/heart_rate/interval_average with
    {
        "user_email": REQUIRED,
        "heart_rate_average_since": REQUIRED // date string
    }
    
    returns the average heart rate for the user since the time specified:
    {
        "status": 1 OR 0,
        "user_data": {
            "age": int,
            "datetime_threshold": date string,
            "email": string,
            "hr_average": float,
            "is_user_tachycaric": boolean,
            "num_readings": int
        }
    }
  • GET /api/get_users
    returns all users with at least one heart rate reading:
    {
        "success": 1 OR 0,
        "emails": array
    }

heart_rate_databases_introduction's People

Contributors

vertikoff avatar suyashkumar avatar davidbradway avatar

Watchers

James Cloos avatar  avatar

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.