The Google Fit APIs, including the Google Fit REST API, will no longer be available after June 30, 2025 . As of May 1, 2024, developers cannot sign up to use these APIs .
For instructions on which API or platform to migrate to, visit the Health Connect migration guide . For a comparison of Health Connect with the Google Fit APIs and the Fitbit Web APIs, visit the Health Connect comparison guide .
Learn more about Health Connect and how to integrate with the API.
Send feedback
Working with Sessions
Stay organized with collections
Save and categorize content based on your preferences.
The Fitness REST API lets you create and obtain sessions. Sessions represent a time interval
during which users perform a fitness activity.
Sessions are represented by the Users.session
resource.
Activities are stored in an 'ActivityType'
integer.
Insert a session
This example demonstrates how to insert a session.
HTTP method
PUT
Request URL
https://www.googleapis.com/fitness/v1/users/me/sessions/someSessionId
Request body
{
"id": "someSessionId",
"name": "My example workout",
"description": "A very intense workout",
"startTimeMillis": 1396710000000,
"endTimeMillis": 1396713600000,
"version": 1,
"lastModifiedToken": "exampleToken",
"application": {
"detailsUrl": "http://example.com",
"name": "Foo Example App",
"version": "1.0"
},
"activityType": 1
}
Response
The response is a 200 OK
status code. The response body contains a JSON representation of the
session.
Curl command
$ curl --header "Authorization: Bearer ya29.1.yourtokenvalue " -X PUT \
--header "Content-Type: application/json;encoding=utf-8" -d @createsession.json \
"https://www.googleapis.com/fitness/v1/users/me/sessions/someSessionId"
List existing sessions
This example demonstrates how to list existing sessions from April 2014.
HTTP method
GET
Request URL
https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2014-04-01T00:00:00.000Z&endTime=2014-04-30T23:59:59.999Z
Request body
None.
Response
The response is a 200 OK
status code. The response body contains JSON representations of all
existing sessions that match the start and end times provided in the query parameters.
Curl command
$ curl --header "Authorization: Bearer ya29.1.yourtokenvalue " -X GET \
--header "Content-Type: application/json;encoding=utf-8" \
"https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2014-04-01T00:00:00.000Z&endTime=2014-04-30T23:59:59.999Z"
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-20 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2023-11-20 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-20 UTC."]]