https://github.com/ps2/python-nightscout
Nightscout api client for python
https://github.com/ps2/python-nightscout
nightscout python python-client python-nightscout
Last synced: about 1 month ago
JSON representation
Nightscout api client for python
- Host: GitHub
- URL: https://github.com/ps2/python-nightscout
- Owner: ps2
- Created: 2017-03-05T15:31:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T21:11:39.000Z (over 1 year ago)
- Last Synced: 2025-03-29T09:01:52.037Z (2 months ago)
- Topics: nightscout, python, python-client, python-nightscout
- Language: Python
- Size: 17.6 KB
- Stars: 27
- Watchers: 1
- Forks: 27
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Nightscout client
[](https://travis-ci.org/ps2/python-nightscout)
A simple python client for accessing data stored in [Nightscout](https://github.com/nightscout/cgm-remote-monitor)
## 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)