Bekerja dengan {i>Dataset

Fitness REST API memungkinkan Anda membuat, mendapatkan, dan menambahkan poin ke set data. J mewakili sekumpulan {i>data point<i} dari sumber data tertentu.

{i>Dataset<i} direpresentasikan oleh Users.dataSources.datasets resource Anda

Menambahkan poin ke {i>dataset<i}

Contoh ini menunjukkan cara menambahkan sepuluh titik delta jumlah langkah baru ke set data yang sebelumnya kosong. Contoh ini mengasumsikan bahwa Anda telah membuat sumber data seperti yang dijelaskan dalam Mengelola Sumber Data.

Metode HTTP
PATCH
URL Permintaan
https://www.googleapis.com/fitness/v1/users/me/dataSources/
derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001
/datasets/1397513334728708316-1397515179728708316
Isi permintaan
{
  "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
        }
      ]
    }
  ]
}

Respons

Responsnya adalah kode status 200 OK. Isi respons berisi array dengan representasi JSON dari semua titik yang berhasil disisipkan.

Perintah curl
$ 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"

Mendapatkan set data

Contoh ini menunjukkan cara mendapatkan konten set data.

Metode HTTP
DAPATKAN
URL Permintaan
https://www.googleapis.com/fitness/v1/users/me/dataSources/
derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001
/datasets/1397513334728708316-1397515179728708316
Isi permintaan
Tidak ada.
Respons
Jika set data ada, responsnya adalah kode status 200 OK. Respons berisi representasi JSON dari set data.
Perintah 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/dataSources/derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001/datasets/1397513334728708316-1397515179728708316"