Giter Site home page Giter Site logo

brettfarrow / cgm.js Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 8 KB

Allows easy use of the Dexcom Share API in your JavaScript project. Originally based on pydexcom.

License: MIT License

JavaScript 100.00%
cgm dexcom dexcom-api diabetes glucose-monitoring javascript node

cgm.js's Introduction

cgm.js

A JavaScript port of pydexcom

Requirements

This has been tested from Node 14 to Node 18, but may work in earlier versions as well.

Usage

Importing

const Dexcom = require("cgm.js");

For ESM, set "type": "module", in your package.json.

import Dexcom from "cgm.js";

Get Single Reading

Most recent reading:

const dexcom = new Dexcom("user", "pass");
const latestGlucoseReading = await dexcom.getLatestGlucoseReading();

getCurrentGlucoseReading() should return the same result but is maintained for parity with the original package.

Example Output

GlucoseReading {
    value: 143,
    mgdL: 143,
    mmolL: 7.9,
    trend: 4,
    trendDescription: 'steady',
    trendArrow: '→',
    time: 2023-02-26T00:48:54.000Z,
    json: { WT: 'Date(1677372534000)', Value: 143, Trend: 'Flat' }
}

Get Multiple Readings

const dexcom = new Dexcom("user", "pass");
const glucoseReadings = await dexcom.getGlucoseReadings(15, 3); // minutes and number of readings readings

The service will return the minimum of the two parameters (minutes and maxCount of readings), so if your readings take place every five minutes and you request 30 minutes and 3 readings, you will only see three readings returned.

Example Output

[
  GlucoseReading {
    value: 112,
    mgdL: 112,
    mmolL: 6.2,
    trend: 3,
    trendDescription: 'rising slightly',
    trendArrow: '↗',
    time: 2023-02-27T03:23:59.000Z,
    json: { WT: 'Date(1677468239000)', Value: 112, Trend: 'FortyFiveUp' }
  },
  GlucoseReading {
    value: 105,
    mgdL: 105,
    mmolL: 5.8,
    trend: 3,
    trendDescription: 'rising slightly',
    trendArrow: '↗',
    time: 2023-02-27T03:18:59.000Z,
    json: { WT: 'Date(1677467939000)', Value: 105, Trend: 'FortyFiveUp' }
  },
  GlucoseReading {
    value: 93,
    mgdL: 93,
    mmolL: 5.2,
    trend: 4,
    trendDescription: 'steady',
    trendArrow: '→',
    time: 2023-02-27T03:14:00.000Z,
    json: { WT: 'Date(1677467640000)', Value: 93, Trend: 'Flat' }
  },
]

cgm.js's People

Contributors

brettfarrow avatar

Stargazers

Dirk Holtwick avatar aliza13 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.