Google Fit REST API を含む Google Fit API は、2026 年に非推奨になります。2024 年 5 月 1 日より、デベロッパーはこれらの API の使用を登録できなくなります。
移行先の API またはプラットフォームの手順については、ヘルスコネクトの移行ガイドをご覧ください。ヘルスコネクトと Google Fit API および Fitbit Web API の比較については、ヘルスコネクトの比較ガイドをご覧ください。
ヘルスコネクトの詳細と API との統合方法をご覧ください。
Users.dataSources.datasets: patch
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
データポイントをデータセットに追加します。このデータセットを事前に作成する必要はありません。
後続の呼び出しで、指定されたデータセット内のすべてのポイントが返されます
このデータセットを取得します。データポイントは複数のデータセットに属することができます。
この方法では、パッチのセマンティクスは使用しません。提供されるデータポイントは、
挿入されるだけで、既存のデータは置き換えられません。
こちらから今すぐお試しください。
リクエスト
HTTP リクエスト
PATCH https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId/datasets/datasetId
パラメータ
パラメータ名 |
値 |
説明 |
パスパラメータ |
dataSourceId |
string |
データセットを作成したデータソースのデータ ストリーム ID。
|
datasetId |
string |
このフィールドは使用されないため、省略してもかまいません。
|
userId |
string |
識別された人物のデータセットにパッチを適用する。me を使用して
表示されます。現時点でサポートされているのは me のみです。
|
承認
このリクエストは、少なくとも次のうち 1 つのスコープによる承認が必要です。
範囲 |
https://www.googleapis.com/auth/fitness.activity.write |
https://www.googleapis.com/auth/fitness.location.write |
https://www.googleapis.com/auth/fitness.body.write |
https://www.googleapis.com/auth/fitness.nutrition.write |
https://www.googleapis.com/auth/fitness.blood_pressure.write |
https://www.googleapis.com/auth/fitness.blood_glucose.write |
https://www.googleapis.com/auth/fitness.oxygen_saturation.write |
https://www.googleapis.com/auth/fitness.body_temperature.write |
https://www.googleapis.com/auth/fitness.reproductive_health.write |
詳細については、認証と認可のページをご覧ください。
リクエスト本文
リクエストの本文には、パッチのセマンティクスのルールに従って、次のプロパティを使用して Users.dataSources.datasets リソースの関連する部分を指定します。
プロパティ名 |
値 |
説明 |
メモ |
必須プロパティ |
dataSourceId |
string |
このデータセットのポイントを作成したデータソースのデータ ストリーム ID。 |
|
maxEndTimeNs |
long |
データセットの部分表現であるすべてのデータポイントの最大の終了時刻。時間はエポックからのナノ秒単位です。データセット識別子の 2 番目の部分とも一致する必要があります。 |
|
minStartTimeNs |
long |
データセットの部分表現であるすべてのデータポイントの最小開始時刻。時間はエポックからのナノ秒単位です。データセット識別子の最初の部分とも一致する必要があります。 |
|
point[] |
list |
データセットに含まれるデータポイントの部分的なリスト。endTimeNanos で並べ替えられています。このリストは、小さなデータセットを取得するときは完全であるとみなされます。また、データセットにパッチを適用するときや、大きすぎて 1 つのレスポンスに含めることができないデータセットを取得するときには部分的なリストとみなされます。 |
|
point[].dataTypeName |
string |
このデータポイントの値の形式を定義するデータ型。 |
|
point[].endTimeNanos |
long |
このデータポイントで表される間隔の終了時間(エポックからのナノ秒単位)。 |
|
point[].startTimeNanos |
long |
このデータポイントで表される間隔の開始時刻。エポックからのナノ秒単位で指定します。 |
|
point[].value[] |
list |
データポイントの各データ型フィールドの値。データ型フィールドに対応する各値は、データソースで指定されたデータ型でフィールドがリストされるのと同じ順序で出現することが期待されます。
データソースの型フィールド内にある列挙値に応じて、整数フィールドと浮動小数点フィールドのいずれか 1 つのみが入力されます。
|
|
試してみよう:
以下の API Explorer を使用して、ライブデータに対してこのメソッドを呼び出し、レスポンスを確認してください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 2025-07-25 UTC。"],[[["\u003cp\u003eAdds data points to a new or existing dataset within Google Fit, returning all dataset points upon retrieval.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes an insert-only approach, without replacing pre-existing data.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with specific scopes, such as \u003ccode\u003ehttps://www.googleapis.com/auth/fitness.activity.write\u003c/code\u003e, for data access.\u003c/p\u003e\n"],["\u003cp\u003eThe request body necessitates properties like \u003ccode\u003edataSourceId\u003c/code\u003e, \u003ccode\u003emaxEndTimeNs\u003c/code\u003e, \u003ccode\u003eminStartTimeNs\u003c/code\u003e, and an array of data points (\u003ccode\u003epoint[]\u003c/code\u003e) with corresponding values.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful requests return a \u003ccode\u003eUsers.dataSources.datasets\u003c/code\u003e resource containing the updated dataset information.\u003c/p\u003e\n"]]],[],null,["# Users.dataSources.datasets: patch\n\n| **Note:** Requires [authorization](#auth).\n\nAdds data points to a dataset. The dataset need not be previously created.\nAll points within the given dataset will be returned with subsquent calls\nto retrieve this dataset. Data points can belong to more than one dataset.\n\n\u003cbr /\u003e\n\n\nThis method does not use patch semantics: the data points provided are\nmerely inserted, with no existing data replaced.\n[Try it now](#try-it).\n\nRequest\n-------\n\n### HTTP request\n\n```\nPATCH https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId/datasets/datasetId\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| **Path parameters** |||\n| `dataSourceId` | `string` | The data stream ID of the data source that created the dataset. |\n| `datasetId` | `string` | This field is not used, and can be safely omitted. |\n| `userId` | `string` | Patch a dataset for the person identified. Use `me` to indicate the authenticated user. Only `me` is supported at this time. |\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes:\n\n| Scope |\n|---------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/fitness.activity.write` |\n| `https://www.googleapis.com/auth/fitness.location.write` |\n| `https://www.googleapis.com/auth/fitness.body.write` |\n| `https://www.googleapis.com/auth/fitness.nutrition.write` |\n| `https://www.googleapis.com/auth/fitness.blood_pressure.write` |\n| `https://www.googleapis.com/auth/fitness.blood_glucose.write` |\n| `https://www.googleapis.com/auth/fitness.oxygen_saturation.write` |\n| `https://www.googleapis.com/auth/fitness.body_temperature.write` |\n| `https://www.googleapis.com/auth/fitness.reproductive_health.write` |\n\nFor more information, see the [authentication and authorization](/fit/rest/v1/authorization) page.\n\n### Request body\n\nIn the request body, supply the relevant portions of a [Users.dataSources.datasets resource](/fit/rest/v1/reference/users/dataSources/datasets#resource), according to the rules of patch semantics, with the following properties:\n\n| Property name | Value | Description | Notes |\n|--------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|\n| **Required Properties** ||||\n| `dataSourceId` | `string` | The data stream ID of the data source that created the points in this dataset. | |\n| `maxEndTimeNs` | `long` | The largest end time of all data points in this possibly partial representation of the dataset. Time is in nanoseconds from epoch. This should also match the second part of the dataset identifier. | |\n| `minStartTimeNs` | `long` | The smallest start time of all data points in this possibly partial representation of the dataset. Time is in nanoseconds from epoch. This should also match the first part of the dataset identifier. | |\n| `point[]` | `list` | A partial list of data points contained in the dataset, ordered by endTimeNanos. This list is considered complete when retrieving a small dataset and partial when patching a dataset or retrieving a dataset that is too large to include in a single response. | |\n| point[].`dataTypeName` | `string` | The data type defining the format of the values in this data point. | |\n| point[].`endTimeNanos` | `long` | The end time of the interval represented by this data point, in nanoseconds since epoch. | |\n| point[].`startTimeNanos` | `long` | The start time of the interval represented by this data point, in nanoseconds since epoch. | |\n| point[].`value[]` | `list` | Values of each data type field for the data point. It is expected that each value corresponding to a data type field will occur in the same order that the field is listed with in the data type specified in a data source. Only one of integer and floating point fields will be populated, depending on the format enum value within data source's type field. | |\n\nResponse\n--------\n\nIf successful, this method returns a [Users.dataSources.datasets resource](/fit/rest/v1/reference/users/dataSources/datasets#resource) in the response body.\n\nTry it!\n-------\n\n\nUse the APIs Explorer below to call this method on live data and see the response."]]