canonical: https://jentic.com/apis/googleapis.com/fitness

# Google Fitness API

The Google Fitness API gives apps programmatic access to a user's fitness tracking data, including steps, heart rate, distance, calories, and workout sessions. It exposes data sources, raw datasets, aggregated reads, and named sessions, all scoped to the authenticated user. Apps can read existing data from connected wearables and write new data points or sessions captured by their own clients.

## For AI agents

Read and write fitness data points, datasets, and workout sessions for the authenticated Google user across heart rate, steps, distance, calories, and other tracked metrics.

## Scope

Does not handle clinical or medical records, prescriptions, or HIPAA-regulated data - use the Cloud Healthcare API for clinical workloads; this API covers consumer fitness tracking only.

## Capabilities

- List the data sources connected to a user's Google Fit account
- Read raw data points from a specific data source over a time range
- Aggregate fitness data into daily or custom buckets via dataset:aggregate
- Write new data points to a custom data source
- Create and update named workout sessions for the user
- List sessions filtered by activity type and time range
- Detect changes to data points since a last read with dataPointChanges

## Use cases

### Pull Daily Activity Summaries into a Health Dashboard

Wellness apps want to show a user a daily summary of steps, distance, calories, and active minutes. The Fitness API's dataset:aggregate endpoint groups raw data points from connected sources into daily buckets in a single call, so the dashboard can fetch a week of summary data without paginating through raw points. The aggregation respects the user's connected device sources.

Example prompt: Call POST /me/dataset:aggregate with a 7-day window and bucketByTime of 86400000 ms to fetch daily step counts for the user.

### Log Workouts from a Coaching App

Coaching and training apps capture sessions on their own clients (a treadmill run, a yoga class) and need to write them back to Google Fit so the data is available across all the user's apps. The Fitness API supports session create and update, plus matching data point writes against an app-owned data source. Sessions appear in the Fit timeline with the app's name and activity type.

Example prompt: Call PUT /me/sessions/{sessionId} with activityType for running and the start and end times, and write matching heart rate data points to a custom dataSource.

### Sync Data on a Schedule

Background services that mirror Google Fit data into a user's account on another platform need to detect what changed since the last sync. The dataPointChanges endpoint returns inserted and deleted points since a token, allowing efficient incremental sync without rereading the full history.

Example prompt: Call GET /me/dataSources/{dataSourceId}/dataPointChanges with the previous pageToken and persist the new points and deletes to the local store.

### Agent-Mediated Wellness Reports

An AI wellness assistant can summarise a user's recent activity by querying the Fitness API through Jentic. The agent searches for the aggregate operation, loads the schema, and executes it with the requested time range, returning steps and active minutes for the assistant's reply. The user's OAuth token never enters the agent's prompt context.

Example prompt: Use Jentic to search 'aggregate google fit data', load the dataset:aggregate schema, and execute it for the past 30 days bucketed daily.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /{userId}/dataSources | List a user's data sources |
| POST | /{userId}/dataSources | Create a custom data source |
| GET | /{userId}/dataSources/{dataSourceId}/dataPointChanges | Get incremental data point changes |
| POST | /{userId}/dataset:aggregate | Aggregate fitness data into time buckets |
| GET | /{userId}/sessions | List workout sessions |
| PUT | /{userId}/sessions/{sessionId} | Create or update a session |

## Key resources

- **dataSources** — Sensors and apps that produce fitness data; list, get, create, update, and delete.
- **dataset** — Time-bounded reads and aggregate queries over data points.
- **sessions** — Named workout sessions with activity type, start, and end times.

## Why Jentic

- **Setup:** Wiring the Fitness API by hand means setting up Google OAuth 2.0 with per-user consent, requesting the specific fitness scopes, and refreshing short-lived access tokens yourself. Through Jentic you install once, import the Fitness API from the API Directory, store the OAuth credential once, and your agent calls it.
- **Permission scoping:** The Fitness API addresses the authenticated user's own data, so scope the agent to the operations it needs, such as aggregating a dataset or listing sessions. You choose that operation set, so writing new data sources or sessions is not included unless you add them.
- **Credential handling:** Your Fitness OAuth credential is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'get daily steps from Google Fit' or 'list fitness sessions', and Jentic returns the matching operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Cloud Healthcare API** — Stores FHIR, DICOM, and HL7v2 clinical data for regulated healthcare workloads.
- **Google Calendar API** — Schedules events that often correspond to logged workout sessions.
- **Google Drive API** — Stores exported fitness reports or images alongside Fit data.

## FAQ

### What authentication does the Google Fitness API use?

It uses Google OAuth 2.0 user-consent flows with fitness-specific scopes such as fitness.activity.read and fitness.heart_rate.write. Through Jentic, the user's refreshable OAuth credentials live encrypted in the vault and the agent receives only a scoped bearer token.

### Can I read heart rate data with this API?

Yes, when the user grants the fitness.heart_rate.read scope. Read heart rate points by listing the appropriate data source under /me/dataSources and calling the dataset endpoints, or use dataset:aggregate to bucket heart rate samples over time.

### What are the rate limits for the Google Fitness API?

Google enforces a default per-user and per-project quota, typically a few queries per second per user. Exceeding the quota returns HTTP 429 and should be retried with exponential backoff.

### How do I aggregate a user's daily steps through Jentic?

Search Jentic for 'aggregate google fit data', load the schema for POST /me/dataset:aggregate, and execute it with aggregateBy of com.google.step_count.delta and bucketByTime of 86400000 ms over the desired range.

### Is the Google Fitness API free?

Yes, the API itself is free to use. Apps are still subject to Google OAuth verification requirements before they can request restricted fitness scopes from end users.

### Can I write data to Google Fit from my own app?

Yes. Create a custom data source under /me/dataSources, then write points to that source via the dataset endpoints, and create matching named sessions via PUT /me/sessions/{sessionId}.

### Can I limit what my agent is allowed to do with the Google Fitness API?

Yes. Because you run Jentic One yourself, you decide exactly which Fitness API operations the agent may call and which OAuth credential it uses. You can grant read-only work such as aggregating a dataset with dataset:aggregate or listing a user's sessions and data sources, while withholding write operations like creating a custom data source or updating a session with PUT sessions unless you deliberately add them. The agent can only reach the operations you include, and it never sees the underlying OAuth token.
