Google 피트니스 REST API를 비롯한 Google 피트니스 API는 2026년에 지원 중단될 예정입니다. 2024년 5월 1일부터 개발자는 이러한 API를 사용하도록 가입할 수 없습니다.
이전할 API 또는 플랫폼에 관한 안내는 헬스 커넥트 이전 가이드를 참고하세요. 헬스 커넥트와 Google Fit API 및 Fitbit Web API를 비교하려면 헬스 커넥트 비교 가이드를 참고하세요.
헬스 커넥트 및 API와 통합하는 방법을 자세히 알아보세요.
세션 작업
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
피트니스 REST API를 사용하면 세션을 만들고 가져올 수 있습니다. 세션은 시간 간격을 나타냄
사용자가 피트니스 활동을 할 때입니다.
세션은 Users.session
리소스로 표시됩니다.
활동은 'ActivityType'에 저장됩니다.
정수입니다.
세션 삽입
이 예에서는 세션을 삽입하는 방법을 보여줍니다.
- HTTP 메서드
- PUT
- 요청 URL
https://www.googleapis.com/fitness/v1/users/me/sessions/someSessionId
- 요청 본문
{
"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
}
- 응답
응답은 200 OK
상태 코드입니다. 응답 본문에는
세션입니다.
- curl 명령어
$ 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"
기존 세션 나열
이 예에서는 2014년 4월에 발생한 기존 세션을 나열하는 방법을 보여줍니다.
- HTTP 메서드
- 받기
- 요청 URL
https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2014-04-01T00:00:00.000Z&endTime=2014-04-30T23:59:59.999Z
- 요청 본문
- 없음
- 응답
- 응답은
200 OK
상태 코드입니다. 응답 본문에는 모든 응답의 JSON 표현이 포함됩니다.
쿼리 매개변수에 제공된 시작 및 종료 시간과 일치하는 기존 세션을 집계합니다.
- curl 명령어
$ 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"
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThe Fitness REST API allows you to create and retrieve fitness sessions, which represent periods of user activity.\u003c/p\u003e\n"],["\u003cp\u003eSessions are managed using the \u003ccode\u003eUsers.session\u003c/code\u003e resource and contain data like start/end times, activity type, and optional metadata.\u003c/p\u003e\n"],["\u003cp\u003eYou can insert new sessions using a PUT request to the API with session details in the request body.\u003c/p\u003e\n"],["\u003cp\u003eExisting sessions can be listed by sending a GET request with optional start and end time parameters to filter results.\u003c/p\u003e\n"],["\u003cp\u003eFor best practices on handling user data, refer to the Responsible use of Google Fit guidelines.\u003c/p\u003e\n"]]],[],null,["# Working with Sessions\n\nThe Fitness REST API lets you create and obtain sessions. Sessions represent a time interval\nduring which users perform a fitness activity.\n\nSessions are represented by the [`Users.session`](/fit/rest/v1/reference/users/sessions) resource.\n\nActivities are stored in an ['ActivityType'](/fit/rest/v1/reference/activity-types)\ninteger.\n| **Important:** For best practices when managing user data, see [Responsible use of Google Fit](/fit/overview#responsible_use_of_google_fit).\n\nInsert a session\n----------------\n\nThis example demonstrates how to insert a session.\n\nHTTP method\n: PUT\n\nRequest URL\n: `https://www.googleapis.com/fitness/v1/users/me/sessions/`**someSessionId**\n\nRequest body\n:\n\n {\n \"id\": \"someSessionId\",\n \"name\": \"My example workout\",\n \"description\": \"A very intense workout\",\n \"startTimeMillis\": 1396710000000,\n \"endTimeMillis\": 1396713600000,\n \"version\": 1,\n \"lastModifiedToken\": \"exampleToken\",\n \"application\": {\n \"detailsUrl\": \"http://example.com\",\n \"name\": \"Foo Example App\",\n \"version\": \"1.0\"\n },\n \"activityType\": 1\n }\n\nResponse\n\n: The response is a `200 OK` status code. The response body contains a JSON representation of the\n session.\n\nCurl command\n:\n\n ```\n $ curl --header \"Authorization: Bearer ya29.1.yourtokenvalue\" -X PUT \\\n --header \"Content-Type: application/json;encoding=utf-8\" -d @createsession.json \\\n \"https://www.googleapis.com/fitness/v1/users/me/sessions/someSessionId\"\n ```\n\nList existing sessions\n----------------------\n\nThis example demonstrates how to list existing sessions from April 2014.\n\nHTTP method\n: GET\n\nRequest URL\n: `https://www.googleapis.com/fitness/v1/users/me/sessions`**?startTime=2014-04-01T00:00:00.000Z&endTime=2014-04-30T23:59:59.999Z**\n\nRequest body\n: None.\n\nResponse\n: The response is a `200 OK` status code. The response body contains JSON representations of all\n existing sessions that match the start and end times provided in the query parameters.\n\nCurl command\n:\n\n ```\n $ curl --header \"Authorization: Bearer ya29.1.yourtokenvalue\" -X GET \\\n --header \"Content-Type: application/json;encoding=utf-8\" \\\n \"https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2014-04-01T00:00:00.000Z&endTime=2014-04-30T23:59:59.999Z\"\n ```"]]