Google 피트니스 REST API를 비롯한 Google 피트니스 API는 2026년에 지원 중단될 예정입니다. 2024년 5월 1일부터 개발자는 이러한 API를 사용하도록 가입할 수 없습니다.
이전할 API 또는 플랫폼에 관한 안내는 헬스 커넥트 이전 가이드를 참고하세요. 헬스 커넥트와 Google Fit API 및 Fitbit Web API를 비교하려면 헬스 커넥트 비교 가이드를 참고하세요.
헬스 커넥트 및 API와 통합하는 방법을 자세히 알아보세요.
REST API 시작하기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 튜토리얼에서는 피트니스 REST API에 대한 액세스를 활성화하고 OAuth 액세스 권한을 얻는 방법을 보여줍니다.
토큰을 확인하고, HTTP 요청을 사용하여 API 메서드를 호출할 수 있습니다.
Fitness REST API를 사용하려면
RESTful 웹 서비스
JSON 표현이 포함됩니다
Google 계정 만들기
피트니스 REST API를 사용하려면 Google 계정이 필요합니다.
계정이 있는 경우 별도의 조치를 취할 필요가 없습니다. 또한
테스트용으로 별도의 Google 계정을 만들어야 합니다.
OAuth 2.0 클라이언트 ID 요청
Fitness API용 OAuth 2.0 클라이언트 ID를 요청하려면 다음 단계를 따르세요.
-
Google API 콘솔을 참조하세요.
- 프로젝트를 선택하거나 새로 만듭니다. Android에서 동일한 프로젝트 사용
앱의 REST 버전을 제공합니다
- 계속을 클릭하여 Fitness API를 사용 설정합니다.
- 사용자 인증 정보로 이동을 클릭합니다.
- 새 사용자 인증 정보를 클릭하고 OAuth 클라이언트 ID를 선택합니다.
- 애플리케이션 유형 아래에서 웹 애플리케이션을 선택합니다.
- 승인된 자바스크립트 원본에 사이트의 기준 URL을 입력합니다.
요청이 시작되는 위치 (예:
https://developers.google.com
)
는 OAuth Playground에서 사용하는 URL입니다.
- 승인된 리디렉션 URI에서 응답이 있는 사이트의 URL을 입력합니다.
처리됩니다 (예:
https://developers.google.com/oauthplayground
).
는 OAuth Playground에서 사용하는 URL입니다.
만들기를 클릭합니다. 새 OAuth 2.0 클라이언트 ID 및 비밀번호가 목록에 표시됩니다.
프로젝트 ID입니다 OAuth 2.0 클라이언트 ID는 문자열이며,
다음과 같습니다.
780816631155-gbvyo1o7r2pn95qc4ei9d61io4uh48hl.apps.googleusercontent.com
OAuth Playground에서 REST API 사용해 보기
OAuth 플레이그라운드는 API에 익숙해지는 가장 쉬운 방법입니다.
피트니스 REST API를 사용하기 전에 HTTP 요청을 제출하고 응답을 관찰
클라이언트 코드를 작성할 수 있습니다
OAuth 플레이그라운드에서 피트니스 REST API를 승인하려면 다음 안내를 따르세요.
- OAuth 플레이그라운드로 이동합니다.
- 1단계에서 승인하고 Fitness v1을 펼친 다음
피트니스 범위
- API 승인 버튼을 클릭하고 다음을 수행할 Google API 콘솔 프로젝트를 선택합니다.
메시지가 표시되면 허용을 클릭합니다. 이 기능을 사용하면
선택한 Google API 콘솔 계정과 연결된 데이터 수정
- 승인 코드를 토큰으로 교환 버튼을 클릭합니다. OAuth
플레이그라운드는
Authorization:
에 이 헤더를 자동으로 포함합니다.
요청 헤더에 사용해야 합니다. 액세스 토큰은
60분 (3,600초) 후에 만료됩니다.
HTTP 요청 제출
다음 예는 HTTP 요청을 전송하여 모든
새 데이터 소스를 만들 수 있습니다. 피트니스 REST용
API의 경우 URI 형식은 다음과 같습니다.
https://www.googleapis.com/fitness/v1/resourcePath?parameters
사용 가능한 모든 데이터 소스를 나열하는 방법은 다음과 같습니다.
- HTTP 메서드에서 GET을 선택합니다.
- 요청 URI에
https://www.googleapis.com/fitness/v1/users/me/dataSources
를 입력합니다.
- 요청 보내기를 클릭합니다.
요청과 응답이 페이지 오른쪽에 표시됩니다. 만약
요청이 성공하면 응답에는 이전 요청의 데이터 소스가
JSON 형식의 예입니다
데이터 소스를 만드는 방법은 다음과 같습니다.
- HTTP 메서드에서 POST를 선택합니다.
- 요청 URI에
https://www.googleapis.com/fitness/v1/users/me/dataSources
를 입력합니다.
- 요청 본문 입력을 클릭합니다.
요청 본문 창에서 다음 JSON을 복사하여 붙여넣습니다.
{
"dataStreamName": "MyDataSource",
"type": "derived",
"application": {
"detailsUrl": "http://example.com",
"name": "Foo Example App",
"version": "1"
},
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"device": {
"manufacturer": "Example Manufacturer",
"model": "ExampleTablet",
"type": "tablet",
"uid": "1000001",
"version": "1"
}
}
Request Body(요청 본문) 창에서 Close(닫기)를 클릭합니다.
요청 보내기를 클릭합니다.
요청과 응답이 페이지 오른쪽에 표시됩니다. 요청
Authorization
헤더에 OAuth 액세스 토큰이 포함됩니다.
Authorization: Bearer ya29.OAuthTokenValue
요청이 성공하면 응답의 첫 번째 줄은 다음과 같습니다.
HTTP/1.1 200 OK
cURL을 사용하여 피트니스 REST API에 액세스
cURL 명령줄 도구를 사용하여
피트니스 REST API. 요청하려면 OAuth 액세스 토큰이 필요합니다.
(이전 안내 참고)
액세스 토큰은 1시간 후에 만료됩니다. 다음 예는
간단한 bash 스크립트를 사용하여 모든 데이터 소스를 나열합니다.
#!/bin/bash
ACCESS_TOKEN=""
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
https://www.googleapis.com/fitness/v1/users/me/dataSources
다음 단계
REST API에 대해 자세히 알아보려면 다음 페이지를 참조하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThis tutorial provides a comprehensive guide on activating and utilizing the Fitness REST API for accessing and managing fitness data.\u003c/p\u003e\n"],["\u003cp\u003eIt outlines the process of obtaining OAuth access tokens for authentication and authorization.\u003c/p\u003e\n"],["\u003cp\u003eYou will learn how to make HTTP requests to interact with the API, including listing data sources and creating new ones.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial also provides practical examples using the OAuth Playground and cURL for testing and implementation.\u003c/p\u003e\n"],["\u003cp\u003eIt includes links to further resources for in-depth understanding of data types, sessions, and workout recording.\u003c/p\u003e\n"]]],[],null,["# Getting Started with the REST API\n\nThis tutorial shows you how to activate access to the Fitness REST API, obtain OAuth access\ntokens, and invoke the API methods using HTTP requests.\n\nTo use the Fitness REST API, it is important that you understand the basics of\n[RESTful web services](http://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services)\nand [JSON representations](http://en.wikipedia.org/wiki/JSON).\n\nGet a Google Account\n--------------------\n\nTo use the Fitness REST API, you need a [Google Account](https://www.google.com/accounts/NewAccount).\nIf you already have an account, then you're all set. You may also want to\ncreate a separate Google Account for testing purposes.\n\nRequest an OAuth 2.0 client ID\n------------------------------\n\nFollow these steps to request an OAuth 2.0 client ID for the Fitness API.\n\n1. Go to the [Google API Console](https://console.cloud.google.com/flows/enableapi?apiid=fitness).\n2. Select a project, or create a new one. Use the same project for the Android and REST versions of your app.\n3. Click **Continue** to enable the Fitness API.\n4. Click **Go to credentials**.\n5. Click **New credentials** , then select **OAuth Client ID**.\n6. Under **Application type** , select **Web application**.\n7. Under **Authorized JavaScript origins** , enter the base URL of the site from which requests will originate (for example `https://developers.google.com` is the URL used by the OAuth Playground).\n8. Under **Authorized redirect URI** , enter the URL of the site where responses will be handled (for example `https://developers.google.com/oauthplayground` is the URL used by the OAuth Playground).\n9. Click **Create**. Your new OAuth 2.0 Client ID and secret appear in the list\n of IDs for your project. An OAuth 2.0 Client ID is a string of characters,\n something like this:\n\n `780816631155-gbvyo1o7r2pn95qc4ei9d61io4uh48hl.apps.googleusercontent.com`\n\nTry the REST API in the OAuth Playground\n----------------------------------------\n\nThe OAuth Playground is the easiest way to familiarize yourself with the\nFitness REST API by submitting HTTP requests and observing the responses before\nyou write any client code.\n\nTo authorize the Fitness REST API in the OAuth Playground:\n\n1. Go to the [OAuth Playground](https://developers.google.com/oauthplayground/).\n2. Under **Step 1 Select \\& authorize APIs** , expand **Fitness v1** and select the Fitness scopes to use.\n3. Click the **Authorize APIs** button, select the Google API Console project to use, and click **Allow** when prompted. You will be able to access and modify data associated with the selected Google API Console account.\n4. Click the **Exchange authorization code for tokens** button. The OAuth Playground automatically includes this header in the `Authorization:` request header when you submit HTTP requests. Note that the access token will expire after 60 minutes (3600 seconds).\n\n### Submit HTTP requests\n\nThe following examples demonstrate how to send HTTP requests to list all\navailable data sources, and to create a new data source. For the Fitness REST\nAPI, the URI format is:\n\n`https://www.googleapis.com/fitness/v1/`\u003cvar class=\"apiparam\" translate=\"no\"\u003eresourcePath\u003c/var\u003e`?`\u003cvar class=\"apiparam\" translate=\"no\"\u003eparameters\u003c/var\u003e\n\n**To list all available data sources:**\n\n1. In **HTTP Method** , select **GET**.\n2. In **Request URI** , enter `https://www.googleapis.com/fitness/v1/users/me/dataSources`\n3. Click **Send the request**.\n\nThe request and the response appear on the right side of the page. If the\nrequest is successful, the response shows the data source from the previous\nexample in JSON format.\n\n**To create a data source:**\n\n1. In **HTTP Method** , select **POST**.\n2. In **Request URI** , enter `https://www.googleapis.com/fitness/v1/users/me/dataSources`\n3. Click **Enter request body**.\n4. In the **Request Body** window, copy and paste the following JSON:\n\n {\n \"dataStreamName\": \"MyDataSource\",\n \"type\": \"derived\",\n \"application\": {\n \"detailsUrl\": \"http://example.com\",\n \"name\": \"Foo Example App\",\n \"version\": \"1\"\n },\n \"dataType\": {\n \"field\": [\n {\n \"name\": \"steps\",\n \"format\": \"integer\"\n }\n ],\n \"name\": \"com.google.step_count.delta\"\n },\n \"device\": {\n \"manufacturer\": \"Example Manufacturer\",\n \"model\": \"ExampleTablet\",\n \"type\": \"tablet\",\n \"uid\": \"1000001\",\n \"version\": \"1\"\n }\n }\n\n5. In the **Request Body** window, click **Close**.\n\n6. Click **Send the request**.\n\nThe request and the response appear on the right side of the page. The request\nincludes the OAuth access token in the `Authorization` header:\n\n`Authorization: Bearer ya29.`\u003cvar class=\"apiparam\" translate=\"no\"\u003eOAuthTokenValue\u003c/var\u003e\n\nIf the request is successful, the first line of the response is:\n\n`HTTP/1.1 200 OK`\n\nUse cURL to access the Fit REST API\n-----------------------------------\n\nYou can use the [cURL](https://curl.haxx.se/) command line tool to access the\nFit REST API. You will need an OAuth access token to make requests\nusing cURL (see the preceding [instructions](#try_the_rest_api_in_the_oauth_playground)).\nNote that access tokens expire after an hour. The following example shows a\nsimple bash script to list all data sources. \n\n```bash\n#!/bin/bash\nACCESS_TOKEN=\"\"\ncurl \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $ACCESS_TOKEN\" \\\n https://www.googleapis.com/fitness/v1/users/me/dataSources\n```\n\nNext steps\n----------\n\nTo learn more about the REST API, see these pages:\n\n- [Fitness Data Types](/fit/rest/v1/data-types)\n- [Sessions](/fit/rest/v1/sessions)\n- [How to Record a Workout](/fit/rest/v1/workout)"]]