简体中文
简体中文
English
联系我们
注册
登录

天气预报服务

更新时间:2021-07-30 04:03:17下载pdf

API列表

action 描述
weather.countryCities 查询城市列表
weather.city 查询城市信息
weather.positionCities 根据经纬度查询城市列表
weather.forecastCity 查询城市天气预报
weather.forecastPosition 根据经纬度查询天气

查询城市列表

接口说明

根据国家码获取该国家下所有的天气数据受支持的城市信息。当前暂时只支持中国。

接口地址

action: weather.countryCities

请求参数

参数名 类型 说明 必填
country_code String 国家码

请求示例

{ "action": "weather.countryCities", "params": { "country_code": "cn" } }

返回信息

参数名 类型 说明
code Integer 响应码(详情见错误码章节)
success Boolean 是否成功
true:成功
false:失败
msg String 请求失败的信息,成功为空
result Object 返回结果

result说明

参数名 类型 说明
area String 地区名称
pinyin String 地区拼音
province String 省份
city String 城市名称
cityId String 城市id

返回示例

{ "success": true, "t": 1541399281296, "result": [ { "area": "北京市", "pinyin": "beijingshi", "province": "北京市", "city": "北京市", "cityId": "793409505965772800" }, { "area": "天津市", "pinyin": "tianjinshi", "province": "天津市", "city": "天津市", "cityId": "793409507844820992" } ] }

错误码

以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

错误码 说明
500 系统错误
1106 权限非法

查询城市信息

接口说明

根据城市ID来查询城市信息

接口地址

action: weather.city

请求参数

参数名 类型 说明 必填
city_id String 城市ID

请求示例

{ "action": "weather.city", "params": { "city_id": "793409534348627968" } }

返回信息

参数名 类型 说明
code Integer 响应码(详情见错误码章节)
success Boolean 是否成功
true:成功
false:失败
msg String 请求失败的信息,成功为空
result Object 返回结果

result说明

参数名 类型 说明
id String 城市信息
ids String 最近更新时间
dbTable String 城市信息
parentId Integer 城市信息
name String 城市名称
shortName String 城市信息
province String 省份名称
countryName String 国家名称
parentCityName String 城市信息
level Integer 城市信息
lon String 精度
lat String 纬度
cityHash String 城市信息
cityIndexId Integer 城市信息
domesticCity Boolean 城市信息

返回示例

{ "success": true, "t": 1541399281296, "result": { "id": 793409534348627968, "ids": null, "gmtCreate": 1477877317000, "gmtModified": 1477877317000, "dbTable": null, "parentId": 793416838972313600, "name": "杭州市", "shortName": "杭州市", "province": "浙江省", "countryName": "中国", "parentCityName": "杭州市", "level": 3, "lon": "120.1650798", "lat": "30.25258003", "cityHash": "wtmk", "cityIndexId": 62160, "domesticCity": true } }

错误码

以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

错误码 说明
500 系统错误
1106 权限非法

根据经纬度查询城市列表

接口说明

根据经纬度查询城市信息

接口地址

action: weather.positionCities

请求参数

参数名 类型 说明 必填
lon String 精度
lat String 纬度

请求示例

{ "action": "weather.positionCities", "params": { "lon": "120.165", "lat": "30.252" } }

返回信息

参数名 类型 说明
code Integer 响应码(详情见错误码章节)
success Boolean 是否成功
true:成功
false:失败
msg String 请求失败的信息,成功为空
result Object 返回结果

result说明

参数名 类型 说明
area String 地区名称
pinyin String 地区拼音
province String 省份
city String 城市名称
cityId Integer 城市id

返回示例

{ "success": true, "t": 1541401512639, "result": { "area": "上城区", "pinyin": "shangshangchengquou", "province": "浙江省", "city": "杭州市", "cityId": 793409589986070528 } }

错误码

以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

错误码 说明
500 系统错误
1106 权限非法

查询城市天气预报

接口说明

根据城市id查询天气预报

接口地址

action: weather.forecastCity

请求参数

参数名 类型 说明 必填
city_id String 城市ID

请求示例

{ "action": "weather.forecastCity", "params": { "city_id": "793409534348627968" } }

返回信息

参数名 类型 说明
code Integer 响应码(详情见错误码章节)
success Boolean 是否成功
true:成功
false:失败
msg String 请求失败的信息,成功为空
result Object 返回结果

result说明

参数名 类型 说明
year-mouth-day Object 日期对应天气预报

具体天气预报说明

参数名 类型 说明
condTxt String
tempRange String 温度区间
updateTime String 更新时间

请求示例

{ "success": true, "t": 1541402025275, "result": { "2018-11-07": { "condTxt": "小雨", "tempRange": "16-20", "updateTime": null }, "2018-11-08": { "condTxt": "小雨", "tempRange": "10-18", "updateTime": null } } }

错误码

以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

错误码 说明
500 系统错误
1106 权限非法

根据经纬度查询天气

接口说明

根据城市经纬度来查询城市的天气信息

接口地址

action: weather.forecastPosition

请求参数

参数名 类型 说明 必填
lon String 精度
lat String 纬度

请求示例

{ "action": "weather.forecastPosition", "params": { "lon": "120.1650798", "lat": "30.25258003" } }

返回信息

参数名 类型 说明
code Integer 响应码(详情见错误码章节)
success Boolean 是否成功
true:成功
false:失败
msg String 请求失败的信息,成功为空
result Object 返回结果

result说明

参数名 类型 说明
data Object 城市信息
lastUpdateTime String 最近更新时间

data说明

参数名 类型 说明
temp String 温度
o3 String o3指数
windLevel String 风等级
pm10 String pm10指数
uvi String 紫外线指数
pressure String 气压
windDir String 风向
co String co指数
tips String 天气贴士
realFeel String 温度实感
no2 String no2指数
condition String 天气情况(阴晴雨雪)")
pm25 String pm2.5指数
so2 String 二氧化硫指数
aqi String 空气质量指数
humidity String 湿度
rank String 空气评分
windSpeed String 风速

返回示例

{ "success": true, "t": 1541403147707, "result": { "data": { "temp": "21", "o3": "13", "windLevel": "2", "pm10": "53", "uvi": "4", "pressure": "1020", "windDir": "东风", "co": "8", "tips": "今天有雨,冷热适宜,感觉很舒适。", "realFeel": "21", "no2": "21", "condition": "阴", "pm25": "46", "so2": "4", "aqi": "53", "humidity": "78", "rank": "393/577", "windSpeed": "2.45" }, "lastUpdateTime": 1541390400000 } }

错误码

以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

错误码 说明
500 系统错误
1106 权限非法