A device twin: series and daily totals.
A wristband sends step counts several times a day. Keep every reading as a point of the series, then read the week as one total per day, with the days without data left empty.
STARCO_KEY it runs as it is. The TypeScript and CLI tabs use the SDK and the command line, which are not published yet.The idea#
The series keeps each point at the time it refers to. Reading it with bucket=1d&agg=sum groups the points by UTC day; fill=null returns the empty days too, as null with n: 0, so a chart never draws a zero that nobody measured.
The whole program#
export API="https://api.starco.dev/v1"
AUTH="Authorization: Bearer $STARCO_KEY"
JSON="Content-Type: application/json"
TWIN=$(curl -s -X POST "$API/twins" -H "$AUTH" -H "$JSON" \
-d '{"template": "daily_movement", "layers": ["wellness"], "label": "wristband-01"}' | jq -r .twin.id)
curl -s -X POST "$API/twins/$TWIN/series/wellness.steps" -H "$AUTH" -H "$JSON" -d '{"points": [
{"t": "2026-11-14T09:00:00Z", "v": 2100}, {"t": "2026-11-14T21:00:00Z", "v": 5320},
{"t": "2026-11-16T21:00:00Z", "v": 9130}, {"t": "2026-11-17T21:00:00Z", "v": 6890}]}' | jq -c '{accepted, rejected}'
curl -s "$API/twins/$TWIN/series/wellness.steps?from=2026-11-14T00:00:00Z&to=2026-11-18T00:00:00Z&bucket=1d&agg=sum&fill=null" \
-H "$AUTH" | jq -r '.points[] | "\(.t[:10]) \(.v) \(.n)"'import os, requests
API = "https://api.starco.dev/v1"
H = {"Authorization": f"Bearer {os.environ['STARCO_KEY']}"}
twin = requests.post(f"{API}/twins", headers=H, json={
"template": "daily_movement", "layers": ["wellness"], "label": "wristband-01"}).json()["twin"]["id"]
points = [("2026-11-14T09:00:00Z", 2100), ("2026-11-14T21:00:00Z", 5320),
("2026-11-16T21:00:00Z", 9130), ("2026-11-17T21:00:00Z", 6890)]
r = requests.post(f"{API}/twins/{twin}/series/wellness.steps", headers=H,
json={"points": [{"t": t, "v": v} for t, v in points]}).json()
print({"accepted": r["accepted"], "rejected": r["rejected"]})
week = requests.get(f"{API}/twins/{twin}/series/wellness.steps", headers=H, params={
"from": "2026-11-14T00:00:00Z", "to": "2026-11-18T00:00:00Z", "bucket": "1d", "agg": "sum", "fill": "null"}).json()
for p in week["points"]:
print(p["t"][:10], p["v"], p["n"]) # v is None on a day without data, never 0import { Client } from '@starco/sdk';
const c = new Client({ baseUrl: "https://api.starco.dev/v1", apiKey: process.env.STARCO_KEY });
const twin = (await c.twins.create({ template: "daily_movement", layers: ["wellness"], label: "wristband-01" })).id;
const r = await c.series.add(twin, "wellness.steps", [
["2026-11-14T09:00:00Z", 2100], ["2026-11-14T21:00:00Z", 5320],
["2026-11-16T21:00:00Z", 9130], ["2026-11-17T21:00:00Z", 6890]]);
console.log({ accepted: r.accepted, rejected: r.rejected });
const week = await c.series.range(twin, "wellness.steps", {
from: "2026-11-14T00:00:00Z", to: "2026-11-18T00:00:00Z", bucket: "1d", agg: "sum", fill: true });
for (const p of week.points) console.log(p.t.slice(0, 10), p.v, p.n); // v is null on a day without data, never 0export STARCO_BASE_URL="https://api.starco.dev/v1" STARCO_API_KEY="$STARCO_KEY"
TWIN=$(starco --json twins create --template daily_movement --layers wellness --label wristband-01 | jq -r .id)
starco series add $TWIN wellness.steps 2100 --at 2026-11-14T09:00:00Z
starco series add $TWIN wellness.steps 5320 --at 2026-11-14T21:00:00Z
starco series add $TWIN wellness.steps 9130 --at 2026-11-16T21:00:00Z
starco series add $TWIN wellness.steps 6890 --at 2026-11-17T21:00:00Z
starco series range $TWIN wellness.steps --from 2026-11-14 --to 2026-11-18 --bucket 1d --agg sum --fill{"accepted":4,"rejected":[]}
2026-11-14 7420 2
2026-11-15 null 0
2026-11-16 9130 1
2026-11-17 6890 1The other tabs print the same facts in their own format. Ids, hashes and counts depend on your project.
What just happened
Four readings became four points. The read grouped them into four UTC days: the 14th adds its two readings, the 15th has none and says so with null and n 0.