डेटासेट के साथ काम करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Fitness REST API से आपको डेटासेट बनाने, हासिल करने, और उसमें पॉइंट जोड़ने की सुविधा मिलती है. ऐप्लिकेशन
डेटासेट, किसी खास डेटा सोर्स के डेटा पॉइंट का सेट दिखाता है.
डेटासेट को इस तरीके से दिखाया जाता है:
Users.dataSources.datasets
संसाधन.
डेटासेट में पॉइंट जोड़ना
यह उदाहरण दिखाता है कि किसी
डेटासेट खाली था. इस उदाहरण में माना गया है कि आपने डेटा सोर्स बनाया है
जैसा कि डेटा सोर्स मैनेज करना में बताया गया है.
- एचटीटीपी तरीका
- पैच
- URL का अनुरोध करें
https://www.googleapis.com/fitness/v1/users/me/dataSources/
derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001
/datasets/1397513334728708316-1397515179728708316
- अनुरोध का मुख्य भाग
{
"dataSourceId":
"derived:com.google.step_count.delta:1234567890:Example Manufacturer:ExampleTablet:1000001",
"maxEndTimeNs": 1397515179728708316,
"minStartTimeNs": 1397513334728708316,
"point": [
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397513365565713993,
"originDataSourceId": "",
"startTimeNanos": 1397513334728708316,
"value": [
{
"intVal": 8
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397513675197854515,
"originDataSourceId": "",
"startTimeNanos": 1397513530098955298,
"value": [
{
"intVal": 3
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397513764101240710,
"originDataSourceId": "",
"startTimeNanos": 1397513817073528237,
"value": [
{
"intVal": 6
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397513938674093579,
"originDataSourceId": "",
"startTimeNanos": 1397514015761859752,
"value": [
{
"intVal": 5
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397514106400006675,
"originDataSourceId": "",
"startTimeNanos": 1397514181893785805,
"value": [
{
"intVal": 4
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397514304850163634,
"originDataSourceId": "",
"startTimeNanos": 1397514356883524220,
"value": [
{
"intVal": 16
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397514518794639297,
"originDataSourceId": "",
"startTimeNanos": 1397514526864527756,
"value": [
{
"intVal": 13
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397514741275742506,
"originDataSourceId": "",
"startTimeNanos": 1397514626480314270,
"value": [
{
"intVal": 18
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397514813435152213,
"originDataSourceId": "",
"startTimeNanos": 1397514839292833196,
"value": [
{
"intVal": 17
}
]
},
{
"dataTypeName": "com.google.step_count.delta",
"endTimeNanos": 1397515179728708316,
"originDataSourceId": "",
"startTimeNanos": 1397515170565969137,
"value": [
{
"intVal": 11
}
]
}
]
}
- जवाब
रिस्पॉन्स, एक 200 OK
स्टेटस कोड है. जवाब के मुख्य हिस्से में एक अरे होता है
शामिल किए गए सभी पॉइंट को JSON फ़ॉर्मैट में दिखाया गया है.
- कर्ल निर्देश
$ curl --header "Authorization: Bearer ya29.1.yourtokenvalue" -X PATCH \
--header "Content-Type: application/json;encoding=utf-8" -d @addpoints.json \
"https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001/datasets/1397513334728708316-1397515179728708316"
डेटासेट पाना
इस उदाहरण में, डेटासेट का कॉन्टेंट पाने का तरीका बताया गया है.
- एचटीटीपी तरीका
- पाएं
- URL का अनुरोध करें
https://www.googleapis.com/fitness/v1/users/me/dataSources/
derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001
/datasets/1397513334728708316-1397515179728708316
- अनुरोध का मुख्य भाग
- कोई नहीं.
- जवाब
- अगर डेटासेट मौजूद है, तो रिस्पॉन्स के तौर पर
200 OK
स्टेटस कोड दिखेगा. जवाब
मुख्य भाग में डेटासेट को JSON फ़ॉर्मैट में दिखाया गया है.
- कर्ल निर्देश
$ 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/dataSources/derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001/datasets/1397513334728708316-1397515179728708316"
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-31 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-31 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe Fitness REST API allows for the creation, retrieval, and updating of datasets, which represent data points from specific sources.\u003c/p\u003e\n"],["\u003cp\u003eDatasets are identified and managed using the \u003ccode\u003eUsers.dataSources.datasets\u003c/code\u003e resource.\u003c/p\u003e\n"],["\u003cp\u003eYou can add data points to a dataset using a PATCH request to the corresponding dataset URL.\u003c/p\u003e\n"],["\u003cp\u003eRetrieving an existing dataset is done with a GET request to the dataset URL.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the "Responsible use of Google Fit" documentation for best practices on handling user data.\u003c/p\u003e\n"]]],[],null,["# Working with Datasets\n\nThe Fitness REST API lets you create, obtain, and add points to datasets. A\ndataset represents a set of data points from a particular data source.\n\nDatasets are represented by the\n[`Users.dataSources.datasets`](/fit/rest/v1/reference/users/dataSources/datasets)\nresource.\n| **Important:** For best practices when managing user data, see [Responsible use of Google Fit](/fit/overview#responsible_use_of_google_fit).\n\nAdd points to a dataset\n-----------------------\n\nThis example demonstrates how to add ten new step count delta points to a\npreviously empty dataset. This example assumes that you created a data source\nas described in [Managing Data Sources](/fit/rest/v1/data-sources).\n\nHTTP method\n: PATCH\n\nRequest URL\n: `https://www.googleapis.com/fitness/v1/users/me/dataSources/` \n **derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001\n /datasets/1397513334728708316-1397515179728708316**\n\nRequest body\n:\n\n {\n \"dataSourceId\":\n \"derived:com.google.step_count.delta:1234567890:Example Manufacturer:ExampleTablet:1000001\",\n \"maxEndTimeNs\": 1397515179728708316,\n \"minStartTimeNs\": 1397513334728708316,\n \"point\": [\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397513365565713993,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397513334728708316,\n \"value\": [\n {\n \"intVal\": 8\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397513675197854515,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397513530098955298,\n \"value\": [\n {\n \"intVal\": 3\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397513764101240710,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397513817073528237,\n \"value\": [\n {\n \"intVal\": 6\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397513938674093579,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397514015761859752,\n \"value\": [\n {\n \"intVal\": 5\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397514106400006675,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397514181893785805,\n \"value\": [\n {\n \"intVal\": 4\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397514304850163634,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397514356883524220,\n \"value\": [\n {\n \"intVal\": 16\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397514518794639297,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397514526864527756,\n \"value\": [\n {\n \"intVal\": 13\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397514741275742506,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397514626480314270,\n \"value\": [\n {\n \"intVal\": 18\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397514813435152213,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397514839292833196,\n \"value\": [\n {\n \"intVal\": 17\n }\n ]\n },\n {\n \"dataTypeName\": \"com.google.step_count.delta\",\n \"endTimeNanos\": 1397515179728708316,\n \"originDataSourceId\": \"\",\n \"startTimeNanos\": 1397515170565969137,\n \"value\": [\n {\n \"intVal\": 11\n }\n ]\n }\n ]\n }\n\nResponse\n\n: The response is a `200 OK` status code. The response body contains an array\n with JSON representations of all the points that were inserted successfully.\n\nCurl command\n:\n\n ```\n $ curl --header \"Authorization: Bearer ya29.1.yourtokenvalue\" -X PATCH \\\n --header \"Content-Type: application/json;encoding=utf-8\" -d @addpoints.json \\\n \"https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001/datasets/1397513334728708316-1397515179728708316\"\n ```\n\nGet a dataset\n-------------\n\nThis example demonstrates how to get the contents of a dataset.\n\nHTTP method\n: GET\n\nRequest URL\n: `https://www.googleapis.com/fitness/v1/users/me/dataSources/` \n **derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001\n /datasets/1397513334728708316-1397515179728708316**\n\nRequest body\n: None.\n\nResponse\n: If the dataset exists, the response is a `200 OK` status code. The response\n body contains a JSON representation of the dataset.\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/dataSources/derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001/datasets/1397513334728708316-1397515179728708316\"\n ```"]]