Query API
Query a single user
Aggregation Query DSL
Horizon AI Python SDK
Managing Continuous Query
Continuous Query Results
Query API
Query API
Query a single user
POST
/
aggregate
/
v1
/
user
/
{user_id}
/
query
curl --request POST \
--url https://api.tryvital.io/aggregate/v1/user/{user_id}/query \
--header 'Content-Type: application/json' \
--header 'x-vital-api-key: <api-key>' \
--data '{
"timeframe": {
"type": "relative",
"anchor": "2023-12-25",
"past": {
"value": 2,
"unit": "minute"
}
},
"queries": [
{
"select": [
{
"arg": {
"sleep": "session_start"
},
"func": "mean"
}
],
"group_by": [
{
"date_trunc": {
"value": 2,
"unit": "minute"
},
"arg": {
"index": "sleep"
}
}
],
"split_by_source": false
}
],
"config": {
"provider_priority_overrides": [
"oura"
]
}
}'
{
"results": [
{
"table": {}
}
]
}
Query API is currently in closed beta. The query schema and the behaviour is subject to change based on beta feedback.
JSON is the default output format. Each query instruction outputs one entry containing a dataframe to the $.results
array,
in the declaration order of the query instructions.
{
"results": [
"table": {
"index": [...],
"min": [...],
"max": [...],
"mean": [...],
"newest": [...]
}
]
}
Specify Accept: application/vnd.vital.tar+gzip+parquet
in your request header.
The response body is a gzipped Tarball of multiple Parquet files, namely 0.parquet
, 1.parquet
, 2.parquet
, etc.
The numbering corresponds to the declaration order of the query instructions.
Authorizations
Vital Team API Key
Headers
Available options:
*/*
, application/json
, application/vnd.vital.tar+gzip+parquet
Path Parameters
Body
application/json
Available options:
session_start
, session_end
, state
, type
, duration_second
, stage_asleep_second
, stage_awake_second
, stage_light_second
, stage_rem_second
, stage_deep_second
, stage_unknown_second
, latency_second
, heart_rate_minimum
, heart_rate_mean
, heart_rate_maximum
, heart_rate_dip
, heart_rate_resting
, efficiency
, hrv_mean_rmssd
, hrv_mean_sdnn
, skin_temperature
, skin_temperature_delta
, respiratory_rate
, score
, source_type
, source_provider
, source_app_id
, time_zone
Available options:
mean
, min
, max
, sum
, count
, median
, stddev
, oldest
, newest
Available options:
oura
, fitbit
, garmin
, whoop
, strava
, renpho
, peloton
, wahoo
, zwift
, freestyle_libre
, abbott_libreview
, freestyle_libre_ble
, eight_sleep
, withings
, apple_health_kit
, manual
, ihealth
, google_fit
, beurer_api
, beurer_ble
, omron
, omron_ble
, onetouch_ble
, accuchek_ble
, contour_ble
, dexcom
, dexcom_v3
, hammerhead
, my_fitness_pal
, health_connect
, polar
, cronometer
, kardia
, whoop_v2
, ultrahuman
, my_fitness_pal_v2
, map_my_fitness
curl --request POST \
--url https://api.tryvital.io/aggregate/v1/user/{user_id}/query \
--header 'Content-Type: application/json' \
--header 'x-vital-api-key: <api-key>' \
--data '{
"timeframe": {
"type": "relative",
"anchor": "2023-12-25",
"past": {
"value": 2,
"unit": "minute"
}
},
"queries": [
{
"select": [
{
"arg": {
"sleep": "session_start"
},
"func": "mean"
}
],
"group_by": [
{
"date_trunc": {
"value": 2,
"unit": "minute"
},
"arg": {
"index": "sleep"
}
}
],
"split_by_source": false
}
],
"config": {
"provider_priority_overrides": [
"oura"
]
}
}'
{
"results": [
{
"table": {}
}
]
}