逐小时预报API开发指南
基本信息
- 华风爱科 API提供给用户一个简洁的RESTful Web接口,用以访问基于位置的天气数据。
- 逐小时预报搜索需location key配合。请使用定位API调取您所需要搜索的地点location key。
- 逐小时预报可调取小时数为1小时,12小时,24小时(~一天),72小时(~3天)。更多逐小时预报请联系商务。
- 逐小时预报支持中英文语言。如需要更多语言与本地化方言请联系商务。
- 逐小时预报响应可返回公制与英制单位。默认返回英制单位,公制单位可在URL中添加metric=true以请求返回。
- API默认返回简短版逐小时预报数据,信息包括:headline:数据有效期,Epoch数据有效期,严重程度,与文字。逐日报告信息:日期,Epoch日期,气温。白天:图标,图标文字,夜晚:图标,图标文字,mobile link与link。URL中添加details=true以请求详细版数据。
API服务地址
请求URL
类型 | URL | 请求方式 |
---|---|---|
使用LocationKey调取1小时预报 | https://openapi.weathercn.com/forecasts/{version}/hourly/1hour/{locationKey}{.{format}}?apikey=<用户的key>{&language={language code}}{&details={true or false}}{&metric={true or false}} | GET |
使用LocationKey调取12小时预报 | https://openapi.weathercn.com/forecasts/{version}/hourly/12hour/{locationKey}{.{format}}?apikey=<用户的key>{&language={language code}}{&details={true or false}}{&metric={true or false}} | GET |
使用LocationKey调取24小时预报 | https://openapi.weathercn.com/forecasts/{version}/hourly/24hour/{locationKey}{.{format}}?apikey=<用户的key>{&language={language code}}{&details={true or false}}{&metric={true or false}} | GET |
使用LocationKey调取72小时预报 | https://openapi.weathercn.com/forecasts/{version}/hourly/72hour/{locationKey}{.{format}}?apikey=<用户的key>{&language={language code}}{&details={true or false}}{&metric={true or false}} | GET |
请求参数
参数 | 说明 | 默认值 | |
---|---|---|---|
apikey | 用以在API里验证与授权使用的用户密钥 | N/A | 必选 |
version | 当前API版本 | v1 | 必选 |
locationkey | 用以搜索指定地点的特定ID | N/A | 必选 |
format | 响应格式 | JSON | 可选 |
language | 指定响应数据语言的字符串 | zh-cn | 可选 |
details | 用以判断是否返回简短版或完整版数据的布尔值(true 或 false),完整版 (details = true) | False | 可选 |
metric | 用以判断是否返回公制或英制版版数据的布尔值(true 或 false),公制版 ( = true) | False | 可选 |
返回参数
参数 | 说明 | ||
---|---|---|---|
DateTime | 当前预报日期与时间, ISO8601 格式: yyyy-mm-ddThh:mm:ss±hh:mm | ||
EpochDateTime | 当前预报的UNIX时间,从协调世界时1970年1月1日0时0分0秒起至现在的总秒数,不考虑闰秒 (午夜 UTC/GMT) | ||
WeatherIcon | 天气预报图标ID | ||
IconPhrase | 图标说明 | ||
HasPrecipitation | 表示存在任何类型降水的布尔值。如果存在降水,则显示为真。(true or false) | ||
IsDaylight | 白天判断值(true or false) | ||
Temperature | 气温 | ||
Value | 气温取整数 | ||
Unit | 气温数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
LocalSource | 针对特定数据的当地的数据源信息。如当地数据源信息缺失,该参数则不显示。 | ||
Id | 当地数据供应商ID值 | ||
Name | 当地数据供应商名称。在支持的情况下供应商名字将以请求的语言显示。否则名称将以英文或者该名称的本地语言显示。 | ||
WeatherCode | 本地数据供应商所提供的天气代码,需匹配WeatherCode编码表。 | ||
WindLevelCode | 本地数据供应商所提供的风力等级,需匹配WindLevelCode编码表。 | ||
WindDirectionCode | 本地数据供应商所提供的风向代码,需匹配WindDirectionCode编码表。 | ||
RealFeelTemperature™ | AccuWeather RealFeel™ Temperature 温度(专利) | ||
Value | AccuWeather RealFeel™ Temperature 温度(专利)的气温取整数 | ||
Unit | RealFeel™数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
RealFeelTemperatureShade™ | AccuWeather RealFeel™ Temperature in shade | ||
Value | RealFeelTemperatureShade™温度(专利)的气温取整数 | ||
Unit | RealFeel™数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
WetBulbTemperature | 湿球温度 | ||
Value | 湿球温度取整数 | ||
Unit | 湿球温度数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
DewPoint | 露点温度 | ||
Value | 露点温度取整数 | ||
Unit | 露点温度数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
Wind | 风 | ||
Speed | 风速 | ||
Value | 风速取整数 | ||
Unit | 风速数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
Direction | 风向 | ||
Degrees | 风向的方位角度(例:180°则是南风) | ||
Localized | 特定语言的风向缩写 | ||
English | 风向英文缩写 | ||
WindGust | 阵风 | ||
Speed | 风速 | ||
阵风风速取整数 | |||
阵风风速数值的单位类型 | |||
用于单位转换使用的ID | |||
RelativeHumidity | 相对湿度 | ||
IndoorRelativeHumidity | 室内相对湿度 | ||
Visibility | 能见度 | ||
Value | 能见度取整数 | ||
Unit | 能见度数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
Ceiling | 云高 | ||
Value | 云高取整数 | ||
Unit | 云高数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
UVIndex | 紫外线强度衡量指数,UV Index、描述、颜色如下: 0-2(Green):Low danger from the sun's UV rays or the average person; 3-5(Yellow):Moderate risk of harm from unprotected sun exposure; 6-7(Orange):High risk of harm from unprotected sun exposure; 8-10(Red):Very high risk of harm from unprotected sun exposure; 11+(Purple):Extreme risk of harm from unprotected sun exposure; | ||
UVIndexText | 紫外线强度衡量指数文字说明 | ||
PrecipitationProbability | 降水概率(单位:%) | ||
ThunderstormProbability | 雷暴概率(单位:%) | ||
RainProbability | 降雨概率(单位:%) | ||
SnowProbability | 降雪概率(单位:%) | ||
IceProbability | 冻雪概率(单位:%) | ||
TotalLiquid | 液体总量 | ||
Value | 总降水量取整数 | ||
Unit | 总降水数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
Rain | 降雨 | ||
Value | 降雨取整数 | ||
Unit | 降雨数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
Snow | 降雪 | ||
Value | 降雪取整数 | ||
Unit | 降雪数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
Ice | 冻雪 | ||
Value | 冻雪取整数 | ||
Unit | 冻雪数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
CloudCover | 云量 | ||
Evapotranspiration | 蒸发,土壤水分蒸发蒸腾损失总量。 | ||
Value | 蒸发取整数 | ||
Unit | 蒸发数值的单位类型 | ||
UnitType | 用于单位转换使用的ID | ||
SolarIrradiance | 太阳辐照度,在地球表面测量的太阳电磁辐射(全球水平辐照度)。 可以为空。 | ||
Value | 太阳辐照度取整数 | ||
Unit | 太阳辐照度数值的单位类型 单位:瓦特/平方米(W/㎡) | ||
UnitType | 用于单位转换使用的ID | ||
MobileLink | 跳转至的华风爱科/Accuweather移动端网页的链接 | ||
Link | 跳转至的华风爱科/Accuweather网页的链接 |
调用示例
使用LocationKey调取1小时预报
jsonhttps://openapi.weathercn.com/forecasts/v1/hourly/1hour/101924?apikey=<用户的key>&language=zh-cn&details=true&metric=true
使用LocationKey调取12小时预报
jsonhttps://openapi.weathercn.com/forecasts/v1/hourly/12hour/101924?apikey=<用户的key>&language=zh-cn&details=true&metric=true
使用LocationKey调取24小时预报
jsonhttps://openapi.weathercn.com/forecasts/v1/hourly/24hour/101924?apikey=<用户的key>&language=zh-cn&details=true&metric=true
使用LocationKey调取72小时预报
jsonhttps://openapi.weathercn.com/forecasts/v1/hourly/72hour/101924?apikey=<用户的key>&language=zh-cn&details=true&metric=true