Skip to main content
GET
/
api
/
v1
/
sleep_metrics
/
{user_id}
Get Sleep Metrics
curl --request GET \
  --url https://api.example.com/api/v1/sleep_metrics/{user_id} \
  --header 'Authorization: Bearer <token>'
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://docs.nivara.io/llms.txt

Use this file to discover all available pages before exploring further.

Get Sleep Metrics

Get detailed sleep and recovery metrics including sleep stage distribution (deep, light, REM), sleep latency and WASO, sleep efficiency, and night events (out-of-bed counts).

Headers

ParameterTypeRequiredDescription
authorizationstringYesAPI authorization token (Bearer token)

Path Parameters

ParameterTypeRequiredDescription
user_idstringYesThe ID of the patient

Query Parameters

ParameterTypeRequiredDescription
daysintegerNoNumber of past days to fetch data for (default: 7)

Responses

StatusDescriptionContent Type
200Successful Responseapplication/json
422Validation Errorapplication/json

Sample Request

curl -X GET "https://api.covita.com/api/v1/sleep_metrics/User1?days=7" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Sample Response

{
  "user_id": "User1",
  "days": 7,
  "sleep_metrics": {
    "average_sleep_duration": 7.2,
    "average_sleep_efficiency": 83.5,
    "sleep_stages": {
      "deep_sleep_percentage": 20,
      "light_sleep_percentage": 55,
      "rem_sleep_percentage": 25
    },
    "sleep_latency_minutes": 12,
    "waso_minutes": 45,
    "out_of_bed_events": 1.5
  },
  "daily_breakdown": [
    {
      "date": "2023-08-15",
      "deep_sleep_minutes": 90,
      "light_sleep_minutes": 248,
      "rem_sleep_minutes": 112,
      "sleep_latency": 10,
      "waso": 40,
      "out_of_bed_count": 1
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

user_id
string
required

Query Parameters

days
integer
default:7

Response

Successful Response