AI-Powered Health & Wellness API
All API endpoints (except public routes) require Firebase Authentication.
https://api-xptzsvmqoa-nn.a.run.appUse Firebase Auth SDK to obtain an ID token:
Manage user profile data with encrypted PII/PHI fields.
Retrieve the current user's profile (decrypted).
Create a new user profile with comprehensive health data.
| Field | Type | Description |
|---|---|---|
name |
string | User's full name (encrypted) |
email |
string | User's email address (encrypted) |
phone |
string | Phone number (encrypted) |
dateOfBirth |
string | ISO date string (encrypted) |
timezone |
string | User's timezone (e.g., "America/Toronto") |
authProvider |
string | Auth method: "password", "google.com", "apple.com" |
age |
number | User's age (1-150) |
unitPreference |
enum | "metric" or "imperial" |
height |
number | Height in cm (metric) or inches (imperial) - encrypted |
weight |
number | Current weight in kg or lbs - encrypted |
targetWeight |
number | Target weight in kg or lbs |
biologicalSex |
string | "Male", "Female", or "Other" |
goalPace |
string | Weight loss pace: "Aggressive", "Moderate", "Conservative" |
dietPreference |
string | Diet type: "Classic", "Keto", "Paleo", "Vegan", etc. |
workoutFrequency |
string | "1-2", "3-4", "5-6", "7" days per week |
activityLevel |
string | Activity factor: "1.2", "1.375", "1.55", "1.725", "1.9" |
nutritionGoal |
string | "Fat Loss", "Muscle Gain", "Maintenance", "Recomp" |
allergies |
array | List of food allergies - encrypted |
dietIntensity |
string | Diet intensity description |
Daily nutritional targets (all numbers, in grams or specified units):
proteinTarget (g)carbsTarget (g)fatTarget (g)fiberTarget (g)waterTarget (ml)vitaminATarget (mcg)vitaminB1Target (mg)vitaminB2Target (mg)vitaminB3Target (mg)vitaminB6Target (mg)vitaminB12Target (mcg)vitaminCTarget (mg)vitaminDTarget (mcg)vitaminETarget (mg)vitaminKTarget (mcg)calciumTarget (mg)ironTarget (mg)magnesiumTarget (mg)potassiumTarget (mg)sodiumTarget (mg)zincTarget (mg)folateTarget (mcg)Daily and weekly exercise goals (all optional):
dailyActiveEnergyTarget (kcal/day) - Active calories burned goaldailyExerciseMinutesTarget (min/day) - Exercise duration goalweeklyExerciseSessionsTarget (sessions/week) - Workout frequency goaldailyStepsTarget (steps/day) - Step count goal (default: 10,000)isUsingCustomExerciseTargets (boolean) - Custom vs auto-calculated targetsusers/{uid}/quota/currentUpdate user profile (partial updates supported).
Same schema as POST, but all fields are optional. Only provided fields will be updated.
Track health metrics over time. All PHI fields are encrypted.
Retrieve health snapshots with optional filtering.
| Parameter | Type | Description |
|---|---|---|
startDate |
string | Filter from this date (ISO format) |
endDate |
string | Filter to this date (ISO format) |
limit |
number | Max records to return (default: 50, max: 100) |
Create a daily health snapshot from HealthKit data. All 19 fields are optional except date.
| Field | Type | Required | Description |
|---|---|---|---|
| đ Required | |||
date |
string | â | ISO date string (YYYY-MM-DD) |
| đ´ Sleep Metrics (7 fields) | |||
sleepDurationHours |
number | â | Total sleep time in hours (encrypted) |
sleepStartTime |
string | â | Sleep start time (ISO 8601 timestamp, encrypted) |
sleepEndTime |
string | â | Sleep end time (ISO 8601 timestamp, encrypted) |
deepSleepPercentage |
number | â | % of sleep in deep stage (0-100, encrypted) |
remSleepPercentage |
number | â | % of sleep in REM stage (0-100, encrypted) |
coreSleepPercentage |
number | â | % of sleep in core/light stage (0-100, encrypted) |
| đ Activity Metrics (5 fields) | |||
steps |
integer | â | Daily step count (encrypted) |
distanceWalkedKm |
number | â | Distance walked/run in kilometers (encrypted) |
activeEnergyBurned |
number | â | Active calories burned in kcal (encrypted) |
exerciseMinutes |
integer | â | Apple Exercise Ring minutes (encrypted) |
standHours |
integer | â | Apple Stand Ring hours (encrypted) |
| â¤ī¸ Heart Metrics (3 fields) | |||
restingHeartRate |
number | â | Lowest sustained heart rate in bpm (encrypted) |
averageHeartRate |
number | â | Mean heart rate for day in bpm (encrypted) |
heartRateVariability |
number | â | HRV SDNN measurement in ms (encrypted) |
| âī¸ Body Measurements (2 fields) | |||
weight |
number | â | Body weight in kg or lbs (encrypted) |
bmi |
number | â | Body Mass Index (encrypted) |
| đ Nutrition (2 fields) | |||
dietaryEnergy |
number | â | Total calories consumed in kcal (encrypted) |
dietaryWater |
number | â | Total water intake in ml (encrypted) |
| đ Metadata (1 field) | |||
dataCompleteness |
number | â | Score 0.0-1.0 indicating % of fields populated |
| đŽ Future Fields (not yet collected) | |||
bloodPressure |
object | â | {systolic: number, diastolic: number} (encrypted) |
glucose |
number | â | Blood glucose in mg/dL (encrypted) |
healthNotes |
string | â | Free-form notes (encrypted) |
Update an existing health snapshot (partial updates supported).
Soft delete a health snapshot (sets deletedAt timestamp).
Track meals and nutritional intake.
Retrieve diet logs with optional date filtering.
Same as health snapshots: startDate, endDate, limit
Create a new diet log entry from AI photo analysis. All entries must include AI-identified foods with complete nutritional data.
| Field | Type | Required | Description |
|---|---|---|---|
date |
string | â | ISO date string |
mealType |
enum | â | "breakfast", "lunch", "dinner", "snack" |
identifiedFood |
array | â | Array of AI-identified food items with nutrients |
calories |
number | â | Total meal calories |
servingSize |
number | â | Total serving size in grams |
title |
string | â | AI-generated meal title (encrypted) |
summary |
string | â | AI analysis summary (encrypted) |
recommendation |
string | â | AI dietary recommendations (encrypted) |
notes |
string | â | User notes (encrypted) |
photoIds |
array | â | Array of photo IDs |
Micronutrient Types: VitaminA, VitaminB1, VitaminB2, VitaminB3, VitaminB6, VitaminB12, VitaminC, VitaminD, VitaminE, VitaminK, Calcium, Iron, Magnesium, Potassium, Sodium, Zinc, Folate
Update an existing diet log.
Soft delete a diet log.
Bulk data operations for app reinstall and device migration. Note: Health data is managed by HealthKit and is not restored via this API.
Get sync status and data summary for the current user.
Restore user profile, diet logs, insights, photos, and achievements. Health data is managed by HealthKit and is not restored via this endpoint.
| Field | Type | Default | Description |
|---|---|---|---|
dataTypes |
array | All types | ["profile", "diet", "insights", "photos", "achievements"] |
startDate |
string | - | Filter data from this date |
endDate |
string | - | Filter data to this date |
chunkSize |
number | 100 | Records per chunk (10-500) |
Monitor AI analysis usage limits.
Check current daily quota status.
Track user accomplishments and milestones through gamification.
Achievement Flow:
achievement_definitions parameter)achievements collection/v1/sync/restore during app reinstall/device migrationData Separation:
Version Support:
criteriaAction (e.g., "meal_logged")nutritionCriteria objectStructure of achievement progress data returned from sync/restore endpoints.
| Field | Type | Description |
|---|---|---|
id |
string | Unique document ID in Firestore |
userId |
string | User who earned/is progressing toward this achievement |
achievementId |
string | References achievement definition in Remote Config |
progress |
number | Current progress value (e.g., 5 out of 7 days) |
isCompleted |
boolean | Whether achievement has been unlocked |
earnedAt |
string | null | ISO timestamp when achievement was completed (null if in-progress) |
lastUpdated |
string | ISO timestamp of last progress update |
createdAt |
string | ISO timestamp when achievement tracking started |
| Category | Description | Example |
|---|---|---|
consistency |
Daily/weekly logging streaks and habit building | "Log meals for 7 consecutive days" |
nutrition |
Macro/micro balance and healthy eating patterns | "Meet protein target for 5 days" |
discovery |
Food variety and trying new cuisines | "Log 50 unique food items" |
progress |
Weight goals and health metric improvements | "Reach target weight" |
| Type | Description | Reset Behavior |
|---|---|---|
lifetime |
One-time achievement, never resets | Once earned, stays earned forever |
daily |
Resets at midnight each day | Progress resets to 0 daily |
weekly |
Resets every Monday | Progress resets to 0 weekly |
monthly |
Resets on the 1st of each month | Progress resets to 0 monthly |
This achievement is complete (isCompleted: true) with an earnedAt timestamp.
This achievement is in progress (progress: 4 out of required target) and has not been earned yet (earnedAt: null).
Achievements are returned as part of the /v1/sync/restore response when "achievements" is included in the dataTypes array.
Achievement definitions are stored in Firebase Remote Config and managed via admin console. This schema is for reference only - users retrieve progress via sync/restore API.
| Field | Type | Description |
|---|---|---|
id |
string | Unique achievement identifier (referenced by achievementId in progress data) |
version |
number | Schema version (1 = legacy, 2 = nutrition criteria) |
title |
string | Display title (3-50 characters) |
description |
string | User-facing description (10-200 characters) |
icon |
string | SF Symbol name (e.g., "flame.fill", "star.fill") |
category |
enum | One of: consistency, nutrition, discovery, progress |
targetValue |
number | Required value to unlock (1-10000) |
rewardPoints |
number | Points awarded on completion (1-1000) |
criteriaType |
enum | How achievement is tracked: consecutive_days, meal_count, nutrition_target, unique_items, etc. |
recurrenceType |
enum | Reset frequency: lifetime, daily, weekly, monthly |
isEnabled |
boolean | Whether achievement is active |
Note: Achievement definitions are fetched by iOS app from Remote Config. The sync/restore API only returns user progress data.
Version 2 achievements support structured nutrition tracking with specific nutrients and accumulation types.
| Type | Description | Example |
|---|---|---|
daily_target |
Hit target amount each qualifying day | "Hit 150g protein daily for 7 days" |
cumulative_total |
Accumulate total amount over lifetime | "Accumulate 5000mg calcium total" |
single_meal |
Hit target in one meal | "Consume 50g protein in one meal" |
Standard HTTP error responses.
| Code | Error | Description |
|---|---|---|
400 |
Bad Request | Invalid request body or parameters |
401 |
Unauthorized | Missing or invalid authentication token |
403 |
Forbidden | Insufficient permissions or quota exceeded |
404 |
Not Found | Resource does not exist |
409 |
Conflict | Resource already exists |
429 |
Too Many Requests | Rate limit exceeded |
500 |
Internal Server Error | Server error (contact support) |
API health check endpoint.
Search food database by name or barcode.
Generate AI-powered health insights.
Upload food photos for AI analysis.