Beta. STARCO Dev works with synthetic data only: do not send real personal or health data. Every feature shows its real status (Available Beta Beta · in development Coming).

Documentation menu

Tutorial 02

Read a layer.

Goal: read the wellness layer of a synthetic twin, understand its shape, read one week of a kind as a series and handle missing days without inventing values.

time 10 minlevel beginneruses layer read Beta · observation series Betatabs curl · Python · TypeScript · CLI (the SDK and the command line are not published as packages yet)
  1. 1Request
  2. 2Shape
  3. 3null
  4. 4Series
  5. 5Table

STEP 1 Read the layer#

Any twin with data works: one of the 8 synthetic twins your project came with, or the twin from tutorial 01. The outputs below come from the tutorial twin after tutorial 03 and tutorial 04 sent it a week of synthetic observations.

curl "$API/twins/$TWIN/layers/wellness" -H "Authorization: Bearer $STARCO_KEY"

STEP 2 Understand the shape#

Response (trimmed)illustrative · synthetic
{ "twin_id": "3a9d5e2c-8b14-4f7a-a6d1-c2e09f4b7d31", "layer": "wellness", "template": "daily_movement",
  "computed_at": "2026-11-19T15:46:10Z", "observation_count": 16,
  "description": "Descriptive values of the observations received: no reference range, no interpretation, no score. Null means no data.",
  "kinds": [
    { "kind": "exercise_minutes", "unit": "min", "count": 0, "latest": null, "min": null, "max": null,
      "mean": null, "mean_last_7_days": null, "first_observed_at": null, "last_observed_at": null },
    { "kind": "steps", "unit": "steps", "count": 7,
      "latest": { "value": 7765, "observed_at": "2026-11-18T21:00:00Z" },
      "min": 5880, "max": 10240, "mean": 7956.4286, "mean_last_7_days": 7956.4286,
      "first_observed_at": "2026-11-12T21:00:00Z", "last_observed_at": "2026-11-18T21:00:00Z" },
    …,
    { "kind": "sleep_hours", "unit": "h", "count": 6,
      "latest": { "value": 7.7, "observed_at": "2026-11-18T07:00:00Z" },
      "min": 6.8, "max": 8, "mean": 7.3833, "mean_last_7_days": 7.3833,
      "first_observed_at": "2026-11-12T07:00:00Z", "last_observed_at": "2026-11-18T07:00:00Z" },
    { "kind": "hydration_glasses", "unit": "glasses", "count": 3, … },
    … ] }
computed_at
When the layer was last recomputed: after the last batch that touched it.
observation_count
How many observations the layer holds, over all its kinds.
kinds[]
One entry per kind of the layer, in the template's order: count, latest (value and time), min, max, mean (rounded to 4 decimals), mean_last_7_days (the 7 days that end at the kind's latest observation), first_observed_at and last_observed_at. Nothing more: no scores, no normal or high or low.

STEP 3 Handle null honestly#

exercise_minutes was never sent: count is 0 and every value is null. If you turn null into 0, a chart shows a day with no exercise that nobody recorded. Keep it as «no data» all the way to the screen.

for k in layer["kinds"]:
    if k["count"] == 0:
        print(f"{k['kind']}: no data")
    else:
        print(f"{k['kind']}: {k['count']} observations, mean {k['mean']} {k['unit']}")
Expected outputillustrative · synthetic
exercise_minutes: no data
steps: 7 observations, mean 7956.4286 steps
sitting_breaks: no data
…
sleep_hours: 6 observations, mean 7.3833 h

STEP 4 Read a week as a series#

The layer summarises; the series gives every observation. Filter by kind, from (inclusive) and to (exclusive), RFC 3339 with an offset.

curl "$API/twins/$TWIN/observations?kind=sleep_hours&from=2026-11-12T00:00:00Z&to=2026-11-19T00:00:00Z" \
  -H "Authorization: Bearer $STARCO_KEY"
Response (trimmed)illustrative · synthetic
{ "twin_id": "3a9d5e2c-8b14-4f7a-a6d1-c2e09f4b7d31",
  "data": [ { "kind": "sleep_hours", "value": 7.2, "unit": "h", "observed_at": "2026-11-12T07:00:00Z", "origin": "api" },
            { "kind": "sleep_hours", "value": 6.8, "unit": "h", "observed_at": "2026-11-13T07:00:00Z", "origin": "api" },
            { "kind": "sleep_hours", "value": 7.5, "unit": "h", "observed_at": "2026-11-15T07:00:00Z", "origin": "api" },
            … ] }

The week, drawn

no data 12131415161718 sleep_hours · synthetic

The 14th has no line at all: nothing was recorded that night. The series never fills a gap.

from datetime import date, timedelta

by_day = {o["observed_at"][:10]: o["value"] for o in series}
start = date(2026, 11, 12)
for i in range(7):
    d = (start + timedelta(days=i)).isoformat()
    v = by_day.get(d)
    print(d, f"{int(v)} h {round(v % 1 * 60):02d} min" if v is not None else "no data")
Expected outputillustrative · synthetic
2026-11-12 7 h 12 min
2026-11-13 6 h 48 min
2026-11-14 no data
2026-11-15 7 h 30 min
2026-11-16 7 h 06 min
2026-11-17 8 h 00 min
2026-11-18 7 h 42 min

What just happened

You read the wellness layer, recomputed by STARCO after the last batch: descriptive values per kind, with null where there were no observations. Then you read the series of one kind and kept the missing night as «no data» all the way to the screen. Both reads are rows of the project's audit chain (layers.show and observations.index).

Next steps#