### Run Quickstart Frontend Locally Source: https://docs.junction.com/home/quickstart Install frontend dependencies and start the frontend application. Configure the .env.local file with your API keys and region. The app will be accessible at http://localhost:3000. ```bash # Install dependencies cd quickstart/frontend npm install # Open .env.local, then fill # out NEXT_PUBLIC_VITAL_API_KEY, NEXT_PUBLIC_VITAL_ENV and NEXT_PUBLIC_VITAL_REGION # Start the frontend app npm run dev # Go to http://localhost:3000 ``` -------------------------------- ### Clone Quickstart and Run Backend Locally Source: https://docs.junction.com/home/quickstart Clone the Quickstart repository and set up the backend application. Ensure you have Python 3 and Poetry installed. Customize the .env file with your API keys and region. ```bash # Note: If on Windows, run # git clone -c core.symlinks=true https://github.com/tryVital/quickstart # instead to ensure correct symlink behavior git clone https://github.com/tryVital/quickstart.git # Create .env, then fill # out VITAL_API_KEY, VITAL_REGION (eu, us) and VITAL_ENV in .env touch .env # Note: must use python 3 # For virtualenv users: # virtualenv venv # source venv/bin/activate poetry install # Start the backend app cd backend/python source ./start.sh ``` -------------------------------- ### Get Forced Vital Capacity Data (Go) Source: https://docs.junction.com/api-reference/data/timeseries/forced-vital-capacity Fetch grouped Forced Vital Capacity data using the Vital Go client. This example includes context setup, client initialization, and error handling. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" ) client := vitalclient.NewClient( vitalclient.WithApiKey(""), vitalclient.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.VitalsForcedVitalCapacityGroupedRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Vitals.ForcedVitalCapacityGrouped(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Create Demo Connection with Go Source: https://docs.junction.com/wearables/providers/test_data This Go example shows how to create a demo connection using the Vital Go client. Initialize the client with your API key and the sandbox environment URL, then call `ConnectDemoProvider`. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) request := &vital.DemoConnectionCreationPayload{ UserId: "", Provider: vital.DemoProviders, } response, err := client.Link.ConnectDemoProvider(context.TODO(), request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Get Calories Active Grouped (Go) Source: https://docs.junction.com/api-reference/data/timeseries/calories-active This Go example demonstrates fetching active calories data. Initialize the Vital client with your API key and sandbox environment. Construct a `VitalsCaloriesActiveGroupedRequest` with start and end dates, then call `CaloriesActiveGrouped`. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" ) client := vitalclient.NewClient( vitalclient.WithApiKey(""), vitalclient.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.VitalsCaloriesActiveGroupedRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Vitals.CaloriesActiveGrouped(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Create Demo Connection with Java Source: https://docs.junction.com/wearables/providers/test_data Use the Vital Java client to establish a demo connection. Configure the client with your API key and environment, then invoke the `connectDemoProvider` method with the necessary payload. ```java import com.vital.api.Vital; import com.vital.api.core.Environment; import com.vital.api.resources.link.requests.DemoConnectionCreationPayload; import com.vital.api.types.DemoProviders; Vital vital = Vital.builder() .apiKey("YOUR_API_KEY") .environment(Environment.SANDBOX) .build(); DemoConnectionCreationPayload request = DemoConnectionCreationPayload .builder() .userId("") .provider(DemoProviders.) .build(); var data = vital.link().connectDemoProvider(request); ``` -------------------------------- ### Get Calories Active Grouped (Node.js) Source: https://docs.junction.com/api-reference/data/timeseries/calories-active Use this Node.js example to retrieve active calories data. Import the Vital client, configure it with your API key and environment, and then call `caloriesActiveGrouped` specifying the user ID and a request object containing start and end dates. ```javascript import { VitalClient, VitalEnvironment } from '@tryvital/vital-node'; import { VitalsCaloriesActiveGroupedRequest } from '@tryvital/vital-node/api/resources/vitals'; const client = new VitalClient({ apiKey: '', environment: VitalEnvironment.Sandbox, }); const request: VitalsCaloriesActiveGroupedRequest = { startDate: "2022-05-01", endDate: "2022-06-01" } const data = await client.vitals.caloriesActiveGrouped( '', request ); ``` -------------------------------- ### PSC Info API Response Example Source: https://docs.junction.com/lab/overview/locations This is an example of the response payload from the GET PSC Info endpoint, detailing specific PSC information. ```json { "lab_id": 27, "slug": "labcorp", "patient_service_centers": [ { "metadata": { "name": "LABCORP", "state": "AZ", "city": "Phoenix", "zip_code": "85006", "first_line": "1300 N 12th St", "second_line": "Ste 300", "phone_number": "480-878-3988", "fax_number": "844-346-5903", "hours": null }, "distance": "25", "site_code": "ABC", "capabilities": ["stat", "appointment_scheduling_with_lab"] }, ] } ``` -------------------------------- ### Create Link Connect Demo with Go Source: https://docs.junction.com/api-reference/link/link-demo-provider Leverage the Vital Go SDK to establish a demo connection. Initialize the client with your API key and environment options, then call ConnectDemoProvider with the request payload. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) request := &vital.DemoConnectionCreationPayload{ UserId: "", Provider: vital.DemoProviders, } response, err := client.Link.ConnectDemoProvider(context.TODO(), request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Create User with Go Source: https://docs.junction.com/api-reference/user/create-user Create a user using the Vital Go SDK. Initialize the client with your API key and desired environment, then use the `User.Create` method. Error handling is demonstrated. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) response, err := client.User.Create(context.TODO(), "") if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Area Info API Response Example Source: https://docs.junction.com/lab/overview/locations This is an example of the response payload from the GET Area Info endpoint, showing PSC availability within a radius. ```python { "zip_code": "85004", "central_labs": { "labcorp": { "within_radius": 5, # the number of PSCs within radius of provided zip code "radius": "25", # miles "capabilities": ["stat", "appointment_scheduling_with_lab"] # aggregate list of capabilities provided by PSCs within the radius } } ... } ``` -------------------------------- ### Inhaler Usage Data Example Source: https://docs.junction.com/api-reference/data/timeseries/inhaler-usage An example of the data structure for inhaler usage, including start and end timestamps, a timestamp for the event, the unit of measurement, and the recorded value. ```APIDOC ## Inhaler Usage Data Structure ### Description This section provides an example of the data structure for inhaler usage records. ### Example Response Body ```json { "end": "2023-02-13T14:57:24+00:00", "start": "2023-02-13T14:30:52+00:00", "timestamp": "2023-02-13T14:30:52+00:00", "unit": "count", "value": 2 } ``` ``` -------------------------------- ### Get User Devices with Go Source: https://docs.junction.com/api-reference/data/device/get-devices This Go example demonstrates how to retrieve user devices using the Vital Go client. Configure the client with your API key and base URL, then call the `User.GetDevices` method. Error handling is included. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) response, err := client.User.GetDevices(context.TODO(), "user_id") if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Example Inhaler Usage Data Source: https://docs.junction.com/api-reference/data/timeseries/inhaler-usage This is an example of the data structure returned for inhaler usage. It includes start and end timestamps, a timestamp for the reading, the unit of measurement, and the recorded value. ```yaml example: end: '2023-02-13T14:57:24+00:00' start: '2023-02-13T14:30:52+00:00' timestamp: '2023-02-13T14:30:52+00:00' unit: count value: 2 ``` -------------------------------- ### Fetch Raw Activity Data (Go) Source: https://docs.junction.com/api-reference/data/activity/get-raw This Go example demonstrates how to retrieve raw activity data using the Vital Go SDK. It includes setting up the client with API key and environment, and making the request. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.ActivityGetRawRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Activity.GetRaw(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Example BMI Data Structure Source: https://docs.junction.com/api-reference/data/timeseries/body-mass-index An example of the data structure returned for Body Mass Index (BMI) measurements, including start, end, and timestamp, along with the unit and value. ```yaml example: end: '2023-02-13T14:57:24+00:00' start: '2023-02-13T14:30:52+00:00' timestamp: '2023-02-13T14:30:52+00:00' unit: index value: 21 ``` -------------------------------- ### Create Link Connect Demo with Python Source: https://docs.junction.com/api-reference/link/link-demo-provider Use the Vital Python SDK to initiate a demo connection. Instantiate the Vital client with your API key and environment, then call connect_demo_provider with the necessary parameters. ```python from vital.client import Vital from vital.environment import VitalEnvironment client = Vital( api_key="YOUR_API_KEY", environment=VitalEnvironment.SANDBOX ) data = client.link.connect_demo_provider(user_id="", provider=DemoProviders.) ``` -------------------------------- ### ClientFacingWorkoutDistanceSample OpenAPI Example Source: https://docs.junction.com/api-reference/data/timeseries/workout-distance This example demonstrates the structure of a workout distance data point as defined in the OpenAPI specification. It includes start and end timestamps, a measurement value, and the unit of measurement. ```yaml title: ClientFacingWorkoutDistanceSample example: end: '2023-02-13T14:57:24+00:00' start: '2023-02-13T14:30:52+00:00' timestamp: '2023-02-13T14:30:52+00:00' unit: m value: 37 ``` -------------------------------- ### Create Link Connect Demo with Java Source: https://docs.junction.com/api-reference/link/link-demo-provider Employ the Vital Java SDK for creating a demo connection. Build the Vital client using your API key and environment, then construct the payload and call connectDemoProvider. ```java import com.vital.api.Vital; import com.vital.api.core.Environment; import com.vital.api.resources.link.requests.DemoConnectionCreationPayload; import com.vital.api.types.DemoProviders; Vital vital = Vital.builder() .apiKey("YOUR_API_KEY") .environment(Environment.SANDBOX) .build(); DemoConnectionCreationPayload request = DemoConnectionCreationPayload .builder() .userId("") .provider(DemoProviders.) .build(); var data = vital.link().connectDemoProvider(request); ``` -------------------------------- ### List Providers using Go Source: https://docs.junction.com/api-reference/providers Fetch all providers using the Vital Go SDK. Initialize the client with your API key and base URL for the sandbox environment, then call `GetAll`. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) response, err := client.Providers.GetAll(context.TODO()) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Workout Duration API Response Example Source: https://docs.junction.com/api-reference/data/timeseries/workout-duration This is an example of the JSON response structure you can expect when fetching workout duration data. It includes grouped data by source, with details on intensity, start and end times, and units. ```json { "groups": { "oura": [ { "data": [ { "end": "2023-02-13T14:30:52+00:00", "intensity": "medium", "start": "2023-02-13T14:30:52+00:00", "unit": "min", "value": 48 } ], "source": { "provider": "oura", "type": "ring" } } ] } } ``` -------------------------------- ### Get Workout Summary with Go Source: https://docs.junction.com/api-reference/data/workouts/get-summary Initialize the Vital Go client with your API key and desired environment. Construct a `WorkoutsGetRequest` object with start and end dates, then call the `Workouts.Get` method. Error handling is included for the API call. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.WorkoutsGetRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Workouts.Get(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Example Workout Summary Source Source: https://docs.junction.com/api-reference/data/workouts/get-summary Specifies the data provider and type for workout summaries. Ensure the provider is correctly configured. ```yaml provider: oura type: ring ``` -------------------------------- ### ClientFacingHeartRateAlertSample Source: https://docs.junction.com/api-reference/data/timeseries/heart-rate-alert Example of a heart rate alert sample, including start and end times, type, unit, and value. ```APIDOC ## ClientFacingHeartRateAlertSample ### Description Represents a sample of a heart rate alert, such as an irregular rhythm. ### Example ```json { "end": "2023-02-13T14:30:52+00:00", "start": "2023-02-13T14:30:52+00:00", "type": "irregular_rhythm", "unit": "count", "value": 1 } ``` ``` -------------------------------- ### Get User Profile Summary with Go Source: https://docs.junction.com/api-reference/data/profile/get-summary Set up the Vital Go client, providing your API key and environment, then call the Profile.Get method. Handle potential errors and print the received data. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) response, err := client.Profile.Get(context.TODO(), "") if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Example: Calories Active Created Event Source: https://docs.junction.com/webhooks/event-structure This example shows the structure of an event for created active calories data. It includes specific fields like `start`, `end`, and `value` for each sample, alongside common event metadata. ```json { "data": { "data": [ { "timestamp": "2023-05-17T07:00:00+00:00", "start": "2023-05-17T07:00:00+00:00", "end": "2023-05-17T08:00:00+00:00", "timezone_offset": 3600, "type": "", "unit": "kcal", "value": 39.518054167148996 }, { "timestamp": "2023-05-17T08:00:00+00:00", "start": "2023-05-17T08:00:00+00:00", "end": "2023-05-17T09:00:00+00:00", "timezone_offset": 3600, "type": "", "unit": "kcal", "value": 31.270257990822234 }, { "timestamp": "2023-05-17T09:00:00+00:00", "start": "2023-05-17T09:00:00+00:00", "end": "2023-05-17T09:01:00+00:00", "timezone_offset": 3600, "type": "", "unit": "kcal", "value": 5.733999999999999 } ], "source_id": 16, # Common wearable data event fields "source": { "logo": "https://storage.googleapis.com/vital-assets/apple_health.png", "name": "Apple HealthKit", "slug": "apple_health_kit" }, "user_id": "4a29dbc7-6db3-4c83-bfac-70a20a4be1b2" }, "event_type": "daily.data.calories_active.created", "user_id": "4a29dbc7-6db3-4c83-bfac-70a20a4be1b2", "client_user_id": "01HW3FSNVCHC3B2QB5N0ZAAAVG", "team_id": "6b74423d-0504-4470-9afb-477252ccf67a" } ``` -------------------------------- ### Fetch Grouped Steps Data (Go) Source: https://docs.junction.com/api-reference/data/timeseries/steps This Go example demonstrates how to fetch grouped steps data using the Vital client. Configure the client with your API key and base URL, then make the StepsGrouped call. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" ) client := vitalclient.NewClient( vitalclient.WithApiKey(""), vitalclient.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.VitalsStepsGroupedRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Vitals.StepsGrouped(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Get Active Calories Timeseries Source: https://docs.junction.com/api-reference/data/timeseries/calories-active Fetches a timeseries of active calories burned, including start and end times, and the value in kilocalories. ```APIDOC ## GET /data/timeseries/calories.active ### Description Retrieves a timeseries of active calories burned. This endpoint is useful for tracking daily energy expenditure related to physical activity. ### Method GET ### Endpoint /data/timeseries/calories.active ### Parameters #### Query Parameters - **start_datetime** (string) - Required - The start of the period for which to retrieve data (inclusive), in ISO 8601 format. - **end_datetime** (string) - Required - The end of the period for which to retrieve data (exclusive), in ISO 8601 format. - **source** (string) - Optional - Filters the timeseries data to a specific source provider (e.g., `oura`, `fitbit`). ### Response #### Success Response (200) - **source** (object) - Information about the data source. - **provider** (string) - Provider slug (e.g., `oura`, `fitbit`, `garmin`). - **type** (string) - The type of data source (app or device). - **app_id** (string or null) - Identifier of the app (for multi-source providers). - **device_id** (string or null) - Identifier of the device. - **data** (array) - An array of timeseries data points. - **unit** (string) - The unit of measurement, always `kcal` for active calories. - **start** (string) - The start time (inclusive) of the interval in ISO 8601 format. - **end** (string) - The end time (exclusive) of the interval in ISO 8601 format. - **value** (number) - The active calories burned during the interval in kilocalories. #### Response Example ```json { "source": { "provider": "oura", "type": "ring", "app_id": null, "device_id": null }, "data": [ { "unit": "kcal", "start": "2023-10-26T08:00:00+00:00", "end": "2023-10-26T09:00:00+00:00", "value": 150.5 }, { "unit": "kcal", "start": "2023-10-26T09:00:00+00:00", "end": "2023-10-26T10:00:00+00:00", "value": 120.0 } ] } ``` ``` -------------------------------- ### Connect Password Provider (Go) Source: https://docs.junction.com/wearables/connecting-providers/auth_types This Go snippet demonstrates linking a user account using email and password credentials. Initialize the Vital client with your API key and desired environment. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) request := &vital.IndividualProviderData{ Username: "", Password: "", } response, err := client.Link.ConnectPasswordProvider( context.TODO(), vital.PasswordProviders, request ) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Get Grouped Calories Active Data Source: https://docs.junction.com/api-reference/data/timeseries/calories-active Retrieve active calories data grouped by source, with specified start and end dates. ```APIDOC ## GET /v2/timeseries/{user_id}/calories_active/grouped ### Description Fetches active calories data for a user, grouped by data source. This endpoint allows you to query time-series data within a specified date range. ### Method GET ### Endpoint /v2/timeseries/{user_id}/calories_active/grouped ### Parameters #### Path Parameters - **user_id** (string) - Required - The unique identifier for the user. #### Query Parameters - **start_date** (string) - Required - The start date for the query (YYYY-MM-DD). - **end_date** (string) - Required - The end date for the query (YYYY-MM-DD). ### Request Example #### cURL ```bash curl --request GET \ --url {{BASE_URL}}/v2/timeseries/{user_id}/calories_active/grouped?start_date={{START_DATE}}&end_date={{END_DATE}} \ --header 'Accept: application/json' \ --header 'x-vital-api-key: ' ``` #### Python ```python from vital.client import Vital from vital.environment import VitalEnvironment client = Vital( api_key="YOUR_API_KEY", environment=VitalEnvironment.SANDBOX ) data = client.vitals.calories_active_grouped( user_id="", start_date="2021-10-01", end_date="2021-10-02" ) ``` #### Node.js ```javascript import { VitalClient, VitalEnvironment } from '@tryvital/vital-node'; import { VitalsCaloriesActiveGroupedRequest } from '@tryvital/vital-node/api/resources/vitals'; const client = new VitalClient({ apiKey: '', environment: VitalEnvironment.Sandbox, }); const request: VitalsCaloriesActiveGroupedRequest = { startDate: "2022-05-01", endDate: "2022-06-01" } const data = await client.vitals.caloriesActiveGrouped( '', request ); ``` #### Java ```java import com.vital.api.Vital; import com.vital.api.core.Environment; import com.vital.api.resources.vitals.requests.VitalsCaloriesActiveGroupedRequest; Vital vital = Vital.builder() .apiKey("YOUR_API_KEY") .environment(Environment.SANDBOX) .build(); VitalsCaloriesActiveGroupedRequest request = VitalsCaloriesActiveGroupedRequest.builder() .startDate("2022-05-01") .endDate("2022-06-01") .build(); var data = vital.vitals().caloriesActiveGrouped("", request); ``` #### Go ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" ) client := vitalclient.NewClient( vitalclient.WithApiKey(""), vitalclient.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.VitalsCaloriesActiveGroupedRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Vitals.CaloriesActiveGrouped(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` ### Response #### Success Response (200) - **groups** (object) - Contains data grouped by source. - **[source_name]** (array) - An array of calorie data points for a specific source. - **data** (array) - Array of individual calorie entries. - **end** (string) - The end timestamp of the activity (ISO 8601 format). - **start** (string) - The start timestamp of the activity (ISO 8601 format). - **unit** (string) - The unit of measurement for the calorie value (e.g., "kcal"). - **value** (number) - The amount of calories burned. - **source** (object) - Information about the data source. - **provider** (string) - The name of the data provider (e.g., "oura"). - **type** (string) - The type of device or service providing the data (e.g., "ring"). #### Response Example ```json { "groups": { "oura": [ { "data": [ { "end": "2023-02-13T14:57:24+00:00", "start": "2023-02-13T14:30:52+00:00", "unit": "kcal", "value": 184 } ], "source": { "provider": "oura", "type": "ring" } } ] } } ``` ``` -------------------------------- ### Fetch Grouped Body Weight Data (Go) Source: https://docs.junction.com/api-reference/data/timeseries/body-weight This Go example demonstrates how to retrieve grouped body weight data. It shows the initialization of the Vital client with an API key and sandbox environment, followed by the creation of a request object and the call to the `BodyWeightGrouped` method. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" ) client := vitalclient.NewClient( vitalclient.WithApiKey(""), vitalclient.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.VitalsBodyWeightGroupedRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Vitals.BodyWeightGrouped(context.TODO(), "*", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Get Sleep Summary Source: https://docs.junction.com/api-reference/data/sleep/get-summary Fetches the sleep summary data for a user. Requires user ID, start date, and end date. ```APIDOC ## GET /v2/summary/sleep/{user_id} ### Description Retrieve processed sleep summary data for a specific user, including duration, efficiency, and quality scores. ### Method GET ### Endpoint /v2/summary/sleep/{user_id} ### Parameters #### Path Parameters - **user_id** (string) - Required - The ID of the user whose sleep data is to be retrieved. #### Query Parameters - **start_date** (string) - Required - The start date for the sleep summary data (YYYY-MM-DD). - **end_date** (string) - Required - The end date for the sleep summary data (YYYY-MM-DD). ### Request Example ```bash curl --request GET \ --url {{BASE_URL}}/v2/summary/sleep/{user_id}?start_date={{START_DATE}}&end_date={{END_DATE}} \ --header 'Accept: application/json' \ --header 'x-vital-api-key: ' ``` ### Response #### Success Response (200) - **data** (object) - Contains the sleep summary details. - **duration** (number) - The total duration of sleep in minutes. - **efficiency** (number) - The sleep efficiency score (percentage). - **quality** (number) - The sleep quality score. #### Response Example ```json { "data": { "duration": 480, "efficiency": 85.5, "quality": 75 } } ``` ``` -------------------------------- ### Get User Sleep Source: https://docs.junction.com/api-reference/data/sleep/get-summary Fetches the sleep summary for a given user ID. You can filter the results by provider, start date, and end date. ```APIDOC ## GET /v2/summary/sleep/{user_id} ### Description Get sleep summary for user_id ### Method GET ### Endpoint /v2/summary/sleep/{user_id} ### Parameters #### Path Parameters - **user_id** (string) - Required - User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api. #### Query Parameters - **provider** (string) - Optional - Provider oura/strava etc. Defaults to '' - **start_date** (string) - Required - Date from in YYYY-MM-DD or ISO formatted date time. If a date is provided without a time, the time will be set to 00:00:00 - **end_date** (string) - Optional - Date to YYYY-MM-DD or ISO formatted date time. If a date is provided without a time, the time will be set to 23:59:59 ### Responses #### Success Response (200) - **sleep** (array) - Sleep data for the user. - **average_hrv** (integer) - Average heart rate variability. - **awake** (integer) - Time awake in seconds. - **bedtime_start** (string) - The start time of the bedtime in ISO8601 format. - **bedtime_stop** (string) - The end time of the bedtime in ISO8601 format. - **calendar_date** (string) - The date of the sleep record in YYYY-MM-DD format. - **created_at** (string) - Timestamp when the record was created. - **date** (string) - Date of the specified record, formatted as ISO8601 datetime string in UTC 00:00. Deprecated in favour of calendar_date. - **deep** (integer) - Time spent in deep sleep in seconds. - **duration** (integer) - Total sleep duration in seconds. - **efficiency** (number) - Sleep efficiency percentage. - **hr_average** (integer) - Average heart rate during sleep. - **hr_lowest** (integer) - Lowest heart rate recorded during sleep. - **id** (string) - Unique identifier for the sleep record. - **latency** (integer) - Time taken to fall asleep in seconds. - **light** (integer) - Time spent in light sleep in seconds. - **recovery_readiness_score** (integer) - Recovery readiness score. - **rem** (integer) - Time spent in REM sleep in seconds. - **respiratory_rate** (integer) - Average respiratory rate during sleep. - **skin_temperature** (number) - Skin temperature during sleep. - **source** (object) - Information about the data source. - **device_id** (string) - The ID of the device. - **provider** (string) - The name of the provider (e.g., 'oura', 'strava'). - **type** (string) - The type of the source. - **temperature_delta** (number) - The change in skin temperature. - **timezone_offset** (integer) - The timezone offset in minutes. - **total** (integer) - Total time in bed in seconds. - **updated_at** (string) - Timestamp when the record was last updated. - **user_id** (string) - The ID of the user. #### Response Example ```json { "sleep": [ { "average_hrv": 78, "awake": 2400, "bedtime_start": "2023-02-27T12:31:24+00:00", "bedtime_stop": "2023-02-27T12:31:24+00:00", "calendar_date": "2023-02-27", "created_at": "2023-02-27T20:31:24+00:00", "date": "2023-02-27T12:31:24+00:00", "deep": 2400, "duration": 28800, "efficiency": 0.97, "hr_average": 50, "hr_lowest": 43, "id": "e2e0eb04-6641-4858-9de5-649efb41b346", "latency": 1000, "light": 2400, "recovery_readiness_score": 82, "rem": 2400, "respiratory_rate": 14, "skin_temperature": 36.5, "source": { "device_id": "550e8400-e29b-41d4-a716-446655440000", "provider": "oura", "type": "unknown" }, "temperature_delta": -0.2, "timezone_offset": 2400, "total": 28800, "updated_at": "2023-02-28T01:22:38+00:00", "user_id": "1449752e-0d8a-40e0-9206-91ab099b2537" } ] } ``` #### Error Response (422) - **detail** (array) - Details of the validation error. ``` -------------------------------- ### Fetch Raw Sleep Data using Go Source: https://docs.junction.com/api-reference/data/sleep/get-raw This Go example shows how to fetch raw sleep data. It includes setting up the Vital client with an API key and environment, defining the request parameters, and making the `GetRaw` call, including basic error handling. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) EndDate := "2022-06-01" request := &vital.SleepGetRawRequest{ StartDate: "2022-05-01", EndDate: &EndDate, } response, err := client.Sleep.GetRaw(context.TODO(), "", request) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Get Menstrual Cycle Summary using Java Source: https://docs.junction.com/api-reference/data/menstrual-cycle/get-summary Build the Vital client using your API key and environment. Create a `MenstrualCycleGetRequest` object with the desired start and end dates. Finally, call the `get` method on the `menstrualCycle` resource with the user ID and request object. ```java import com.vital.api.Vital; import com.vital.api.core.Environment; import com.vital.api.resources.menstrualCycle.requests.MenstrualCycleGetRequest; Vital vital = Vital.builder() .apiKey("YOUR_API_KEY") .environment(Environment.SANDBOX) .build(); MenstrualCycleGetRequest request = MenstrualCycleGetRequest.builder() .startDate("2022-05-01") .endDate("2022-06-01") .build(); var data = vital.menstrualCycle().get("", request); ``` -------------------------------- ### Fetch Workout Stream using Go Source: https://docs.junction.com/api-reference/data/workouts/get-stream This Go example demonstrates how to retrieve workout stream data. It shows how to create a Vital client with API key and environment options, and then call the `GetByWorkoutId` method, including basic error handling. ```go import ( "context" vital "github.com/tryVital/vital-go" vitalclient "github.com/tryVital/vital-go/client" "github.com/tryVital/vital-go/option" ) client := vitalclient.NewClient( option.WithApiKey(""), option.WithBaseURL(vital.Environments.Sandbox), ) response, err := client.Workouts.GetByWorkoutId( context.TODO(), "" ) if err != nil { return err } fmt.Printf("Received data %s\n", response) ``` -------------------------------- ### Create Demo Connection with cURL Source: https://docs.junction.com/wearables/providers/test_data Use this cURL command to create a demo connection for a specified user and provider. Ensure you replace placeholders with your actual API key, user ID, and provider. ```bash curl --request POST \ --url https://api.sandbox.tryvital.io/v2/link/connect/demo \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'x-vital-api-key: ' \ --data '{"user_id": "", "provider": ""}' ``` -------------------------------- ### Get Raw Sleep Data Source: https://docs.junction.com/api-reference/data/sleep/get-raw This endpoint retrieves the raw sleep data for a specified user. You can filter the data by providing start and end dates. ```APIDOC ## GET /v2/summary/sleep/{user_id}/raw ### Description Retrieve raw sleep data for a specific user as received from their connected wearable provider. ### Method GET ### Endpoint /v2/summary/sleep/{user_id}/raw ### Parameters #### Path Parameters - **user_id** (string) - Required - The ID of the user whose sleep data is to be retrieved. #### Query Parameters - **start_date** (string) - Required - The start date for the data retrieval (YYYY-MM-DD). - **end_date** (string) - Required - The end date for the data retrieval (YYYY-MM-DD). ### Request Example ```bash curl --request GET \ --url {{BASE_URL}}/v2/summary/sleep/{user_id}/raw \ --header 'Accept: application/json' \ --header 'x-vital-api-key: ' ``` ### Response #### Success Response (200) - **data** (array) - An array of raw sleep data objects. - **type** (string) - The type of sleep data. - **value** (object) - The sleep data value, structure depends on the type. - **source** (string) - The source of the data (e.g., wearable provider). - **recorded_at** (string) - The timestamp when the data was recorded. #### Response Example ```json { "data": [ { "type": "sleep_stage", "value": { "stage": "deep", "start_time": "2023-01-01T02:00:00Z", "end_time": "2023-01-01T03:30:00Z" }, "source": "wearable_provider_x", "recorded_at": "2023-01-01T04:00:00Z" } ] } ``` ```