Freebusy: query

傳回一組日曆的有空/忙碌資訊。 立即試用

要求

HTTP 要求

POST https://www.googleapis.com/calendar/v3/freeBusy

授權

這項要求允許至少具有下列其中一項範圍的授權:

範圍
https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/auth/calendar

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

要求主體

在要求主體中,以下列結構提供資料:

{
  "timeMin": datetime,
  "timeMax": datetime,
  "timeZone": string,
  "groupExpansionMax": integer,
  "calendarExpansionMax": integer,
  "items": [
    {
      "id": string
    }
  ]
}
資源名稱 說明 附註
timeMin datetime 查詢的間隔開始時間,符合 RFC3339 的格式。
timeMax datetime 查詢的間隔結尾,格式為 RFC3339
timeZone string 回應中使用的時區。選用設定。預設值為世界標準時間。
groupExpansionMax integer 單一群組要提供的日曆 ID 數量上限。選用設定。如果群組的成員數量超過這個值,系統就會傳回錯誤。最大值為 100。
calendarExpansionMax integer 要提供 FreeBusy 資訊的日曆數量上限。選用設定。最大值為 50。
items[] list 要查詢的日曆和/或群組清單。
items[].id string 日曆或群組的 ID。

回應

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

{
  "kind": "calendar#freeBusy",
  "timeMin": datetime,
  "timeMax": datetime,
  "groups": {
    (key): {
      "errors": [
        {
          "domain": string,
          "reason": string
        }
      ],
      "calendars": [
        string
      ]
    }
  },
  "calendars": {
    (key): {
      "errors": [
        {
          "domain": string,
          "reason": string
        }
      ],
      "busy": [
        {
          "start": datetime,
          "end": datetime
        }
      ]
    }
  }
}
屬性名稱 說明 附註
kind string 資源類型 (「calendar#freeBusy」)。
timeMin datetime 間隔的開始時間。
timeMax datetime 間隔的結束時間。
groups object 群組擴展。
groups.(key) nested object 這個群組的成員日曆清單。
groups.(key).errors[] list 選用的錯誤 (如果群組計算失敗)。
groups.(key).errors[].domain string 錯誤的網域或廣泛類別。
groups.(key).errors[].reason string 造成錯誤的具體原因。可能的值包括:
  • groupTooBig」:要求的使用者群組對單一查詢而言太大。
  • tooManyCalendarsRequested」:單一查詢要求的日曆數量過多。
  • notFound」:找不到要求的資源。
  • internalError」:API 服務發生內部錯誤。
日後可能會新增其他錯誤類型,因此用戶端應妥善處理這份清單未包含的其他錯誤狀態。
groups.(key).calendars[] list 群組中的日曆 ID 清單。
calendars object 日曆的有空/忙碌資訊清單。
calendars.(key) nested object 將單一日曆的有空/忙碌狀態展開。
calendars.(key).errors[] list 選用的錯誤 (如果日曆計算作業失敗)。
calendars.(key).errors[].domain string 錯誤的網域或廣泛類別。
calendars.(key).errors[].reason string 造成錯誤的具體原因。可能的值包括:
  • groupTooBig」:要求的使用者群組對單一查詢而言太大。
  • tooManyCalendarsRequested」:單一查詢要求的日曆數量過多。
  • notFound」:找不到要求的資源。
  • internalError」:API 服務發生內部錯誤。
日後可能會新增其他錯誤類型,因此用戶端應妥善處理這份清單未包含的其他錯誤狀態。
calendars.(key).busy[] list 應將此日曆視為忙碌的時間範圍清單。
calendars.(key).busy[].start datetime 時間範圍的開始時間 (含)。
calendars.(key).busy[].end datetime 時間範圍的結束 (不含)。

試試看!

您可以使用下方的 APIs Explorer,針對即時資料呼叫這個方法,然後查看回應。