首页 生活常用 历史天气
历史天气

历史天气

  • 111
  • 133
全国3000多个省市的历史天气查询,包括最高最低温度、风级、湿度、气压等指数,最低最高温度、日出日落时间、空气质量指数、首要污染物等信息。图片地址:http://api.jisuapi.com/weather/icon.zip
0.00/次
https://api.binstd.com/weather2/query
JSON,JSONP
GET POST
https://api.binstd.com/weather2/query?appkey=yourappkey&city=安顺&date=2018-01-01

请求参数:

API在线测试
参数名称类型必填说明
city string 城市
cityid int 城市ID
date string 日期 默认为昨天 格式为:2018-01-01

返回参数:

参数名称类型说明
cityid int 城市ID
cityname string 城市
date string 日期
weather string 天气
temphigh string 最高气温
templow string 最低气温
img string 图片数字
humidity string 湿度
pressure string 气压
windspeed string 风速
windpower string 风级
sunrise string 日出时间
sunset string 日落时间
aqi string AQI指数
primarypollutant string 首要污染物

请求代码:

查看代码
<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$city = '安顺';//utf8
$cityid='111';//任选
$url = "https://api.binstd.com/weather2/query?appkey=$appkey&city=$city";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

$result = $jsonarr['result'];
echo $result['cityid'].' '.$result['date'].' '.$result['weather'].' '.$result['temphigh'].' '.$result['templow'].' '.$result['img'].' '.$result['humidity'].' '.$result['pressure'].' '.$result['windspeed'].' '.$result['winddirect'].' '.$result['windpower'].' '.$result['sunrise'].' '.$result['sunset'].' '.$result['aqi'].' '.$result['primarypollutant'].' '.$result['cityname'];
                    

JSON返回示例 :

{
    "status": "0",
    "msg": "ok",
    "result": {
        "cityid": "111",
        "date": "2018-01-01",
        "weather": "阴",
        "temphigh": "8",
        "templow": "4",
        "img": "2",
        "humidity": "98",
        "pressure": "856",
        "windspeed": "1.8",
        "winddirect": "东风",
        "windpower": "2级",
        "sunrise": "07:44",
        "sunset": "18:15",
        "aqi": "29",
        "primarypollutant": "PM10",
        "cityname": "安顺"
    }
}
                    

API错误码:

代号说明
201 城市和城市ID都为空
202 城市不存在
203 查询日期为空
204 日期格式不正确
210 没有信息

系统错误码:

代号说明
101 APPKEY为空或不存在
102 APPKEY已过期
103 APPKEY无请求此数据权限
104 请求超过次数限制
105 IP被禁止
106 IP请求超过限制
107 接口维护中
108 接口已停用
名称权限价格

活动推荐ACTIVITY 更多

  • orc活动

热门API接口推荐RECOMMENDED DATA 更多

开通BinSTD会员

开通账号:

×

会员类型:

  • 会员

会员时长:

  • 按年付

总金额:

  • ¥ 600.00元原价:900.00元
  • ¥ 300.00元原价:450.00元
  • ¥ 50.00元原价:75.00元
  • ¥ 100.00元原价:150.00元
  • ¥ 150.00元原价:225.00元
  • ¥ 200.00元原价:300.00元
  • ¥ 250.00元原价:375.00元