接口地址:https://api.tongsir.cn/api/wether.php
返回格式:JSON
请求方式:get
请求示例:https://api.tongsir.cn/api/wether.php?ip=114.115.116.117

请求参数说明:

名称 必填 类型 说明
  ip string 输入ip地址,如:114.115.116.117

返回参数说明:

名称 类型 说明
  city string 城市
  updatetime string 更新时间
  wendu string 温度
  fengli string 风力
  shidu string 湿度
  fengxiang string 风向
  environment 数组 建议

返回示例:

{
    "city":"郑州",
    "updatetime":"13:21",
    "wendu":"9",
    "fengli":"2级",
    "shidu":"47%",
    "fengxiang":"东北风",
    "sunrise_1":"07:29",
    "sunset_1":"17:18",
    "sunrise_2":[

    ],
    "sunset_2":[

    ],
    "environment":{
        "aqi":"335",
        "pm25":"284",
        "suggest":"老年人病人应留在室内,停止体力消耗,一般人群避免户外活动",
        "quality":"严重污染",
        "MajorPollutants":"颗粒物(PM2.5)",
        "o3":"19",
        "co":"3",
        "pm10":"342",
        "so2":"30",
        "no2":"91",
        "time":"13:00:00"
    },
    "yesterday":{
        "date_1":"20日星期四",
        "high_1":"高温 10℃",
        "low_1":"低温 2℃",
        "day_1":{
            "type_1":"多云",
            "fx_1":"东风",
            "fl_1":"<3级"
        },
        "night_1":{
            "type_1":"多云",
            "fx_1":"西风",
            "fl_1":"<3级"
        }
    },
    "forecast":{
        "weather":[
            {
                "date":"21日星期五",
                "high":"高温 12℃",
                "low":"低温 3℃",
                "day":{
                    "type":"多云",
                    "fengxiang":"东北风",
                    "fengli":"3-4级"
                },
                "night":{
                    "type":"阴",
                    "fengxiang":"西北风",
                    "fengli":"<3级"
                }
            },
            {
                "date":"22日星期六",
                "high":"高温 10℃",
                "low":"低温 1℃",
                "day":{
                    "type":"多云",
                    "fengxiang":"西北风",
                    "fengli":"<3级"
                },
                "night":{
                    "type":"多云",
                    "fengxiang":"西北风",
                    "fengli":"<3级"
                }
            },
            {
                "date":"23日星期天",
                "high":"高温 5℃",
                "low":"低温 -2℃",
                "day":{
                    "type":"多云",
                    "fengxiang":"东北风",
                    "fengli":"3-4级"
                },
                "night":{
                    "type":"多云",
                    "fengxiang":"东北风",
                    "fengli":"<3级"
                }
            },
            {
                "date":"24日星期一",
                "high":"高温 4℃",
                "low":"低温 -1℃",
                "day":{
                    "type":"阴",
                    "fengxiang":"南风",
                    "fengli":"<3级"
                },
                "night":{
                    "type":"多云",
                    "fengxiang":"西南风",
                    "fengli":"<3级"
                }
            },
            {
                "date":"25日星期二",
                "high":"高温 10℃",
                "low":"低温 -1℃",
                "day":{
                    "type":"多云",
                    "fengxiang":"北风",
                    "fengli":"<3级"
                },
                "night":{
                    "type":"多云",
                    "fengxiang":"东北风",
                    "fengli":"3-4级"
                }
            }
        ]
    },
    "zhishus":{
        "zhishu":[
            {
                "name":"晨练指数",
                "value":"较不宜",
                "detail":"风力稍大,较不宜晨练,室外锻炼请注意选择避风的地点,避免迎风锻炼。"
            },
            {
                "name":"舒适度",
                "value":"较舒适",
                "detail":"白天天气晴好,早晚会感觉偏凉,午后舒适、宜人。"
            },
            {
                "name":"穿衣指数",
                "value":"较冷",
                "detail":"建议着厚外套加毛衣等服装。年老体弱者宜着大衣、呢外套加羊毛衫。"
            },
            {
                "name":"感冒指数",
                "value":"较易发",
                "detail":"昼夜温差较大,较易发生感冒,请适当增减衣服。体质较弱的朋友请注意防护。"
            },
            {
                "name":"晾晒指数",
                "value":"基本适宜",
                "detail":"天气不错,午后温暖的阳光仍能满足你驱潮消霉杀菌的晾晒需求。"
            },
            {
                "name":"旅游指数",
                "value":"适宜",
                "detail":"天气较好,温度适宜,但风稍微有点大。这样的天气适宜旅游,您可以尽情地享受大自然的无限风光。"
            },
            {
                "name":"紫外线强度",
                "value":"最弱",
                "detail":"属弱紫外线辐射天气,无需特别防护。若长期在户外,建议涂擦SPF在8-12之间的防晒护肤品。"
            },
            {
                "name":"洗车指数",
                "value":"较适宜",
                "detail":"较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。"
            },
            {
                "name":"运动指数",
                "value":"较不宜",
                "detail":"天气较好,但考虑天气寒冷,风力较强,推荐您进行室内运动,若户外运动请注意保暖并做好准备活动。"
            },
            {
                "name":"约会指数",
                "value":"较适宜",
                "detail":"虽然有点风,但情侣们可以放心外出,不用担心天气来调皮捣乱而影响了兴致。"
            },
            {
                "name":"雨伞指数",
                "value":"不带伞",
                "detail":"天气较好,不会降水,因此您可放心出门,无须带雨伞。"
            }
        ]
    }
}

服务级错误码参照(error_code):

  错误码 说明
  102 IP不能为空!

系统级错误码参照:

  错误码 说明 旧版本(resultcode)
  102 ip为空 102

错误码格式说明(示例:200201):

  2 002 01
  服务级错误(1为系统级错误) 服务模块代码(即数据ID) 具体错误代码

PHP演示:


header('Location:https://api.tongsir.cn/api/wether.php?ip=xxx.xxx.xxx.xxx');
?>