`get-activity`
Retrieve completed workout sessions.
```python
def get_activity(
client: Terra,
user_id: str,
start_date: datetime,
end_date: datetime,
to_webhook: bool = False
) -> list:
"""
Get activity/workout data.
Returns sessions with:
- Duration, calories burned
- Heart rate (avg, max, min, samples)
- Distance, steps, floors
- GPS position/polyline
- Power, cadence (cycling)
"""
response = client.activity.get(
user_id=user_id,
start_date=start_date,
end_date=end_date,
to_webhook=to_webhook # True for async processing
)
return response.data
```
Sample Activity Response:
```json
{
"data": [{
"metadata": {
"start_time": "2025-12-05T07:00:00Z",
"end_time": "2025-12-05T08:00:00Z",
"type": "running"
},
"calories_data": {
"total_burned_calories": 450,
"net_activity_calories": 350
},
"heart_rate_data": {
"summary": { "avg_hr_bpm": 145, "max_hr_bpm": 175 }
},
"distance_data": { "distance_meters": 8500 },
"movement_data": { "steps_count": 8500 }
}]
}
```
`get-sleep`
Retrieve sleep sessions with stages.
```python
def get_sleep(
client: Terra,
user_id: str,
start_date: datetime,
end_date: datetime
) -> list:
"""
Get sleep data.
Returns sessions with:
- Sleep stages (deep, light, REM, awake)
- Duration in bed vs asleep
- Sleep efficiency
- HRV, respiratory rate
- Temperature deviation
"""
response = client.sleep.get(
user_id=user_id,
start_date=start_date,
end_date=end_date
)
return response.data
```
Sample Sleep Response:
```json
{
"data": [{
"metadata": {
"start_time": "2025-12-04T22:30:00Z",
"end_time": "2025-12-05T06:30:00Z"
},
"sleep_durations_data": {
"duration_in_bed_seconds": 28800,
"duration_asleep_seconds": 26400,
"sleep_efficiency": 0.92
},
"asleep": {
"duration_deep_sleep_state_seconds": 5400,
"duration_light_sleep_state_seconds": 14400,
"duration_REM_sleep_state_seconds": 6600
},
"awake": {
"num_wakeup_events": 2,
"sleep_latency_seconds": 600
},
"heart_rate_data": {
"summary": { "resting_hr_bpm": 52 }
}
}]
}
```
`get-daily`
Retrieve aggregated daily summaries.
```python
def get_daily(
client: Terra,
user_id: str,
start_date: datetime,
end_date: datetime
) -> list:
"""
Get daily aggregated data.
Returns summaries with:
- Steps, calories, distance
- Active minutes, floors
- Resting heart rate, HRV
- Recovery scores
- Stress data
Note: Sent multiple times/day - always OVERWRITE previous data.
"""
response = client.daily.get(
user_id=user_id,
start_date=start_date,
end_date=end_date
)
return response.data
```
Sample Daily Response:
```json
{
"data": [{
"metadata": {
"start_time": "2025-12-05T00:00:00Z",
"end_time": "2025-12-05T23:59:59Z"
},
"calories_data": {
"total_burned_calories": 2400,
"BMR_calories": 1600,
"net_activity_calories": 800
},
"movement_data": {
"steps_count": 10500,
"floors_climbed": 12
},
"heart_rate_data": {
"summary": { "resting_hr_bpm": 58 }
},
"scores": {
"recovery": { "score": 82 },
"activity": { "score": 75 },
"sleep": { "score": 88 }
}
}]
}
```
`get-body`
Retrieve body metrics and biometrics.
```python
def get_body(
client: Terra,
user_id: str,
start_date: datetime,
end_date: datetime
) -> list:
"""
Get body metrics data.
Returns measurements including:
- Weight, height, BMI
- Body fat %, muscle mass
- Blood glucose (CGM)
- Blood pressure
- Temperature
- SpO2
Note: Sent multiple times/day - always OVERWRITE previous data.
"""
response = client.body.get(
user_id=user_id,
start_date=start_date,
end_date=end_date
)
return response.data
```
Sample Body Response:
```json
{
"data": [{
"metadata": {
"start_time": "2025-12-05T00:00:00Z",
"end_time": "2025-12-05T23:59:59Z"
},
"body_metrics": {
"weight_kg": 75.5,
"height_cm": 178,
"BMI": 23.8,
"body_fat_percentage": 18.5
},
"blood_glucose_data": {
"blood_glucose_samples": [
{ "glucose_mg_per_dL": 95, "timestamp": "2025-12-05T07:00:00Z" },
{ "glucose_mg_per_dL": 120, "timestamp": "2025-12-05T08:30:00Z" }
]
},
"blood_pressure_data": {
"systolic_bp_mmHg": 120,
"diastolic_bp_mmHg": 80
}
}]
}
```
`get-nutrition`
Retrieve nutrition and meal data.
```python
def get_nutrition(
client: Terra,
user_id: str,
start_date: datetime,
end_date: datetime
) -> list:
"""
Get nutrition data.
Returns meal logs with:
- Calories, macros (protein, carbs, fat)
- Micronutrients
- Individual food items
- Meal timestamps
"""
response = client.nutrition.get(
user_id=user_id,
start_date=start_date,
end_date=end_date
)
return response.data
```
Sample Nutrition Response:
```json
{
"data": [{
"metadata": {
"start_time": "2025-12-05T00:00:00Z",
"end_time": "2025-12-05T23:59:59Z"
},
"summary": {
"macros": {
"calories": 2200,
"protein_g": 120,
"carbohydrates_g": 250,
"fat_g": 70,
"fiber_g": 30
}
},
"meals": [
{
"name": "Breakfast",
"timestamp": "2025-12-05T08:00:00Z",
"macros": { "calories": 450, "protein_g": 25 }
}
]
}]
}
```
`get-menstruation`
Retrieve menstrual cycle data.
```python
def get_menstruation(
client: Terra,
user_id: str,
start_date: datetime,
end_date: datetime
) -> list:
"""
Get menstruation/cycle data.
Returns tracking data including:
- Cycle phase, day in cycle
- Flow level, symptoms
- Predictions
"""
response = client.menstruation.get(
user_id=user_id,
start_date=start_date,
end_date=end_date
)
return response.data
```
`get-athlete`
Retrieve user profile information.
```python
def get_athlete(
client: Terra,
user_id: str
) -> dict:
"""
Get user profile/athlete data.
Returns profile including:
- Name, email (if available)
- Date of birth, age
- Sex, gender
- Location
- Connected devices
"""
response = client.athlete.get(user_id=user_id)
return response.data
```