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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cinnamon-rs

v0.1.3

Published

A type-safe, asynchronous Rust client for the Nightscout API (v1 & v2).

Readme

cinnamon

A type-safe, asynchronous Rust client for the Nightscout API (v1 & v2).

Cinnamon aims to simplify interactions with Nightscout by providing strongly-typed structs for entries, treatments, profiles, and device status, handling authentication and error propagation automatically.

Installation

Add this to your Cargo.toml:

[dependencies]
cinnamon = "0.1.0"
tokio = { version = "1", features = ["full"] }
chrono = "0.4"

Usage

Setup the Client

Initialize the client with your Nightscout URL and optional API Secret.

use cinnamon::client::NightscoutClient;
use std::env;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = "https://my-cgm.herokuapp.com";
    let token = Some("my-api-secret-123".to_string());

    let client = NightscoutClient::new(url, token)?;
    
    println!("Successfully connected to {}", client.base_url);
    Ok(())
}

Fetching Glucose Data (SGV)

Retrieve the latest Sensor Glucose Value (SGV) or a list of historical entries.

use cinnamon::models::entries::SgvEntry;

// ... inside main ...

// Get the single latest entry
match client.entries().sgv().latest().await {
    Ok(entry) => {
        println!("Latest BG: {} mg/dl", entry.sgv);
        println!("Time: {}", entry.date_string);
        println!("Trend: {:?}", entry.direction);
    },
    Err(e) => eprintln!("Error fetching SGV: {}", e),
}

// Fetch the last 10 entries
let history = client.entries().sgv().list().limit(10).await?;
for entry in history {
    println!("[{}] {}", entry.date_string, entry.sgv);
}

Fetching System State (Properties)

Use the V2 Properties API to check system states like Insulin On Board (IOB), Carbs On Board (COB), or Pump Status.

use cinnamon::models::properties::PropertyType;

// ... inside main ...

let stats = client.properties()
    .get()
    .only(&[PropertyType::Iob, PropertyType::Cob, PropertyType::Pump])
    .send()
    .await?;

if let Some(iob_data) = stats.iob {
    println!("IOB: {} U (Source: {})", iob_data.iob, iob_data.source);
}

if let Some(cob_data) = stats.cob {
    println!("COB: {} g", cob_data.cob);
}

Uploading Treatments

Upload insulin boluses, carb corrections, or other care events to Nightscout.

use cinnamon::models::treatments::Treatment;
use chrono::Utc;

// ... inside main ...

let correction = Treatment {
    id: None,
    event_type: "Correction Bolus".to_string(),
    created_at: Utc::now().to_rfc3339(),
    insulin: Some(2.5),
    notes: Some("Correction for high BG".to_string()),
    entered_by: Some("Cinnamon-Rust".to_string()),
    // Fill unused fields with None
    glucose: None, glucose_type: None, carbs: None, units: None,
};

match client.treatments().create(vec![correction]).await {
    Ok(_) => println!("Treatment uploaded successfully."),
    Err(e) => eprintln!("Failed to upload: {}", e),
}

Disclaimer

NO MEDICAL ADVICE: This library is for educational and informational purposes only. It is not intended to be relied upon for medical decisions, insulin dosing, or treatment adjustments. Always consult with a qualified healthcare professional.

If you have any concerns regarding your health or diabetes management, please contact your healthcare provider immediately.

NO WARRANTY: This software is provided "as is", without warranty of any kind. The data retrieved may be inaccurate, delayed, or incomplete. The authors and contributors explicitly disclaim any liability for any direct or indirect damage or health consequences resulting from the use of this code.