Releasesv0.1.0
Read data

Statistics of one quantity type per hour or per local day

GET
/v1/users/{id}/samples/stats

Count, sum, mean, min and max of the samples whose start falls in each interval. With view=merged (the default) each interval holds one row, from the best ranked source that recorded something in it (see source-priorities), so nothing counts twice; the choice is made per interval, not per record. With view=all there is one series per provider, source and unit: a phone and a watch counting the same steps stay apart. Not paged.

Served from a continuous aggregate when the database has one and tz has a whole-hour offset over the range, else computed from the samples (same answer). Data written for a past hour (an imported history, a provider deletion) shows within about 5 minutes.

Authorization

tenantKey
headerAuthorizationBearer <token>

Tenant API key, ohs_sk_ + 43 base62 characters.

Path Parameters

id*string
Formatuuid

Query Parameters

type*string

Canonical quantity type, as for listSamples.

interval?string

Width of the intervals.

Default"day"
Value in"hour""day"
tz?string

IANA time zone of the intervals; a day runs from local midnight to local midnight.

Default"UTC"
start*|

Inclusive lower bound, RFC 3339 or YYYY-MM-DD (midnight in tz). Widened to a whole interval.

end*|

Exclusive upper bound, RFC 3339 or YYYY-MM-DD (midnight in tz). Widened to a whole interval; at most 10000 intervals after start.

provider?string

Keep one provider.

view?string

merged (the default): when several sources recorded the same thing (a ring and a watch the same night, a phone and a watch the same steps, one sample directly and through an aggregator), only the best ranked source's record is listed, so nothing counts twice. The order of sources is the user's (see source-priorities). all: every stored record of every source.

Default"merged"
Value in"merged""all"

Header Parameters

Authorization*string

The tenant API key, as a bearer secret.

Response Body

The intervals that hold samples, by start, provider, source and unit.

application/json
  1. response
type*string
interval*string
Value in"hour""day"
tz*string
view*string
Value in"merged""all"
start*string

Start of the range after widening, with the offset of tz.

Formatdate-time
end*string
Formatdate-time
truncated*boolean

True when more than 50000 rows matched; buckets holds the earliest.

buckets*array<>
curl -X GET 'http://localhost:8080/v1/users/497f6eca-6276-4993-bfeb-53cbbbba6f08/samples/stats?type=string&start=2019-08-24T14%3A15%3A22Z&end=2019-08-24T14%3A15%3A22Z' \  -H 'Authorization: Bearer ohs_sk_...'
{  "type": "string",  "interval": "hour",  "tz": "string",  "view": "merged",  "start": "2019-08-24T14:15:22Z",  "end": "2019-08-24T14:15:22Z",  "truncated": true,  "buckets": [    {      "start": "2019-08-24T14:15:22Z",      "provider": "string",      "source": "string",      "unit": "string",      "count": 0,      "sum": 0,      "avg": 0,      "min": 0,      "max": 0    }  ]}
Edit on GitHub