Weather - Get Current Conditions

使用取得目前的天氣狀況。

Get Current Conditions API 是 HTTP GET 要求,會針對指定的座標位置傳回詳細的目前天氣狀況,例如濕度、溫度和風力。 此外,也可以擷取特定位置過去 6 或 24 小時的觀察資料。 回應傳回的基本資訊包括觀察日期和時間、天氣狀況的簡短描述、天氣圖示、氣象指標旗標和溫度等詳細數據。 此外,也會傳回其他詳細資料,例如 RealFeel™ 溫度和紫外線指數。 如需詳細資訊,請參閱 要求即時天氣數據

GET https://atlas.microsoft.com/weather/currentConditions/json?api-version=1.1&query={query}
GET https://atlas.microsoft.com/weather/currentConditions/json?api-version=1.1&query={query}&unit={unit}&details={details}&duration={duration}&language={language}

URI 參數

名稱 位於 必要 類型 Description
format
path True

JsonFormat

所需的回應格式。 僅支援 json 格式。

api-version
query True

string

Azure 地圖服務 API 的版本號碼。

query
query True

number[]

指定為逗號分隔字串的適用查詢,後面接著經度,例如 “47.641268,-122.125679”。

details
query

string

傳回目前條件的完整詳細數據。 可用的值為

  • true - 傳回完整詳細數據。 根據預設,會傳回所有詳細數據。
  • false - 傳回目前條件數據的截斷版本,其中包括觀察日期時間、天氣片語、圖示代碼、濕度指標旗標和溫度。
duration
query

integer

傳回天氣狀況的時間範圍。 根據預設,會傳回最新的天氣狀況。 預設值為 0。 支援的值包括:

  • 0 - 傳回最新的天氣狀況。
  • 6 - 傳回過去 6 小時內的天氣狀況。
  • 24 - 傳回過去 24 小時內的天氣狀況。
language
query

string

應該傳回搜尋結果的語言。 應該是其中一個支援的 IETF 語言標記,不區分大小寫。 當特定欄位無法使用指定語言的數據時,會使用預設語言。

如需詳細資訊,請參閱 支援的語言

unit
query

WeatherDataUnit

指定以度量單位或英制單位傳回數據。 預設值為計量。

要求標頭

名稱 必要 類型 Description
x-ms-client-id

string

指定哪個帳戶與 Microsoft Entra ID 安全性模型搭配使用。 它代表 Azure 地圖服務 帳戶的唯一標識符,而且可以從 Azure 地圖服務 管理平面帳戶 API 擷取。 若要在 Azure 地圖服務 中使用 Microsoft Entra ID 安全性,請參閱下列文章以取得指引。

回應

名稱 類型 Description
200 OK

CurrentConditionsResult

確定

Other Status Codes

ErrorResponse

發生意外錯誤。

安全性

AADToken

這些是 Microsoft Entra OAuth 2.0 流程。 與 Azure 角色型存取控制配對時,可用來控制對 Azure 地圖服務 REST API 的存取。 Azure 角色型訪問控制可用來指定一或多個 Azure 地圖服務 資源帳戶或子資源的存取權。 任何使用者、群組或服務主體都可以透過內建角色或由一或多個許可權組成的自定義角色來授與存取權,以 Azure 地圖服務 REST API。

若要實作案例,建議您檢視 驗證概念。 總而言之,此安全性定義會透過能夠針對特定 API 和範圍進行訪問控制的物件,提供將應用程式模型化 () 的解決方案。

備註

  • 此安全性定義需要使用x-ms-client-id 標頭來指出應用程式要求存取權 Azure 地圖服務 資源。 這可以從 地圖管理 API 取得。

Authorization URL專屬於 Azure 公用雲端實例。 主權雲端具有唯一的授權 URL 和 Microsoft Entra ID 設定。 * 透過 Azure 入口網站、PowerShell、CLI、Azure SDK 或 REST API,從 Azure 管理平面設定 Azure 角色型存取控制。 * Azure 地圖服務 Web SDK 的使用方式允許針對多個使用案例設定應用程式設定。

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名稱 Description
https://atlas.microsoft.com/.default https://atlas.microsoft.com/.default

subscription-key

這是在 Azure 入口網站 或使用PowerShell、CLI、Azure SDK 或 REST API Create Azure 地圖服務 帳戶時所佈建的共享密鑰。

使用此金鑰,任何應用程式都可以存取所有 REST API。 換句話說,此金鑰可作為發行所在帳戶中的主要金鑰。

對於公開的應用程式,我們建議使用機密用戶端應用程式方法來存取 Azure 地圖服務 REST API,以便安全地儲存您的密鑰。

Type: apiKey
In: query

SAS Token

這是透過 Azure 管理平面透過 Azure 入口網站、PowerShell、CLI、Azure SDK 或 REST API,從 Azure 地圖服務 資源上的列出 SAS 作業建立的共用存取簽章令牌。

使用此令牌時,任何應用程式都有權使用 Azure 角色型訪問控制進行存取,並更精細地控制到期、速率和區域 (特定令牌的使用) 。 換句話說,SAS 令牌可用來允許應用程式以比共用密鑰更安全的方式來控制存取。

對於公開的應用程式,我們建議在 地圖帳戶資源 上設定允許的來源特定清單,以限制轉譯濫用,並定期更新 SAS 令牌。

Type: apiKey
In: header

範例

Successfully retrieve detailed current weather conditions for a given coordinate location

Sample Request

GET https://atlas.microsoft.com/weather/currentConditions/json?api-version=1.1&query=47.641268,-122.125679

Sample Response

{
  "results": [
    {
      "dateTime": "2019-11-14T15:08:00-08:00",
      "phrase": "Cloudy",
      "iconCode": 7,
      "hasPrecipitation": false,
      "isDayTime": true,
      "temperature": {
        "value": 13.7,
        "unit": "C",
        "unitType": 17
      },
      "realFeelTemperature": {
        "value": 13.6,
        "unit": "C",
        "unitType": 17
      },
      "realFeelTemperatureShade": {
        "value": 13.6,
        "unit": "C",
        "unitType": 17
      },
      "relativeHumidity": 75,
      "dewPoint": {
        "value": 9.2,
        "unit": "C",
        "unitType": 17
      },
      "wind": {
        "direction": {
          "degrees": 315,
          "localizedDescription": "NW"
        },
        "speed": {
          "value": 3.6,
          "unit": "km/h",
          "unitType": 7
        }
      },
      "windGust": {
        "speed": {
          "value": 4.9,
          "unit": "km/h",
          "unitType": 7
        }
      },
      "uvIndex": 0,
      "uvIndexPhrase": "Low",
      "visibility": {
        "value": 8,
        "unit": "km",
        "unitType": 6
      },
      "obstructionsToVisibility": "",
      "cloudCover": 95,
      "ceiling": {
        "value": 4359,
        "unit": "m",
        "unitType": 5
      },
      "pressure": {
        "value": 1014.9,
        "unit": "mb",
        "unitType": 14
      },
      "pressureTendency": {
        "localizedDescription": "Steady",
        "code": "S"
      },
      "pastTwentyFourHourTemperatureDeparture": {
        "value": 1.8,
        "unit": "C",
        "unitType": 17
      },
      "apparentTemperature": {
        "value": 16.1,
        "unit": "C",
        "unitType": 17
      },
      "windChillTemperature": {
        "value": 13.9,
        "unit": "C",
        "unitType": 17
      },
      "wetBulbTemperature": {
        "value": 11.4,
        "unit": "C",
        "unitType": 17
      },
      "precipitationSummary": {
        "pastHour": {
          "value": 0.5,
          "unit": "mm",
          "unitType": 3
        },
        "pastThreeHours": {
          "value": 0.8,
          "unit": "mm",
          "unitType": 3
        },
        "pastSixHours": {
          "value": 0.8,
          "unit": "mm",
          "unitType": 3
        },
        "pastNineHours": {
          "value": 0.8,
          "unit": "mm",
          "unitType": 3
        },
        "pastTwelveHours": {
          "value": 0.8,
          "unit": "mm",
          "unitType": 3
        },
        "pastEighteenHours": {
          "value": 0.8,
          "unit": "mm",
          "unitType": 3
        },
        "pastTwentyFourHours": {
          "value": 0.8,
          "unit": "mm",
          "unitType": 3
        }
      },
      "temperatureSummary": {
        "pastSixHours": {
          "minimum": {
            "value": 8.3,
            "unit": "C",
            "unitType": 17
          },
          "maximum": {
            "value": 13.7,
            "unit": "C",
            "unitType": 17
          }
        },
        "pastTwelveHours": {
          "minimum": {
            "value": 5.9,
            "unit": "C",
            "unitType": 17
          },
          "maximum": {
            "value": 13.7,
            "unit": "C",
            "unitType": 17
          }
        },
        "pastTwentyFourHours": {
          "minimum": {
            "value": 5.9,
            "unit": "C",
            "unitType": 17
          },
          "maximum": {
            "value": 13.7,
            "unit": "C",
            "unitType": 17
          }
        }
      }
    }
  ]
}

定義

名稱 Description
CurrentConditions
CurrentConditionsResult
ErrorAdditionalInfo

資源管理錯誤其他資訊。

ErrorDetail

錯誤詳細數據。

ErrorResponse

錯誤回應

IconCode

數值,表示顯示 的 iconPhrase影像。 如需詳細資訊,請參閱 Azure 地圖服務 中的天氣服務

JsonFormat

所需的回應格式。 僅支援 json 格式。

PastHoursTemperature

過去數小時內溫度波動的摘要。

PrecipitationSummary
PressureTendency
TemperatureSummary
UnitType

與所顯示單位類型相關聯的數值標識碼。 可用於單元翻譯。 如需詳細資訊,請參閱 Azure 地圖服務 中的天氣服務

WeatherDataUnit

指定以計量單位或英制單位傳回數據。 預設值為計量。

WeatherUnit

與天氣相關的指定單位特定值。

WindDetails

傳回的風詳細數據包括速度和方向。

WindDirection

風向

CurrentConditions

名稱 類型 Description
apparentTemperature

WeatherUnit

在指定的單位中,由空氣溫度、相對濕度和風速的組合所造成,所感知的室內溫度。

ceiling

WeatherUnit

指定單位中的雲端上限。 上限是最低雲端基底的高度測量。

cloudCover

integer

代表雲端涵蓋的百分比。

dateTime

string

以 ISO 8601 格式顯示的目前觀察日期和時間,例如 2019-10-27T19:39:57-08:00。

dewPoint

WeatherUnit

指定單位中的 dewpoint 溫度。 露點溫度是空氣必須冷卻至的溫度,才能達到飽和度。

hasPrecipitation

boolean

表示存在或不存在的雨。 True 表示存在雨,false 表示沒有雨。

iconCode

IconCode

數值,表示顯示 的 iconPhrase影像。 如需詳細資訊,請參閱 Azure 地圖服務 中的天氣服務

isDayTime

boolean

表示當天的時間。 True 表示 'day',',false 表示 'night。

obstructionsToVisibility

string

有限可見度的原因。

可能的值:

  • A = 繁重的雷雨/殭
  • BD = 垃圾
  • BN = 風沙
  • BS = 噴雪
  • D = 塵封
  • F = 水氣
  • GF = 地面水
  • HZ = haze
  • I = ice
  • IC = 霜淇淋
  • IF = 霜淇淋
  • IP = 霜淇淋
  • IPW = 霜淇淋雨
  • K = 水氣
  • L = drizzle
  • R = 雨
  • RS = 雨/雪
  • RW = 雨雨
  • S = 雪
  • SG = 雪花花
  • SP = 雪花花
  • SW = 雪雨
  • T = 雷電
  • UP = 未定義的雨
  • ZL = 凍結 drizzle
  • ZR = 凍結雨
  • + = 重
  • - = 淺色
pastTwentyFourHourTemperatureDeparture

WeatherUnit

從指定單位前 24 小時前觀察到的溫度離開。

phrase

string

目前天氣條件的片語描述。 以指定的語言顯示。

precipitationSummary

PrecipitationSummary

過去24小時內的雨量摘要。

pressure

WeatherUnit

指定單位中的空氣壓力。

pressureTendency

PressureTendency

空氣壓力變更。

realFeelTemperature

WeatherUnit

正在傳回 RealFeel™ Temperature。

realFeelTemperatureShade

WeatherUnit

正在傳回 RealFeel™ Temperature。 描述溫度在陰影中真正感覺的樣子。

relativeHumidity

integer

相對濕度是以相同溫度飽和所需的量百分比表示的空氣中存在水溫量。

temperature

WeatherUnit

傳回的溫度。

temperatureSummary

TemperatureSummary

過去 6、12 和 24 小時內的溫度波動摘要。

uvIndex

integer

測量來自太陽的陰氣強度。 支援的值包括:

  • 0-2 - 從太陽的UV光線或平均人員中低危險。
  • 3-5 - 不受保護的太陽暴露的危害風險中等。
  • 6-7 - 不受保護的太陽暴露的高風險。
  • 8-10 - 不受保護的太陽暴露的損害風險非常高。
  • 11+ - 不受保護的太陽暴露的極端損害風險。
uvIndexPhrase

string

uvIndex相關聯的片語。

visibility

WeatherUnit

指定單位中的可見度。 可清楚辨識物件或光線的距離量值。

wetBulbTemperature

WeatherUnit

在達到飽和度之前,空氣可能會以固定壓力將水壓到其冷卻至其溫度。

wind

WindDetails

傳回的風詳細數據包括速度和方向。

windChillTemperature

WeatherUnit

由於風力,在公開的面板上察覺到的空氣溫度。

windGust

WindDetails

風雨。 風流突然突然增加,速度很快。

CurrentConditionsResult

名稱 類型 Description
results

CurrentConditions[]

詳細的目前天氣狀況。

ErrorAdditionalInfo

資源管理錯誤其他資訊。

名稱 類型 Description
info

object

其他資訊。

type

string

其他信息類型。

ErrorDetail

錯誤詳細數據。

名稱 類型 Description
additionalInfo

ErrorAdditionalInfo[]

錯誤其他資訊。

code

string

錯誤碼。

details

ErrorDetail[]

錯誤詳細資料。

message

string

錯誤訊息。

target

string

錯誤目標。

ErrorResponse

錯誤回應

名稱 類型 Description
error

ErrorDetail

error 物件。

IconCode

數值,表示顯示 的 iconPhrase影像。 如需詳細資訊,請參閱 Azure 地圖服務 中的天氣服務

名稱 類型 Description
1

Integer

10

Integer

11

Integer

12

Integer

13

Integer

14

Integer

15

Integer

16

Integer

17

Integer

18

Integer

19

Integer

2

Integer

20

Integer

21

Integer

22

Integer

23

Integer

24

Integer

25

Integer

26

Integer

27

Integer

28

Integer

29

Integer

3

Integer

30

Integer

31

Integer

32

Integer

33

Integer

34

Integer

35

Integer

36

Integer

37

Integer

38

Integer

39

Integer

4

Integer

40

Integer

41

Integer

42

Integer

43

Integer

44

Integer

5

Integer

6

Integer

7

Integer

8

Integer

9

Integer

JsonFormat

所需的回應格式。 僅支援 json 格式。

名稱 類型 Description
json

string

JavaScript 物件表示法數據交換格式

PastHoursTemperature

過去數小時內溫度波動的摘要。

名稱 類型 Description
maximum

WeatherUnit

maximum

minimum

WeatherUnit

minimum

PrecipitationSummary

名稱 類型 Description
pastEighteenHours

WeatherUnit

過去 18 小時內已下降的 (相當於) 的氣候量。

pastHour

WeatherUnit

過去一小時內已下降的 (相當於) 的氣候量。

pastNineHours

WeatherUnit

過去九小時內已下降的 (相當於) 的氣候量。

pastSixHours

WeatherUnit

過去六小時內已下降的 (相當於) 的氣候量。 包含計量和標準值。

pastThreeHours

WeatherUnit

過去三小時內已下降 (相當於) 的雨量。

pastTwelveHours

WeatherUnit

過去 12 小時內已下降的 (水量) 。

pastTwentyFourHours

WeatherUnit

過去 24 小時內已下降 (相當於) 的氣候量。

PressureTendency

名稱 類型 Description
code

string

不論語言為何,壓力趨勢程序代碼。 其中一個 F=下降、S=穩定、R=Rising。

localizedDescription

string

以指定語言顯示壓力趨勢的描述

TemperatureSummary

名稱 類型 Description
pastSixHours

PastHoursTemperature

過去6小時內溫度波動的摘要。

pastTwelveHours

PastHoursTemperature

過去12小時內溫度波動的摘要。

pastTwentyFourHours

PastHoursTemperature

過去24小時內溫度波動的摘要。

UnitType

與所顯示單位類型相關聯的數值標識碼。 可用於單元翻譯。 如需詳細資訊,請參閱 Azure 地圖服務 中的天氣服務

名稱 類型 Description
0

Integer

1

Integer

10

Integer

11

Integer

12

Integer

13

Integer

14

Integer

15

Integer

16

Integer

17

Integer

18

Integer

19

Integer

2

Integer

20

Integer

21

Integer

22

Integer

3

Integer

31

Integer

4

Integer

5

Integer

6

Integer

7

Integer

8

Integer

9

Integer

WeatherDataUnit

指定以計量單位或英制單位傳回數據。 預設值為計量。

名稱 類型 Description
imperial

string

以單位傳回數據。 一些單位的機率系統範例為Fahrenheit和英哩。

metric

string

以計量單位傳回數據。 計量系統的一些範例單位為攝氏和公里。

WeatherUnit

與天氣相關的指定單位特定值。

名稱 類型 Description
unit

string

傳回值的單位類型。

unitType

UnitType

與所顯示單位類型相關聯的數值標識碼。 可用於單元翻譯。 如需詳細資訊,請參閱 Azure 地圖服務 中的天氣服務

value

number

四捨五入值。

WindDetails

傳回的風詳細數據包括速度和方向。

名稱 類型 Description
direction

WindDirection

風向

speed

WeatherUnit

指定單位的風速。

WindDirection

風向

名稱 類型 Description
degrees

integer

Azimuth 度的風向,從 true North 開始,並繼續順時針方向。 北為 0 度,東部為 90 度,南為 180 度,西部為 270 度。 可能的值 0-359。

localizedDescription

string

指定語言的方向縮寫。