你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Weather - Get Current Conditions

使用 获取当前天气状况。

API Get Current Conditions 是一个 HTTP GET 请求,可返回给定坐标位置的详细当前天气条件,例如降水、温度和风。 此外,还可检索过去 6 或 24 小时内特定位置的观测结果。 随 响应一起返回的基本信息包括观测日期和时间、天气条件的简要说明、天气图标、降水指示器标志和温度等详细信息。 还会返回 RealFeel™ 温度和 UV 指数等其他详细信息。 有关详细信息,请参阅 请求实时天气数据

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 参数

名称 必需 类型 说明
format
path True

JsonFormat

响应的所需格式。 仅支持 json 格式。

api-version
query True

string

Azure Maps 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

指定以公制单位或英制单位返回数据。 默认值为 metric。

请求头

名称 必需 类型 说明
x-ms-client-id

string

指定要与Microsoft Entra ID安全模型一起使用的帐户。 它表示Azure Maps帐户的唯一 ID,可以从Azure Maps管理平面帐户 API 检索。 若要在 Azure Maps 中使用Microsoft Entra ID安全性,请参阅以下文章以获取指导。

响应

名称 类型 说明
200 OK

CurrentConditionsResult

确定

Other Status Codes

ErrorResponse

发生了意外错误。

安全性

AADToken

这些是 OAuth 2.0 流Microsoft Entra。 与 Azure 基于角色的访问控制配对后,它可用于控制对 Azure Maps REST API 的访问。 Azure 基于角色的访问控制用于指定对一个或多个Azure Maps资源帐户或子资源的访问权限。 可以通过内置角色或由一个或多个权限组成的自定义角色授予任何用户、组或服务主体访问权限,以Azure Maps REST API。

若要实现方案,建议查看 身份验证概念。 总之,此安全定义提供了一个解决方案,用于通过能够对特定 API 和作用域进行访问控制的对象对应用程序 () 建模。

备注

  • 此安全定义需要使用x-ms-client-id 标头来指示应用程序请求访问哪个Azure Maps资源。 这可以从 地图管理 API 获取。

Authorization URL特定于 Azure 公有云实例。 主权云具有唯一的授权 URL 和Microsoft Entra ID配置。 * Azure 基于角色的访问控制是通过 Azure 门户、PowerShell、CLI、Azure SDK 或 REST API 从 Azure 管理平面配置的。 * 使用 Azure Maps Web SDK 可以针对多个用例基于配置设置应用程序。

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

Scopes

名称 说明
https://atlas.microsoft.com/.default https://atlas.microsoft.com/.default

subscription-key

这是在Azure 门户或使用 PowerShell、CLI、Azure SDK 或 REST API Create Azure Maps帐户时预配的共享密钥。

使用此密钥,任何应用程序都可以访问所有 REST API。 换句话说,此密钥可以用作颁发它们的帐户中的主密钥。

对于公开的应用程序,我们建议使用机密客户端应用程序方法来访问Azure Maps REST API,以便安全地存储密钥。

Type: apiKey
In: query

SAS Token

这是一个共享访问签名令牌,通过 Azure 管理平面通过 Azure 门户、PowerShell、CLI、Azure SDK 或 REST API 在Azure Maps资源上列出 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
          }
        }
      }
    }
  ]
}

定义

名称 说明
CurrentConditions
CurrentConditionsResult
ErrorAdditionalInfo

资源管理错误附加信息。

ErrorDetail

错误详细信息。

ErrorResponse

错误响应

IconCode

表示显示 的图像的 iconPhrase数值。 有关详细信息,请参阅 Azure Maps 中的天气服务

JsonFormat

响应的所需格式。 仅支持 json 格式。

PastHoursTemperature

过去小时的温度波动摘要。

PrecipitationSummary
PressureTendency
TemperatureSummary
UnitType

与显示的单位类型关联的数值 ID 值。 可用于单元翻译。 有关详细信息,请参阅 Azure Maps 中的天气服务

WeatherDataUnit

指定以公制单位或英制单位返回数据。 默认值为 metric。

WeatherUnit

与天气相关的给定单位的特定值。

WindDetails

返回的风力详细信息,包括速度和方向。

WindDirection

风向

CurrentConditions

名称 类型 说明
apparentTemperature

WeatherUnit

由指定单位中空气温度、相对湿度和风速组合引起的室外温度。

ceiling

WeatherUnit

指定单位中的云上限。 天花板是最低云基高度的度量值。

cloudCover

integer

表示云覆盖率的百分比。

dateTime

string

以 ISO 8601 格式显示的当前观察的日期和时间,例如 2019-10-27T19:39:57-08:00。

dewPoint

WeatherUnit

以指定单位为单位的露点温度。 露点温度是空气必须冷却到达到饱和度的温度。

hasPrecipitation

boolean

指示是否存在降水。 True 表示存在降水,false 表示没有降水。

iconCode

IconCode

表示显示 的图像的 iconPhrase数值。 有关详细信息,请参阅 Azure Maps 中的天气服务

isDayTime

boolean

指示一天中的时间。 True 表示“day”,false 表示“night”。

obstructionsToVisibility

string

可见性受限的原因。

可能的值:

  • A = 强雷暴/冰冻
  • BD = 吹尘
  • BN = 吹砂
  • BS = 吹雪
  • D = 灰尘
  • F = fog
  • GF = 地面雾
  • HZ = haze
  • I = ice
  • IC = 冰晶
  • IF = 冰雾
  • IP = 冰颗粒
  • IPW = 冰颗粒淋浴
  • K = 烟雾
  • L = 细雨
  • R = 雨
  • RS = 雨/雪
  • RW = 阵雨
  • S = snow
  • SG = 雪粒
  • SP = 雪地颗粒
  • SW = 雪地阵雨
  • T = 雷雨
  • UP = 未定义的降水
  • ZL = 冰冻细雨
  • ZR = 冰冻雨
  • + = 重
  • - = 浅色
pastTwentyFourHourTemperatureDeparture

WeatherUnit

偏离 24 小时前观测到的指定单位的温度。

phrase

string

当前天气状况的短语说明。 以指定语言显示。

precipitationSummary

PrecipitationSummary

过去 24 小时的降水量摘要。

pressure

WeatherUnit

指定单位的大气压力。

pressureTendency

PressureTendency

大气压力变化。

realFeelTemperature

WeatherUnit

返回的 RealFeel™ 温度。

realFeelTemperatureShade

WeatherUnit

返回的 RealFeel™ 温度。 描述树荫下温度的真实感觉。

relativeHumidity

integer

相对湿度是空气中存在的水蒸汽量,以相同温度下饱和所需量的百分比表示。

temperature

WeatherUnit

正在返回的温度。

temperatureSummary

TemperatureSummary

过去 6、12 和 24 小时内的温度波动摘要。

uvIndex

integer

测量来自太阳的紫外线辐射强度。 支持的值是:

  • 0-2 - 太阳紫外线或普通人的危险性低。
  • 3-5 - 不受保护的阳光照射造成的中度伤害风险。
  • 6-7 - 不受保护的阳光照射造成的伤害风险很高。
  • 8-10 - 不受保护的阳光照射造成的伤害风险非常高。
  • 11+ - 不受保护的阳光暴露的极端危害风险。
uvIndexPhrase

string

uvIndex关联的短语。

visibility

WeatherUnit

指定单位中的可见性。 对象或光可以清晰识别的距离的度量值。

wetBulbTemperature

WeatherUnit

通过将水以恒定压力蒸发到空气达到饱和状态,空气可以冷却到的温度。

wind

WindDetails

返回的风力详细信息,包括速度和方向。

windChillTemperature

WeatherUnit

由于风而暴露的皮肤上感知到的空气温度。

windGust

WindDetails

阵风。 阵风是一个突然的,短暂的风速增加。

CurrentConditionsResult

名称 类型 说明
results

CurrentConditions[]

详细的当前天气状况。

ErrorAdditionalInfo

资源管理错误附加信息。

名称 类型 说明
info

object

其他信息。

type

string

其他信息类型。

ErrorDetail

错误详细信息。

名称 类型 说明
additionalInfo

ErrorAdditionalInfo[]

错误附加信息。

code

string

错误代码。

details

ErrorDetail[]

错误详细信息。

message

string

错误消息。

target

string

错误目标。

ErrorResponse

错误响应

名称 类型 说明
error

ErrorDetail

错误对象。

IconCode

表示显示 的图像的 iconPhrase数值。 有关详细信息,请参阅 Azure Maps 中的天气服务

名称 类型 说明
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 格式。

名称 类型 说明
json

string

JavaScript 对象表示法数据交换格式

PastHoursTemperature

过去小时的温度波动摘要。

名称 类型 说明
maximum

WeatherUnit

最大值

minimum

WeatherUnit

最小值

PrecipitationSummary

名称 类型 说明
pastEighteenHours

WeatherUnit

降水量 (过去18小时内下降的液体当量) 。

pastHour

WeatherUnit

降水量 (过去一小时下降的液体当量) 。

pastNineHours

WeatherUnit

降水量 (过去9小时内下降的液体当量) 。

pastSixHours

WeatherUnit

降水量 (液体当量) 在过去六小时内下降。 包含指标和英制值。

pastThreeHours

WeatherUnit

降水量 (过去三小时内下降的液体当量) 。

pastTwelveHours

WeatherUnit

降水量 (过去12小时内下降的液体当量) 。

pastTwentyFourHours

WeatherUnit

降水量 (液体当量) 在过去24小时内下降。

PressureTendency

名称 类型 说明
code

string

无论语言如何,压力趋势代码。 F=下降、S=稳定、R=Rising 之一。

localizedDescription

string

指定语言的压力趋势说明

TemperatureSummary

名称 类型 说明
pastSixHours

PastHoursTemperature

过去 6 小时的温度波动摘要。

pastTwelveHours

PastHoursTemperature

过去 12 小时内的温度波动摘要。

pastTwentyFourHours

PastHoursTemperature

过去 24 小时内的温度波动摘要。

UnitType

与显示的单位类型关联的数值 ID 值。 可用于单元翻译。 有关详细信息,请参阅 Azure Maps 中的天气服务

名称 类型 说明
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

指定以公制单位或英制单位返回数据。 默认值为 metric。

名称 类型 说明
imperial

string

以英制单位返回数据。 帝国体系的一些示例单位是华氏度和英里。

metric

string

以指标单位返回数据。 指标系统的一些示例单位为摄氏度和公里。

WeatherUnit

与天气相关的给定单位的特定值。

名称 类型 说明
unit

string

返回值的单位类型。

unitType

UnitType

与显示的单位类型关联的数值 ID 值。 可用于单元翻译。 有关详细信息,请参阅 Azure Maps 中的天气服务

value

number

舍入值。

WindDetails

返回的风力详细信息,包括速度和方向。

名称 类型 说明
direction

WindDirection

风向

speed

WeatherUnit

以指定单位为单位的风速。

WindDirection

风向

名称 类型 说明
degrees

integer

方位角风向,从真正北端开始,沿顺时针方向继续。 北为0度,东为90度,南为180度,西为270度。 可能的值 0-359。

localizedDescription

string

指定语言的方向缩写。