npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@faymaz/jsdexcom

v2.0.0

Published

Node.js library for accessing Dexcom Share API with international support

Downloads

132

Readme

Visitor Count

Language EN

Author: faymaz

@faymaz/jsdexcom

Node.js library for accessing Dexcom Share API with international support. This library allows you to fetch real-time CGM (Continuous Glucose Monitor) data from Dexcom Share servers.

Installation

npm install @faymaz/jsdexcom

Usage

Basic Usage

import JSDexcom from '@faymaz/jsdexcom';

// Create client (default region is 'ous')
const dexcom = new JSDexcom('YOUR_USERNAME', 'YOUR_PASSWORD');

try {
  const reading = await dexcom.getLatestGlucose();
  console.log(`Current glucose: ${reading._value} mg/dL`);
  console.log(`Trend: ${reading._trend_arrow} (${reading._trend_direction})`);
  console.log(`Time: ${reading._datetime.toLocaleString()}`);
} catch (error) {
  console.error('Error:', error.message);
}

Region-Specific Usage

// For US users
const dexcomUS = new JSDexcom('USERNAME', 'PASSWORD', 'us');

// For International users (default)
const dexcomOUS = new JSDexcom('USERNAME', 'PASSWORD', 'ous');

// For Japan users
const dexcomJP = new JSDexcom('USERNAME', 'PASSWORD', 'jp');

Response Format

{
    _json: {
        WT: "Date timestamp",
        ST: "Date timestamp",
        DT: "Date timestamp",
        Value: 120,
        Trend: "Flat"
    },
    _value: 120,              // Glucose value in mg/dL
    _trend_direction: "Flat", // Text description of trend
    _trend_arrow: "→",       // Visual representation of trend
    _datetime: Date          // JavaScript Date object
}

Trend Arrows

| Trend | Arrow | Description | | -------------- | ----- | ---------------------- | | None | → | No trend | | DoubleUp | ↑↑ | Rising quickly | | SingleUp | ↑ | Rising | | FortyFiveUp | ↗ | Rising slowly | | Flat | → | Stable | | FortyFiveDown | ↘ | Falling slowly | | SingleDown | ↓ | Falling | | DoubleDown | ↓↓ | Falling quickly | | NotComputable | ? | Cannot determine trend | | RateOutOfRange | ⚠️ | Rate of change unknown |

Environment Variables

You can use environment variables for configuration:

DEXCOM_USERNAME=your-username
DEXCOM_PASSWORD=your-password
DEXCOM_REGION=ous  # or 'us' or 'jp'

Error Handling

try {
  const dexcom = new JSDexcom('USERNAME', 'PASSWORD');
  const reading = await dexcom.getLatestGlucose();
  // ... handle reading
} catch (error) {
  if (error.message.includes('Invalid credentials')) {
    console.error('Check your username and password');
  } else if (error.message.includes('No readings available')) {
    console.error('No recent glucose readings found');
  } else {
    console.error('Error:', error.message);
  }
}

Examples

Monitor Glucose Levels

import JSDexcom from '@faymaz/jsdexcom';

async function monitorGlucose() {
  const dexcom = new JSDexcom('USERNAME', 'PASSWORD');

  setInterval(
    async () => {
      try {
        const reading = await dexcom.getLatestGlucose();
        console.log(
          `${reading._datetime.toLocaleTimeString()}: ${reading._value} mg/dL ${reading._trend_arrow}`
        );

        if (reading._value < 70) {
          console.log('⚠️ LOW glucose alert!');
        } else if (reading._value > 180) {
          console.log('⚠️ HIGH glucose alert!');
        }
      } catch (error) {
        console.error('Error:', error.message);
      }
    },
    5 * 60 * 1000
  ); // Check every 5 minutes
}

monitorGlucose();

Standalone Version

You can also use the standalone version without npm. Check the GitHub repository for more information.

License

MIT

Author

faymaz - GitHub

Disclaimer

This project is not affiliated with Dexcom, Inc. Use at your own risk. Always verify glucose values using your official Dexcom receiver or app.