Q: App flow to retrieve wearable data

DeepBat1 month ago

I’m looking to connect our app to all fitness wearables. After setting it up, what is the process to request users permission to connect to their wearable device’s data? (e.g connecting it to Whoop data).

terra

Chandruadmin3 weeks ago

Hey there,

After a user connects one of their wearable device accounts to your Terra account, you will receive a user_id that uniquely identifies that device, something like efb43159-a1ab-4c4a-88bd-5100157a1e6b. Using this user ID, you can request for data from this user from your application's backend with a simple HTTP request like so (using python for this example):

import requests headers = { "dev-id": "<YOUR-DEV-ID>", "x-api-key": "<YOUR-API-KEY>", } params = { "start_date": "2024-06-01", "end_date": "2024-06-10", "user_id": "efb43159-a1ab-4c4a-88bd-5100157a1e6b", "to_webhook": False, "with_samples": True } response = requests.get("https://api.tryterra.co/v2/daily", headers=headers, params=params) data = response.json() # will contain daily data

The request above will return a json response containing a data payload that follows our daily data model.

Additionally, using Terra's destinations feature, you can have data from the users device/account directly sent to your backend or database as new data becomes available. For example, you can setup a webhook on your backend that will ingest Terra payloads. When a new user connects their device, you will receive a payload detailing the device and the user's id (and a reference_id that you can supply to identify them) and anytime they complete a workout or new steps gets synced with their device, we will send you a payload containing all the data for the day.

.

To see more regarding the methods of receiving data from Terra, checkout this section in our docs