浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。

文档全面上新

更科技的视觉体验,更高效的页面结构,快前往体验吧!

体验新版


接口说明

    车联网API服务的各种能力后续将合并到Web API服务中。自2015年12月31日起,车联网API服务将不再向新用户提供服务支持。已有用户服务暂不受影响,请已使用了各种车联网API服务的开发者,尽快升级服务到Web API中使用。

天气API主要应用场景:根据经纬度/城市名查询天气的结果。

注意事项:

1、天气API仅提供给汽车相关产品小规模免费使用,非车联网相关的产品一概无法提供支持!

2、天气API无法提供超过5000次的天气服务免费支持!

如需商业合作请将公司名称、产品介绍等先关信息发送至(liushuo01@baidu.com)

接口示例

http://api.map.baidu.com/telematics/v3/weather?location=北京&output=json&ak=E4805d16520de693a3fe707cdc962045

接口参数说明

参数类型 参数名称 是否必须 具体描述
String ak true 开发者密钥
String sn false 若用户所用ak的校验方式为sn校验时该参数必须。 (sn生成算法)
String location true 支持经纬度和城市名两种形式,一次请求最多支持15个城市,之间用"|"分隔,同一个城市的经纬度之间用 "," 分隔。举例:location=116.43,40.75|120.22,43,33或者是location=北京|上海|广州。
String output false 输出的数据格式,默认为xml格式,当output设置为’json’时,输出的为json格式的数据;
String coord_type false 请求参数坐标类型,默认为gcj02经纬度坐标。允许的值为bd09ll、bd09mc、gcj02、wgs84。bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托坐标,gcj02表示经过国测局加密的坐标。wgs84表示gps获取的坐标。
String callback false 将json格式的返回值通过callback函数返回以实现jsonp功能。举例:callback=showLocation(JavaScript函数名)。

返回结果

参数名称 含义 说明
currentCity 当前城市 返回城市名
status 返回结果状态信息 请求状态,如果成功返回0,如果失败返回其他数字,详细见状态码附录。
date 当前时间 年-月-日
results 天气预报信息 白天可返回近期3天的天气情况(今天、明天、后天)、晚上可返回近期4天的天气情况(今天、明天、后天、大后天)
results.currentCity 当前城市
results.pm25 pm2.5 0~50,一级,优,绿色;

51~100,二级,良,黄色; 101~150,三级,轻度污染,橙色; 151~200,四级,中度污染 ,红色; 201~300,五级,重度污染 ,紫色; >300,六级,严重污染, 褐红色。 图标分类示意图: pm25green.png 优, pm25yellow.png 良 , pm25orange.png 轻度污染,pm25red.png 中度污染,pm25purple.png 重度污染, pm25balck.png 严重污染。

results.index.title 指数title 分为:穿衣、洗车、感冒、运动、紫外线这几个类型。
results.index.zs 指数取值 不同指数描述不一
results.index.tipt 指数含义 指数含义
results.index.des 指数详情 指数详情
results.weather_data weather_data.date 天气预报时间
weather_data.dayPictureUrl 白天的天气预报图片url
weather_data.nightPictureUrl 晚上的天气预报图片url
weather_data.weather 天气状况 常见天气情况(“|”分隔符):晴|多云|阴|阵雨|雷阵雨|雷阵雨伴有冰雹|雨夹雪|小雨|中雨|大雨|暴雨|大暴雨|特大暴雨|阵雪|小雪|中雪|大雪|暴雪|雾|冻雨|沙尘暴|小雨转中雨|中雨转大雨|大雨转暴雨|暴雨转大暴雨|大暴雨转特大暴雨|小雪转中雪|中雪转大雪|大雪转暴雪|浮尘|扬沙|强沙尘暴|霾
weather_data.wind 风力 风力值
weather_data.temperature 温度 温度范围,如:29~22℃

返回xml格式的数据

<CityWeatherResponse>
<status>success</status>
<date>2013-07-18</date>
<results>
<currentCity>北京市</currentCity>
<weather_data>
<date>周三(今天, 实时:24℃)</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/duoyun.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>多云</weather>
<wind>微风</wind>
<temperature>23℃~ 15℃</temperature>
<date>周四</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/leizhenyu.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/zhongyu.png
</nightPictureUrl>
<weather>雷阵雨转中雨</weather>
<wind>微风</wind>
<temperature>29~22℃</temperature>
<date>周五</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/yin.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>阴转多云</weather>
<wind>微风</wind>
<temperature>31~23℃</temperature>
<date>周六</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/duoyun.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>多云</weather>
<wind>微风</wind>
<temperature>31~24℃</temperature>
</weather_data>
<currentCity>合肥市</currentCity>
<weather_data>
<date>周三</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/duoyun.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>多云</weather>
<wind>东风3-4级</wind>
<temperature>27℃</temperature>
<date>周四</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/duoyun.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>多云</weather>
<wind>东北风3-4级</wind>
<temperature>35~27℃</temperature>
<date>周五</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/duoyun.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>多云</weather>
<wind>南风</wind>
<temperature>35~27℃</temperature>
<date>周六</date>
<dayPictureUrl>
http://api.map.baidu.com/images/weather/day/duoyun.png
</dayPictureUrl>
<nightPictureUrl>
http://api.map.baidu.com/images/weather/night/duoyun.png
</nightPictureUrl>
<weather>多云</weather>
<wind>东风</wind>
<temperature>34~27℃</temperature>
</weather_data>
</results>
</CityWeatherResponse>
<weather>阵雨</weather>
<wind>东北风3-4级</wind>
<temperature>18℃</temperature>
<index>
<title>穿衣</title>
<zs>舒适</zs>
<tipt>穿衣指数</tipt>
<des>建议着长袖T恤、衬衫加单裤等服装。年老体弱者宜着针织长袖衬衫、马甲和长裤。</des>
<title>洗车</title>
<zs>不宜</zs>
<tipt>洗车指数</tipt>
<des>不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。</des>
<title>感冒</title>
<zs>较易发</zs>
<tipt>感冒指数</tipt>
<des>相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。</des>
<title>运动</title>
<zs>较不宜</zs>
<tipt>运动指数</tipt>
<des>有降水,推荐您在室内进行健身休闲运动;若坚持户外运动,须注意携带雨具并注意避雨防滑。</des>
<title>紫外线强度</title>
<zs>弱</zs>
<tipt>紫外线强度指数</tipt>
<des>紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。</des>
</index>
<pm25>166</pm25>
</results>
</CityWeatherResponse>

返回json格式的数据

{
error: 0,
status: "success",
date: "2013-07-17",
results: 
[
{
currentCity: "北京市",
pm25: "166",
index: [
{
title: "穿衣",
zs: "舒适",
tipt: "穿衣指数",
des: "建议着长袖T恤、衬衫加单裤等服装。年老体弱者宜着针织长袖衬衫、马甲和长裤。"
},
{
title: "洗车",
zs: "不宜",
tipt: "洗车指数",
des: "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。"
},
{
title: "感冒",
zs: "较易发",
tipt: "感冒指数",
des: "相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。"
},
{
title: "运动",
zs: "较不宜",
tipt: "运动指数",
des: "有降水,推荐您在室内进行健身休闲运动;若坚持户外运动,须注意携带雨具并注意避雨防滑。"
},
{
title: "紫外线强度",
zs: "弱",
tipt: "紫外线强度指数",
des: "紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。"
}
],
weather_data: 
[
{
date: "周三(今天, 实时:24℃)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "微风",
temperature: "23℃~ 15℃"
},
{
date: "明天(周四)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/leizhenyu.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/zhongyu.png",
weather: "雷阵雨转中雨",
wind: "微风",
temperature: "29~22℃"
},
{
date: "后天(周五)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/yin.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "阴转多云",
wind: "微风",
temperature: "31~23℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "微风",
temperature: "31~24℃"
}
]
},
{
currentCity: "合肥市",
weather_data: 
[
{
date: "今天(周三)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "东风3-4级",
temperature: "27℃"
},
{
date: "明天(周四)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "东北风3-4级",
temperature: "35~27℃"
},
{
date: "后天(周五)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "南风",
temperature: "35~27℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "东风",
temperature: "34~27℃"
}
]
}
]
}
  • 文档根本没法用

  • 文档水平很差

  • 文档水平一般

  • 文档不错

  • 文档写的很好

如发现文档错误,或对此文档有更好的建议,请在下方反馈。问题咨询请前往反馈平台提交工单咨询。

提交反馈

拖动标注工具

添加矩形标注

添加箭头标注

完成

取消