Giter VIP home page Giter VIP logo

dexcom-api-wrapper's Introduction

Dexcom API Wrapper

Dexcom has recently released a new API that enables developers to use data from their glucose sensors to create innovative apps. To get you started, here is a wrapper meant to be a starting template for your app. โ€ƒ https://developer.dexcom.com/

Features

This wrapper takes care of authentication, requests, and fetching data from the 5 GET endpoints available:

  • calibrations: user's calibration events.
  • dataRange: user's earliest and latest times for calibration, estimated glucose value (EGV), and event records. Useful for providing start and end dates for the other endpoints.
  • devices: user's device information, including G4, G5, and G6 standalone receivers, the G5 and G6 mobile apps, and transmitters.
  • egvs: user's estimated glucose values (EGVs), including trend and status information.
  • events: user's event records. This includes carbohydrate intake, insulin doses, exercise, and health events that are entered in the receiver interface or through the mobile app.

Setup

  1. Make a Dexcom Developer account.
  2. Create an app on Dexcom Developer to get CLIENT_ID and CLIENT_SECRET.
    1. Go to https://developer.dexcom.com/user/me/apps
    2. Click "Add an App โŠ•"
    3. Name it whatever you like and click "Create"
    4. In the "Redirect URI" field, write https://localhost:8080and click "Save"
      (unless you'd like to use something else in particular)
    5. Under "Authentication", copy the CLIENT_ID and CLIENT_SECRET.
  3. Install rauth.
    pip install rauth
    OR
    pip install -r requirements.txt
  4. Enter CLIENT_ID and CLIENT_SECRET on lines 11 and 12 respectively of app.py.
    NOTE: If you entered a different "Redirect URI" than https://localhost:8080 on step 2.iv, then change line 16.
  5. Run application to generate tokens.
    1. Run python dexcom.py
    2. Open the URL that's printed in the console. Sign in to your Dexcom Account.
      If you don't have a Dexcom account, refer to Using Sandbox Data and repeat step 5.
    3. Authorize the application to view your data. Check "Share Data", sign and click "Save and Continue".
    4. Copy the redirected URL and paste it into the console.
      It will look something like https://localhost:8080/?code=13d9f01422495234231233bfdb123351e0f.
    5. EGVs should be printed to your console!

Usage

Other than for setup and reference purposes, you don't need to access api.py. Your application implementation will be done entirely in dexcom.py. To use the API, use the dexcomAPI function.

dexcomAPI takes three arguments:

  • endpoint: The endpoint to use: calibrations, dataRange, devices, egvs, or events. All endpoints besides dataRange require a time window indicated by the start and end parameters below.
    Default: egvs.
  • start: the beginning date of the time window. Use dataRange endpoint to get the earliest time.
    Default: 2022-02-27T00:30:00.
  • end: the ending date of the time window. Use dataRange endpoint to get the latest time.
    Default: 2022-02-27T02:35:00.

dexcomAPI returns a JSON object. Refer to the Features section for each endpoint details.

Using Sandbox Data

Dexcom has provided a sandbox environment containing simulated CGM data is available for all Registered Developers to test their applications. The data in the sandbox emulates real Dexcom data, and all of the endpoints available in the production environment are also available in the sandbox environment.

To use the Sandbox data, comment out line 10 and uncomment line 9. This makes the endpoints use the base URL of https://sandbox-api.dexcom.com/v2/ instead of https://api.dexcom.com/v2/.

During authentication, you will be asked to select a Sandbox user. Refer to the Users section of Dexcom Developer Docs to select data that works best for your application. Once you've chosen, type your (or any) name to authorize.

Limitations

  • According to Dexcom Developer FAQs, the Dexcom API does NOT provide real-time estimated glucose values. All values reported by the /egvs endpoint are intentionally delayed by 3 hours. If you'd like real-time values, I highly recommend checking out Nightscout.
  • This wrapper does NOT deal with the /statistics endpoint. You can find more information about endpoints on Dexcom Developer Docs.
  • This application is simply a wrapper. It does not manipulate or analyze the Dexcom API data in any way. That is left up to you. I got bulk of the work out of the way so read up on Dexcom Developer Docs and change this application to your liking. All the best!

License

See the LICENSE file for license rights and limitations (MIT).

Donate, buy me a Pizza or PayPal me if you'd like to see this project expanded and support me. :)

Paypal me

Buy Me A Coffee Paypal me

dexcom-api-wrapper's People

Contributors

prince25 avatar

Stargazers

 avatar  avatar

Watchers

 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.