Users.sessions: list

列出先前建立的工作階段。立即試用

要求

HTTP 要求

GET https://www.googleapis.com/fitness/v1/users/userId/sessions

參數

參數名稱 說明
路徑參數
userId string 列出指定對象的工作階段。使用 me 表示已驗證的使用者。目前僅支援 me
選用查詢參數
activityType integer 如果非空白,則只能傳回含有這些活動類型的工作階段。
endTime string RFC3339 時間戳記。 回應中只會列出開始和結束時間之間的工作階段。如果省略這個時間,但已指定 startTime,系統會傳回從 startTime 到結束時間的所有工作階段。
includeDeleted boolean 如果值為 true,如果同時省略 startTimeendTime,系統會傳回工作階段刪除作業。
pageToken string 用於漸進式同步處理的接續權杖。如要取得下一個變更項目,請將這個參數設為先前回應的 nextPageToken 值。如未指定開始或結束時間,系統會忽略網頁符記。如未指定開始時間、結束時間和指定網頁權杖,系統會傳回過去 30 天內修改的工作階段。
startTime string RFC3339 時間戳記。 回應中只會列出開始和結束時間之間的工作階段。如果省略這個時間,但已指定 endTime,系統會傳回從開始時間到 endTime 的所有工作階段。

授權

此要求需要至少具備下列其中一個範圍的授權:

範圍
https://www.googleapis.com/auth/fitness.activity.read
https://www.googleapis.com/auth/fitness.activity.write
https://www.googleapis.com/auth/fitness.location.read
https://www.googleapis.com/auth/fitness.location.write
https://www.googleapis.com/auth/fitness.body.read
https://www.googleapis.com/auth/fitness.body.write
https://www.googleapis.com/auth/fitness.nutrition.read
https://www.googleapis.com/auth/fitness.nutrition.write
https://www.googleapis.com/auth/fitness.blood_pressure.read
https://www.googleapis.com/auth/fitness.blood_pressure.write
https://www.googleapis.com/auth/fitness.blood_glucose.read
https://www.googleapis.com/auth/fitness.blood_glucose.write
https://www.googleapis.com/auth/fitness.oxygen_saturation.read
https://www.googleapis.com/auth/fitness.oxygen_saturation.write
https://www.googleapis.com/auth/fitness.body_temperature.read
https://www.googleapis.com/auth/fitness.body_temperature.write
https://www.googleapis.com/auth/fitness.reproductive_health.read
https://www.googleapis.com/auth/fitness.reproductive_health.write

詳情請參閱驗證與授權頁面。

要求主體

此方法不會提供要求主體。

回應

如果成功的話,這個方法會傳回回應內文,其結構如下:

{
  "session": [
    {
      "id": string,
      "name": string,
      "description": string,
      "startTimeMillis": long,
      "endTimeMillis": long,
      "modifiedTimeMillis": long,
      "application": {
        "packageName": string,
        "version": string,
        "detailsUrl": string,
        "name": string
      },
      "activityType": integer,
      "activeTimeMillis": long
    }
  ],
  "deletedSession": [
    {
      "id": string,
      "name": string,
      "description": string,
      "startTimeMillis": long,
      "endTimeMillis": long,
      "modifiedTimeMillis": long,
      "application": {
        "packageName": string,
        "version": string,
        "detailsUrl": string,
        "name": string
      },
      "activityType": integer,
      "activeTimeMillis": long
    }
  ],
  "nextPageToken": string,
  "hasMoreData": boolean
}
屬性名稱 說明 附註
session[] list 結束時間介於要求的 startTimeendTime 之間。

session[].id string 用戶端產生的 ID,在特定使用者擁有的所有工作階段中都不會重複。
session[].name string 使用者可理解的工作階段名稱。
session[].description string 工作階段說明。
session[].startTimeMillis long 開始時間,以毫秒為單位 (自 Epoch 起算),
session[].endTimeMillis long 結束時間 (以毫秒為單位,自 Epoch 起算,含首尾)。
session[].modifiedTimeMillis long 表示工作階段上次修改時間的時間戳記。
session[].application nested object 建立工作階段的應用程式。
session[].application.packageName string 這個應用程式的套件名稱。建立 Android 應用程式時會用來當做專屬 ID,但 REST 用戶端無法指定。REST 用戶端的開發人員 ID 號碼會反映在資料來源資料串流 (而非 packageName) 中。
session[].application.version string 應用程式的版本。只要應用程式變更了會影響資料運算的方式,您就應該更新這個欄位。
session[].application.detailsUrl string 選用的 URI 可用來連結應用程式。
session[].application.name string 這個應用程式的名稱。對 REST 用戶端來說,這是必要步驟,但我們不會強制使用這個名稱。它可供其他開發人員辨識,以便找出哪個 REST 建立應用程式或資料來源。
session[].activityType integer 這個工作階段代表的活動類型。
deletedSession[] list 如果請求中的 includeDeleted 設為 true,且省略了 startTimeendTime,這將包括自上次同步處理後遭刪除的工作階段。
deletedSession[].id string 用戶端產生的 ID,在特定使用者擁有的所有工作階段中都不會重複。
deletedSession[].name string 使用者可理解的工作階段名稱。
deletedSession[].description string 工作階段說明。
deletedSession[].startTimeMillis long 開始時間,以毫秒為單位 (自 Epoch 起算),
deletedSession[].endTimeMillis long 結束時間 (以毫秒為單位,自 Epoch 起算,含首尾)。
deletedSession[].modifiedTimeMillis long 表示工作階段上次修改時間的時間戳記。
deletedSession[].application nested object 建立工作階段的應用程式。
deletedSession[].application.packageName string 這個應用程式的套件名稱。建立 Android 應用程式時會用來當做專屬 ID,但 REST 用戶端無法指定。REST 用戶端的開發人員 ID 號碼會反映在資料來源資料串流 (而非 packageName) 中。
deletedSession[].application.version string 應用程式的版本。只要應用程式變更了會影響資料運算的方式,您就應該更新這個欄位。
deletedSession[].application.detailsUrl string 選用的 URI 可用來連結應用程式。
deletedSession[].application.name string 這個應用程式的名稱。對 REST 用戶端來說,這是必要步驟,但我們不會強制使用這個名稱。它可供其他開發人員辨識,以便找出哪個 REST 建立應用程式或資料來源。
deletedSession[].activityType integer 這個工作階段代表的活動類型。
nextPageToken string 用於同步處理進一步變更的同步處理權杖。只有在要求中省略 startTimeendTime 時,才會提供這個值。
session[].activeTimeMillis long 工作階段有效時間。雖然 start_time_millis 和 end_time_millis 定義了整個工作階段時間,但活動時間可以較短,而 Active_time_millis 有效。如果已知工作階段期間的閒置時間,系統也應透過 com.google.activity.Segment 資料點與 STILL 活動值插入

deletedSession[].activeTimeMillis long 工作階段有效時間。雖然 start_time_millis 和 end_time_millis 定義了整個工作階段時間,但活動時間可以較短,而 Active_time_millis 有效。如果已知工作階段期間的閒置時間,系統也應透過 com.google.activity.Segment 資料點與 STILL 活動值插入

hasMoreData boolean 旗標,表示伺服器有更多資料可供轉移。請勿使用這個欄位。伺服器絕對不會填入回應。

試試看!

使用 APIs Explorer 針對即時資料呼叫這個方法,並查看回應。