Base/weather

跳转到: 导航, 搜索

目录

天气信息

根据城市返回天气信息的接口

URL

http://api.map.sina.com.cn/base/weather.(json%7Cxml)

支持格式

XML/JSON

HTTP请求方式

GET

是否需要登录

false

请求数限制

true

请求参数

参数 必选 类型及范围 说明
source true string 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份
city_name true string 需要获取天气信息的城市名称
days false int 需要获取天气信息的天数(最大为3,默认为1)

返回结果

XML示例

<?xml version="1.0" encoding="UTF-8" ?> 
<geoSearchResult>
  <status>1</status> 
  <city>北京</city> 
  <days>1</days> 
  <weathers>
   <weather>
     <since_condition>晴</since_condition> 
     <after_condition>阴</after_condition> 
     <low_degree>1</low_degree> 
     <high_degree>11</high_degree> 
     <forecast_date>2011-03-23</forecast_date> 
     <day_of_week>周三</day_of_week> 
     <since_img>http://image2.sina.com.cn/dy/weather/images/figure/qing_small.gif</since_img> 
     <after_img>http://image2.sina.com.cn/dy/weather/images/figure/yin_small.gif</after_img> 
    </weather>
  </weathers>
 </geoSearchResult>

JSON示例

{
 "status":"1",
 "city":"\u5317\u4eac",
 "days":"1",
 "weathers":
 [
  {
   "since_condition":"\u6674",
   "after_condition":"\u9634",
   "low_degree":"1",
   "high_degree":"11",
   "forecast_date":"2011-03-23",
   "day_of_week":"\u5468\u4e09",
   "since_img":"http:\/\/image2.sina.com.cn\/dy\/weather\/images\/figure\/qing_small.gif",
   "after_img":"http:\/\/image2.sina.com.cn\/dy\/weather\/images\/figure\/yin_small.gif"
  }
 ]
}

字段说明

status:查询结果(status为1时,查询有结果)
city:查询城市
days:查询天数
wethers:返回的天气记录集
since_condition:天气情况A(如果与天气情况B不同,则为天气情况A转天气情况B)
after_condition:天气情况B
low_degree:更多ip地址信息
high_degree:本条记录的ip
forecast_date:天气预报的日期
day_of_week:星期几
since_img:天气图片A,与天气情况A对应
after_img:天气图片B,与天气情况B对应

使用示例

xml: 
http://api.map.sina.com.cn/base/weather.xml?city_name=北京&source=appkey

json: 
http://api.map.sina.com.cn/base/weather.json?city_name=北京&source=appkey