Skip to main content
POST
/
aggregate
/
v1
/
user
/
{user_id}
/
query
Query One
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": "<string>",
    "anchor": "2023-12-25",
    "past": {
      "value": 2,
      "unit": "minute"
    }
  },
  "queries": [
    {
      "select": [
        {
          "arg": {
            "sleep": "id"
          },
          "func": "mean"
        }
      ],
      "group_by": [
        {
          "date_trunc": {
            "value": 2,
            "unit": "minute"
          },
          "arg": {
            "index": "sleep"
          }
        }
      ],
      "where": "<string>"
    }
  ],
  "config": {
    "provider_priority_overrides": [
      "oura"
    ]
  }
}'
{
  "results": [
    {
      "table": {}
    }
  ]
}

Horizon AI Query is in closed beta.Interested in the Horizon AI Query? Get in touch with your Customer Success Manager.

Receiving data in JSON

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": [...]
        }
    ]
}

Receiving data in Parquet

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

x-vital-api-key
string
header
required

Vital Team API Key

Headers

accept
enum<string>
default:*/*
Available options:
*/*,
application/json,
application/vnd.vital.tar+gzip+parquet

Path Parameters

user_id
string
required

Body

application/json
timeframe
object
required
  • RelativeTimeframe
  • Placeholder
queries
Query · object[]
required
config
object

Response

Successful Response

results
AggregationResult · object[]
required
I