Giter Site home page Giter Site logo

python-nightscout's Introduction

Python Nightscout client

Build Status

A simple python client for accessing data stored in Nightscout

Install

Clone this repo, and inside the main directory, run:

pip install .

Example Usage

To create an instance of the nightscout.Api class, with no authentication:

import nightscout
api = nightscout.Api('https://yournightscoutsite.herokuapp.com/')

To use authentication, instantiate the nightscout.Api class with your api secret:

api = nightscout.Api('https://yournightscoutsite.herokuapp.com/', api_secret='your api secret')

Glucose Values

To fetch recent sensor glucose values (SGVs):

entries = api.get_sgvs()
print([entry.sgv for entry in entries])

Specify time ranges:

api.get_sgvs({'count':0, 'find[dateString][$gte]': '2017-03-07T01:10:26.000Z'})

Treatments

To fetch recent treatments (boluses, temp basals):

treatments = api.get_treatments()
print([treatment.eventType for treatment in treatments])

Profiles

profile_definition_set = api.get_profiles()

profile_definition = profile_definition_set.get_profile_definition_active_at(datetime.now())

profile = profile_definition.get_default_profile()

print "Duration of insulin action = %d" % profile.dia

five_thirty_pm = datetime(2017, 3, 24, 17, 30)
five_thirty_pm = profile.timezone.localize(five_thirty_pm)
print "Scheduled basal rate at 5:30pm is = %f" % profile.basal.value_at_date(five_thirty_pm)

python-nightscout's People

Contributors

ps2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.