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 。
|
授权
此请求需要获得以下至少一个范围的授权:
范围 |
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 |
数据集的这种可能的部分表示形式中所有数据点的最大结束时间。时间以纳秒为单位,从新纪元开始计算。这也应与数据集标识符的第二部分相匹配。 |
|
minStartTimeNs |
long |
数据集的这种可能的部分表示形式中所有数据点的最短开始时间。时间以纳秒为单位,从新纪元开始计算。这也应与数据集标识符的第一部分相匹配。 |
|
point[] |
list |
数据集中包含的部分数据点列表,按 endTimeNanos 排序。如果检索的是小型数据集,则此列表被视为完整;而对于修补数据集或检索的数据集因过大而无法包含在单个响应中时,此列表会被视为部分内容。 |
|
point[].dataTypeName |
string |
用于定义此数据点中值格式的数据类型。 |
|
point[].endTimeNanos |
long |
此数据点表示的间隔的结束时间(以纳秒为单位,自纪元开始)。 |
|
point[].startTimeNanos |
long |
此数据点表示的间隔的开始时间(以纳秒为单位,自纪元开始)。 |
|
point[].value[] |
list |
数据点的每个数据类型字段的值。与数据类型字段对应的每个值的出现顺序应与在数据源中指定的数据类型中列出的字段顺序相同。
系统将仅填充整数和浮点字段中的一个,具体取决于数据源的类型字段中的格式枚举值。
|
|
试试看!
使用下面的 API Explorer 对实际数据调用此方法,然后查看响应。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\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."]]