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

Weather - Get Daily Forecast

用于获取未来 1 天、5 天、10 天、15 天、25 天或 45 天的每日详细天气预报。

API Get Daily Forecast 是一个 HTTP GET 请求,它返回给定坐标位置未来 1 天、5 天、10 天、15 天、25 天或 45 天的详细天气预报,例如每天的温度和风。 响应包括温度、风速、降水量、空气质量和 UV 指数等详细信息。 有关更多信息,请参阅 请求每日天气预报数据

如果使用的是 Gen1 S0 定价层,则可以请求未来 1 天、5 天、10 天和 15 天的每日预测。 如果使用的是 Gen1 S1 或 Gen2 定价层,则还可以请求未来 25 天和 45 天的每日预测。

GET https://atlas.microsoft.com/weather/forecast/daily/json?api-version=1.1&query={query}
GET https://atlas.microsoft.com/weather/forecast/daily/json?api-version=1.1&query={query}&unit={unit}&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”。

通常,天气信息适用于陆地上的位置、被陆地包围的水体以及距离海岸线约 50 海里以内的海洋区域。

duration
query

integer

指定返回每日预测响应的天数。 可用值为

  • 1 - 返回第二天的预测数据。 默认情况下返回。
  • 5 - 返回未来 5 天的预测数据。
  • 10 - 返回未来 10 天的预测数据。
  • 25 - 返回未来 25 天的预测数据。 仅在 S1 SKU 中可用。
  • 45 - 返回未来 45 天的预测数据。 仅在 S1 SKU 中可用。
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

DailyForecastResult

好的

Other Status Codes

ErrorResponse

发生意外错误。

安全性

AADToken

这些 Microsoft Entra OAuth 2.0 流。 与 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 允许为多个用例设置基于应用程序的配置。

类型: oauth2
流向: implicit
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize

作用域

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

subscription-key

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

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

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

类型: apiKey
在: query

SAS Token

这是一个共享访问签名令牌,它通过 Azure 门户、PowerShell、CLI、Azure SDK 或 REST API 通过 Azure 管理平面在 azure Maps 资源 上的列表 SAS 操作创建。

使用此令牌,任何应用程序都有权使用 Azure 基于角色的访问控制进行访问,并精细控制特定令牌的过期、速率和区域。 换句话说,SAS 令牌可用于允许应用程序以比共享密钥更安全的方式控制访问。

对于公开的应用程序,建议在 映射帐户资源 上配置允许的源的特定列表,以限制呈现滥用并定期续订 SAS 令牌。

类型: apiKey
在: header

示例

Successfully retrieve detailed daily weather forecast for a given coordinate location

示例请求

GET https://atlas.microsoft.com/weather/forecast/daily/json?api-version=1.1&query=62.6490341,30.0734812&duration=5

示例响应

{
  "summary": {
    "startDate": "2019-11-17T09:00:00-08:00",
    "endDate": "2019-11-17T15:00:00-08:00",
    "severity": 5,
    "phrase": "Rain Sunday evening",
    "category": "rain"
  },
  "forecasts": [
    {
      "date": "2019-11-13T21:00:00-08:00",
      "temperature": {
        "minimum": {
          "value": 0.8,
          "unit": "C",
          "unitType": 17
        },
        "maximum": {
          "value": 5.3,
          "unit": "C",
          "unitType": 17
        }
      },
      "realFeelTemperature": {
        "minimum": {
          "value": -3.4,
          "unit": "C",
          "unitType": 17
        },
        "maximum": {
          "value": 1.3,
          "unit": "C",
          "unitType": 17
        }
      },
      "realFeelTemperatureShade": {
        "minimum": {
          "value": -3.4,
          "unit": "C",
          "unitType": 17
        },
        "maximum": {
          "value": 1.6,
          "unit": "C",
          "unitType": 17
        }
      },
      "hoursOfSun": 1.1,
      "degreeDaySummary": {
        "heating": {
          "value": 15,
          "unit": "C",
          "unitType": 17
        },
        "cooling": {
          "value": 0,
          "unit": "C",
          "unitType": 17
        }
      },
      "airAndPollen": [
        {
          "name": "AirQuality",
          "value": 0,
          "category": "Good",
          "categoryValue": 1,
          "type": "Ozone"
        },
        {
          "name": "Grass",
          "value": 0,
          "category": "Low",
          "categoryValue": 1
        },
        {
          "name": "Mold",
          "value": 0,
          "category": "Low",
          "categoryValue": 1
        },
        {
          "name": "Ragweed",
          "value": 0,
          "category": "Low",
          "categoryValue": 1
        },
        {
          "name": "Tree",
          "value": 0,
          "category": "Low",
          "categoryValue": 1
        },
        {
          "name": "UVIndex",
          "value": 0,
          "category": "Low",
          "categoryValue": 1
        }
      ],
      "day": {
        "iconCode": 12,
        "iconPhrase": "Showers",
        "hasPrecipitation": true,
        "precipitationType": "Rain",
        "precipitationIntensity": "Light",
        "shortPhrase": "Cloudy with a few showers",
        "longPhrase": "Cloudy with a couple of showers, mainly later",
        "precipitationProbability": 75,
        "thunderstormProbability": 20,
        "rainProbability": 75,
        "snowProbability": 40,
        "iceProbability": 0,
        "wind": {
          "direction": {
            "degrees": 160,
            "localizedDescription": "SSE"
          },
          "speed": {
            "value": 16.7,
            "unit": "km/h",
            "unitType": 7
          }
        },
        "windGust": {
          "direction": {
            "degrees": 160,
            "localizedDescription": "SSE"
          },
          "speed": {
            "value": 48.2,
            "unit": "km/h",
            "unitType": 7
          }
        },
        "totalLiquid": {
          "value": 6.1,
          "unit": "mm",
          "unitType": 3
        },
        "rain": {
          "value": 6.1,
          "unit": "mm",
          "unitType": 3
        },
        "snow": {
          "value": 0,
          "unit": "cm",
          "unitType": 4
        },
        "ice": {
          "value": 0,
          "unit": "mm",
          "unitType": 3
        },
        "hoursOfPrecipitation": 3.5,
        "hoursOfRain": 3.5,
        "hoursOfSnow": 0,
        "hoursOfIce": 0,
        "cloudCover": 100
      },
      "night": {
        "iconCode": 12,
        "iconPhrase": "Showers",
        "hasPrecipitation": true,
        "precipitationType": "Rain",
        "precipitationIntensity": "Light",
        "shortPhrase": "Breezy early; cloudy",
        "longPhrase": "Breezy this evening; otherwise, low clouds",
        "precipitationProbability": 65,
        "thunderstormProbability": 0,
        "rainProbability": 64,
        "snowProbability": 40,
        "iceProbability": 0,
        "wind": {
          "direction": {
            "degrees": 181,
            "localizedDescription": "S"
          },
          "speed": {
            "value": 20.4,
            "unit": "km/h",
            "unitType": 7
          }
        },
        "windGust": {
          "direction": {
            "degrees": 170,
            "localizedDescription": "S"
          },
          "speed": {
            "value": 42.6,
            "unit": "km/h",
            "unitType": 7
          }
        },
        "totalLiquid": {
          "value": 4,
          "unit": "mm",
          "unitType": 3
        },
        "rain": {
          "value": 4,
          "unit": "mm",
          "unitType": 3
        },
        "snow": {
          "value": 0,
          "unit": "cm",
          "unitType": 4
        },
        "ice": {
          "value": 0,
          "unit": "mm",
          "unitType": 3
        },
        "hoursOfPrecipitation": 2.5,
        "hoursOfRain": 2.5,
        "hoursOfSnow": 0,
        "hoursOfIce": 0,
        "cloudCover": 98
      },
      "sources": [
        "AccuWeather"
      ]
    }
  ]
}

定义

名称 说明
AirAndPollen
DailyForecast
DailyForecastResult
DailyForecastSummary

请求期间的主要条件摘要。 请注意,summary 只能涵盖部分时间段。

DayOrNight
DegreeDaySummary
ErrorAdditionalInfo

资源管理错误附加信息。

ErrorDetail

错误详细信息。

ErrorResponse

错误响应

IconCode

表示显示 iconPhrase. 有关详细信息,请参阅 Azure Maps 中的天气服务

JsonFormat

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

LocalSource

本地天气数据提供商信息。

PrecipitationType

指定降水的类型(“雨”、“雪”、“冰”或“混合”)。 如果 dbz 为零,则响应中不存在 precipitationType。

UnitType

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

WeatherDataUnit

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

WeatherUnit

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

WeatherUnitRange

返回的温度值。

WindDetails

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

WindDirection

风向

AirAndPollen

名称 类型 说明
category

string

空气质量或污染类型的类别。 例如,Low(低)、High(高)、Good(良好)、Moderate(中等)、unhealthy(不健康)、Hazardous(危险)。

categoryValue

integer (int32)

与空气质量或污染类别关联的值。 这些值的范围是 1 到 6。 1 表示条件良好,6 表示危险条件。

name

string

花粉或污染物的名称。 例如,草、霉菌、杂草、空气质量、树木和 UV 指数。

type

string

只为空气质量而存在。 示例包括臭氧和颗粒污染。

value

integer (int32)

上面给定类型的值。 与霉菌、草、杂草和树木关联的值以每立方米零件数为单位。 空气质量和 UV 都是指数,因此它们是无单位的。

DailyForecast

名称 类型 说明
airAndPollen

AirAndPollen[]

空气质量

date

string (date-time)

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

day

DayOrNight

日预报详细信息

degreeDaySummary

DegreeDaySummary

Heating Degrees Day (加热度日) 或 Cooling Degree Day (冷却度日) 信息的平均温度摘要

hoursOfSun

number (float)

日照时间。

night

DayOrNight

夜预报详情

realFeelTemperature

WeatherUnitRange

RealFeel™ Temperature 正在返回。

realFeelTemperatureShade

WeatherUnitRange

RealFeel™ Temperature 正在返回。 描述阴凉处温度的真实感觉。

sources

string[]

预测数据的来源。

temperature

WeatherUnitRange

当天的温度值。

DailyForecastResult

名称 类型 说明
forecasts

DailyForecast[]

每个请求日期的 Forecast 数据。

summary

DailyForecastSummary

请求期间的主要条件摘要。 请注意,summary 只能涵盖部分时间段。

DailyForecastSummary

请求期间的主要条件摘要。 请注意,summary 只能涵盖部分时间段。

名称 类型 说明
category

string

1 或 2 个单词来总结短语。

endDate

string (date-time)

汇总期间结束的日期和时间,以 ISO 8601 格式显示,例如 2019-10-27T19:39:57-08:00。

phrase

string

每日预报的摘要短语。 以指定的语言显示。

severity

integer (int32)

严重性

startDate

string (date-time)

摘要生效的日期和时间,以 ISO 8601 格式显示,例如 2019-10-27T19:39:57-08:00。

DayOrNight

名称 类型 说明
cloudCover

integer (int32)

表示云覆盖的百分比。

hasPrecipitation

boolean

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

hoursOfIce

number (float)

冰的时间。

hoursOfPrecipitation

number (float)

降水小时数

hoursOfRain

number (float)

几个小时的雨。

hoursOfSnow

number (float)

下雪数小时。

ice

WeatherUnit

iceProbability

integer (int32)

百分比表示结冰的概率。 例如,'30'。

iconCode

IconCode (int32)

表示显示 iconPhrase. 有关详细信息,请参阅 Azure Maps 中的天气服务

iconPhrase

string

图标的短语描述。 以指定的语言显示。 例如,“Sunny”。

localSource

LocalSource

本地天气数据提供商信息。

longPhrase

string

以指定语言表示的 forecast 的短语描述。 Azure Maps 会尝试将此短语的长度保持在 100 个字符以下,但某些语言/天气事件可能会导致短语长度更长,超过 100 个字符。

precipitationIntensity

string

强度的描述。

precipitationProbability

integer (int32)

表示降水概率的百分比。 例如,'20'。

precipitationType

PrecipitationType

指定降水的类型(“雨”、“雪”、“冰”或“混合”)。 如果 dbz 为零,则响应中不存在 precipitationType。

rain

WeatherUnit

rainProbability

integer (int32)

表示下雨概率的百分比。 例如,'40'。

shortPhrase

string

以指定语言表示的 forecast 的短语描述。 Azure Maps 尝试将此短语的长度保持在 30 个字符以下,但某些语言/天气事件可能会导致短语长度更长,超过 30 个字符。

snow

WeatherUnit

雪白

snowProbability

integer (int32)

百分比表示下雪的概率。 例如,'30'。

thunderstormProbability

integer (int32)

百分比表示雷暴的概率。 例如,'80'。

totalLiquid

WeatherUnit

预测期内降水的总液体当量。

wind

WindDetails

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

windGust

WindDetails

阵风。 阵风是风速的突然、短暂增加。

DegreeDaySummary

名称 类型 说明
cooling

WeatherUnit

平均温度高于 65 华氏度/18 摄氏度的度数。

heating

WeatherUnit

平均温度低于 65 华氏度/18 摄氏度的度数。

ErrorAdditionalInfo

资源管理错误附加信息。

名称 类型 说明
info

object

其他信息。

type

string

其他信息类型。

ErrorDetail

错误详细信息。

名称 类型 说明
additionalInfo

ErrorAdditionalInfo[]

错误附加信息。

code

string

错误代码。

details

ErrorDetail[]

错误详细信息。

message

string

错误消息。

target

string

错误目标。

ErrorResponse

错误响应

名称 类型 说明
error

ErrorDetail

错误对象。

IconCode

表示显示 iconPhrase. 有关详细信息,请参阅 Azure Maps 中的天气服务

说明
1

10
11

12

阵雨

13

大部多云有阵雨

14

局部晴朗有阵雨

15

雷暴

16

大部多云有雷暴

17

局部晴朗有雷暴

18

19

小雪

2

晴时多云

20

大部多云有小雪

21

局部晴朗有小雪

22

雪白

23

大部多云有雪

24

25

雨夹雪

26

冻雨

27
28
29

雨夹雪

3

局部晴朗

30

31

32

33

清晰

34

大部晴朗

35

局部多云

36

间歇性云(夜间)

37

朦胧的月光

38

大部分时间多云(夜间)

39

局部多云有阵雨

4

间歇性多云

40

大部分时间多云,有阵雨(夜间)

41

局部多云有雷暴

42

多云,有雷暴(夜间)

43

大部分时间多云,有阵雨(夜间)

44

大部分时间多云,有雪(夜间)

5

朦胧的阳光

6

大部多云

7

多云

8

阴沉(阴)

9

JsonFormat

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

说明
json

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

LocalSource

本地天气数据提供商信息。

名称 类型 说明
id

integer (int32)

数字标识符,对于本地数据提供程序是唯一的。

name

string

本地数据提供程序的名称。 名称以 URL 中的语言代码指定的语言显示(如果可用)。 否则,Name (名称) 将以英语或提供名称时所用的语言显示。

weatherCode

string

本地数据提供商提供的天气代码。 此天气代码允许将天气预报与本地数据提供商提供的图标(而不是 Azure Maps 图标)匹配。

PrecipitationType

指定降水的类型(“雨”、“雪”、“冰”或“混合”)。 如果 dbz 为零,则响应中不存在 precipitationType。

说明
Ice

Mix

混合

Rain

Snow

雪白

UnitType

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

说明
0

英尺

1

英寸

10

米每秒

11

百帕

12

英寸汞柱

13

千帕

14

毫巴

15

毫米汞柱

16

每平方英寸磅数

17

摄氏温度

18

华氏温度

19

开氏温度

2

英里

20

百分之

21

漂浮

22

整数

3

毫米

31

MicrogramsPerCubicMeterOfAir

4

厘米

5

6

千米

7

公里每小时

8

9

英里每小时

WeatherDataUnit

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

说明
imperial

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

metric

以公制单位返回数据。 公制的一些示例单位是 Celsius 和 Kilometer。

WeatherUnit

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

名称 类型 说明
unit

string

返回值的单位类型。

unitType

UnitType (int32)

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

value

number (float)

四舍五入的值。

WeatherUnitRange

返回的温度值。

名称 类型 说明
maximum

WeatherUnit

该时间段的最高温度

minimum

WeatherUnit

该时间段的最低温度。

WindDetails

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

名称 类型 说明
direction

WindDirection

风向

speed

WeatherUnit

以指定单位表示的风速。

WindDirection

风向

名称 类型 说明
degrees

integer (int32)

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

localizedDescription

string

指定语言的 Direction 缩写。