- Every Nightscout API. Entries (sgv/mbg/cal), treatments, device status, profiles, food, settings and activity; properties, ddata and summary; status, auth and notifications; admin (subjects, roles, permissions). It uses API v3 when available and falls back to v1/v2 automatically.
- Safe auth. Access tokens are exchanged for short-lived JWTs and refreshed before they expire. Credentials never follow redirects and never travel over plain HTTP, and a failed login is never retried in a loop that would lock you out.
- Models that survive real data. Numbers stored as strings,
nulls and unknown fields from any uploader (xDrip+, Loop, AAPS, Trio, OpenAPS) are tolerated. Fields cinnamon doesn't know are kept, so read-modify-write never loses data. - Incremental sync. A persistable cursor mirrors collections, including the v1 uploads that API v3 history misses.
- Realtime (optional). Live
/storage,/alarmanddataUpdatestreams over socket.io, with automatic reconnects. - Tested against a real Nightscout. The suite runs against Nightscout 15.0.8 in Docker, not only against mocks.
Installation
[]
= "2.0.0-alpha.1"
= { = "1", = ["macros", "rt-multi-thread"] }
| Feature | Default | Enables |
|---|---|---|
rustls |
✅ | TLS through rustls |
native-tls |
TLS through the platform stack instead | |
compression |
✅ | gzip/brotli responses |
tracing |
✅ | tracing events per request (never bodies or secrets) |
realtime |
socket.io streams (ns.realtime()) |
|
blocking |
a synchronous wrapper (cinnamon::blocking::Client) |
Quick start
use ;
use Treatment;
use ;
async
Authentication
use ;
# async
connect checks the credentials before returning, so a typo fails immediately instead of
silently degrading to anonymous access. Use Client::builder(url).build() to skip the
round trip.
Queries, filters and streaming
use ;
use EventType;
use Filter;
use TryStreamExt;
# async
Unlike raw API v1, cinnamon never silently caps results at four days, and it never sends
an unbounded delete: delete_many requires a time range.
Reading, updating and deleting
use DeleteFilter;
use Timestamp;
# async
Incremental sync
use ;
use Treatment;
# async
Realtime (feature realtime)
use StreamExt;
let mut glucose = ns.realtime.glucose.await?;
while let Some = glucose.next.await
ns.realtime().storage([...]) follows API v3 writes, alarms() follows alarms (and can
ack them), and updates() follows dataUpdate deltas. That last one is the only live
feed for the many uploaders that still write through API v1. See examples/.
Blocking (feature blocking)
let ns = connect?;
let latest = ns.run?;
Errors
Every call returns cinnamon::Result<T>. cinnamon::Error separates Unauthorized,
Forbidden { permission }, NotFound, Gone (soft-deleted), BadRequest, ApiDisabled
(the server refuses writes), Unsupported (for example, settings on a v1-only server),
Timeout, Transport and Decode { path }. A decode error names the exact field that
broke.
Development
; ;
CINNAMON_E2E=1
See MIGRATION.md for upgrading from 1.x, and PARITY.md
for how each Nightscout endpoint maps to cinnamon.
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.