天天看点

漂亮的天气预报,天气预报API,7天精准天气预报API JSON天气预报效果图

为了完善天气预报功能模块,我开发了一套数据量较为全的天气预报,主要为全国主要城市预报。地址为:http://www.sojson.com/tianqi/

首先首页是个定位功能,然后根据定位查询天气。当定位不准,或者定位到的城市没有在我的城市范围内,那么就采用本省的省会做为天气预报城市,这里比较粗糙。

天气预报效果图

天气预报,我设置了几个背景效果,分为:天晴,下雨,污染雾霾,下雪,等几个背景效果。

天气晴朗效果图:

漂亮的天气预报,天气预报API,7天精准天气预报API JSON天气预报效果图

天气下雨效果图

漂亮的天气预报,天气预报API,7天精准天气预报API JSON天气预报效果图

其他的自己体验。

天气API接口说明

接口链接:

http://www.sojson.com/tianqi/api/1011-58414.shtml

参数说明:

1011-58414

,第一个是省ID,第二个是城市ID。

返回说明:返回以  JSON  格式返回。

天气API 返回值如下:

{
        "updateTime": 1496988312667,
        "alert": "2017年06月09日06时安徽省安庆市太湖县发布雷电黄色预警",
        "temperature": 24.4,
        "rain": 0.1,
        "humidity": 97,
        "weatherInfo": "大雨",
        "feelst": 23.4,
        "icomfort": {
            "text": "温暖,较舒适",
            "color": "#00a44f",
            "value": "1"
        },
        "airpressure": 996,
        "speed": 1.9,
        "direct": "西南风",
        "power": "微风",
        "title": "6小时内我县可能发生雷电活动,请注意防范。",
        "description": "1.政府及相关部门按照职责做好防雷工作;\n2.密切关注天气,尽量避免户外活动。",
        "aqi": {
            "aqi": "26.0",
            "aq": "1",
            "info": "优",
            "description": "空气质量令人满意,基本无空气污染。",
            "color": "#32f43e"
        },
        "day7": [
            {
                "date": {
                    "date": "今天",
                    "md": "06月09日",
                    "week": "星期五"
                },
                "day": {
                    "wicon": "9",
                    "wdesc": "大雨",
                    "temp": "28℃",
                    "direct": "南风",
                    "wind": "微风"
                },
                "night": {
                    "wicon": "8",
                    "wdesc": "中雨",
                    "temp": "23℃",
                    "direct": "南风",
                    "wind": "微风"
                },
                "details": {
                    "hour": [
                        "17:00",
                        "20:00",
                        "23:00",
                        "10日02:00",
                        "05:00",
                        "08:00",
                        "11:00",
                        "14:00"
                    ],
                    "wicon": [
                        "8",
                        "8",
                        "8",
                        "7",
                        "7",
                        "8",
                        "7",
                        "7"
                    ],
                    "temp": [
                        "24.2℃",
                        "23.2℃",
                        "23.4℃",
                        "25.7℃",
                        "27.3℃",
                        "24.6℃",
                        "28.5℃",
                        "29.8℃"
                    ],
                    "rainfall": [
                        "5.5毫米",
                        "8.9毫米",
                        "3.9毫米",
                        "1毫米",
                        "0.5毫米",
                        "8毫米",
                        "2.3毫米",
                        "1.3毫米"
                    ],
                    "wind_speed": [
                        "0.4米/秒",
                        "0.6米/秒",
                        "1米/秒",
                        "1.8米/秒",
                        "3.1米/秒",
                        "3.4米/秒",
                        "3.7米/秒",
                        "2.6米/秒"
                    ],
                    "wind_direction": [
                        "东风",
                        "东南风",
                        "东南风",
                        "南风",
                        "西南风",
                        "西南风",
                        "西风",
                        "西风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "95.1%",
                        "95.6%",
                        "98%",
                        "97.1%",
                        "93.7%",
                        "83%",
                        "85.6%",
                        "94.7%"
                    ],
                    "cloudage": [
                        "90.7%",
                        "70%",
                        "72.9%",
                        "100%",
                        "85.5%",
                        "70%",
                        "70%",
                        "70%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            },
            {
                "date": {
                    "date": "明 天",
                    "md": "06月10日",
                    "week": "星期六"
                },
                "day": {
                    "wicon": "7",
                    "wdesc": "小雨",
                    "temp": "30℃",
                    "direct": "西南风",
                    "wind": "微风"
                },
                "night": {
                    "wicon": "4",
                    "wdesc": "雷阵雨",
                    "temp": "21℃",
                    "direct": "西南风",
                    "wind": "微风"
                },
                "details": {
                    "hour": [
                        "08:00",
                        "11:00",
                        "14:00",
                        "17:00",
                        "20:00",
                        "23:00",
                        "11日02:00",
                        "05:00"
                    ],
                    "wicon": [
                        "8",
                        "7",
                        "7",
                        "8",
                        "7",
                        "4",
                        "4",
                        "4"
                    ],
                    "temp": [
                        "24.6℃",
                        "28.5℃",
                        "29.8℃",
                        "27.6℃",
                        "26.2℃",
                        "24.3℃",
                        "24.1℃",
                        "22.6℃"
                    ],
                    "rainfall": [
                        "8毫米",
                        "2.3毫米",
                        "1.3毫米",
                        "6.1毫米",
                        "0.1毫米",
                        "0.5毫米",
                        "0.5毫米",
                        "0.3毫米"
                    ],
                    "wind_speed": [
                        "3.4米/秒",
                        "3.7米/秒",
                        "2.6米/秒",
                        "2米/秒",
                        "1.4米/秒",
                        "0.8米/秒",
                        "1.2米/秒",
                        "2.2米/秒"
                    ],
                    "wind_direction": [
                        "西南风",
                        "西风",
                        "西风",
                        "西南风",
                        "西南风",
                        "南风",
                        "南风",
                        "南风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "83%",
                        "85.6%",
                        "94.7%",
                        "94.9%",
                        "95%",
                        "98.7%",
                        "98.7%",
                        "96%"
                    ],
                    "cloudage": [
                        "70%",
                        "70%",
                        "70%",
                        "70%",
                        "42%",
                        "56.9%",
                        "99.9%",
                        "100%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            },
            {
                "date": {
                    "date": "后 天",
                    "md": "06月11日",
                    "week": "星期日"
                },
                "day": {
                    "wicon": "4",
                    "wdesc": "雷阵雨",
                    "temp": "25℃",
                    "direct": "东北风",
                    "wind": "4~5级"
                },
                "night": {
                    "wicon": "4",
                    "wdesc": "雷阵雨",
                    "temp": "20℃",
                    "direct": "东风",
                    "wind": "4~5级"
                },
                "details": {
                    "hour": [
                        "08:00",
                        "11:00",
                        "14:00",
                        "17:00",
                        "20:00",
                        "23:00",
                        "12日02:00",
                        "05:00"
                    ],
                    "wicon": [
                        "4",
                        "4",
                        "4",
                        "4",
                        "1",
                        "1",
                        "1",
                        "4"
                    ],
                    "temp": [
                        "21.2℃",
                        "24.8℃",
                        "22.5℃",
                        "22.4℃",
                        "22.3℃",
                        "21.8℃",
                        "21.4℃",
                        "20.8℃"
                    ],
                    "rainfall": [
                        "0.2毫米",
                        "1.2毫米",
                        "1.9毫米",
                        "0.1毫米",
                        "无降水",
                        "无降水",
                        "无降水",
                        "0.1毫米"
                    ],
                    "wind_speed": [
                        "3.4米/秒",
                        "2米/秒",
                        "1.4米/秒",
                        "1.1米/秒",
                        "1.5米/秒",
                        "1.5米/秒",
                        "1.6米/秒",
                        "1.5米/秒"
                    ],
                    "wind_direction": [
                        "西南风",
                        "西风",
                        "东北风",
                        "东北风",
                        "东风",
                        "东北风",
                        "东北风",
                        "东北风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "85.5%",
                        "93.5%",
                        "95.6%",
                        "99.8%",
                        "98.3%",
                        "99%",
                        "98.9%",
                        "98.5%"
                    ],
                    "cloudage": [
                        "99.4%",
                        "100%",
                        "100%",
                        "47.4%",
                        "45.6%",
                        "45.9%",
                        "55.3%",
                        "100%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            },
            {
                "date": {
                    "md": "06月12日",
                    "week": "星期一"
                },
                "day": {
                    "wicon": "2",
                    "wdesc": "阴",
                    "temp": "25℃",
                    "direct": "东风",
                    "wind": "微风"
                },
                "night": {
                    "wicon": "1",
                    "wdesc": "多云",
                    "temp": "19℃",
                    "direct": "东北风",
                    "wind": "微风"
                },
                "details": {
                    "hour": [
                        "08:00",
                        "11:00",
                        "14:00",
                        "17:00",
                        "20:00",
                        "23:00",
                        "13日02:00",
                        "05:00"
                    ],
                    "wicon": [
                        "4",
                        "2",
                        "2",
                        "2",
                        "2",
                        "1",
                        "1",
                        "1"
                    ],
                    "temp": [
                        "20.2℃",
                        "21.4℃",
                        "24.8℃",
                        "22.7℃",
                        "23.4℃",
                        "22.8℃",
                        "22.2℃",
                        "19.4℃"
                    ],
                    "rainfall": [
                        "0.1毫米",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水"
                    ],
                    "wind_speed": [
                        "1.6米/秒",
                        "1.8米/秒",
                        "2.5米/秒",
                        "3米/秒",
                        "2.3米/秒",
                        "2米/秒",
                        "2米/秒",
                        "1.8米/秒"
                    ],
                    "wind_direction": [
                        "东北风",
                        "东北风",
                        "东北风",
                        "东北风",
                        "东风",
                        "东北风",
                        "东北风",
                        "东北风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "93.1%",
                        "80.2%",
                        "82.9%",
                        "89.2%",
                        "85%",
                        "88.6%",
                        "90.2%",
                        "93.8%"
                    ],
                    "cloudage": [
                        "91.1%",
                        "83.7%",
                        "95.4%",
                        "94.5%",
                        "94%",
                        "79.9%",
                        "79.9%",
                        "79.9%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            },
            {
                "date": {
                    "md": "06月13日",
                    "week": "星期二"
                },
                "day": {
                    "wicon": "1",
                    "wdesc": "多云",
                    "temp": "26℃",
                    "direct": "东北风",
                    "wind": "4~5级"
                },
                "night": {
                    "wicon": "1",
                    "wdesc": "多云",
                    "temp": "19℃",
                    "direct": "东北风",
                    "wind": "4~5级"
                },
                "details": {
                    "hour": [
                        "08:00",
                        "11:00",
                        "14:00",
                        "17:00",
                        "20:00",
                        "23:00",
                        "14日02:00",
                        "05:00"
                    ],
                    "wicon": [
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "1"
                    ],
                    "temp": [
                        "19.2℃",
                        "21.2℃",
                        "20.1℃",
                        "19.2℃",
                        "21.2℃",
                        "25.8℃",
                        "22.4℃",
                        "20.9℃"
                    ],
                    "rainfall": [
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水"
                    ],
                    "wind_speed": [
                        "2.1米/秒",
                        "2.1米/秒",
                        "2.3米/秒",
                        "2.1米/秒",
                        "1.8米/秒",
                        "3.3米/秒",
                        "1.8米/秒",
                        "2米/秒"
                    ],
                    "wind_direction": [
                        "东北风",
                        "东北风",
                        "东北风",
                        "东北风",
                        "东风",
                        "东北风",
                        "东北风",
                        "东北风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "91.4%",
                        "91.9%",
                        "92.1%",
                        "88.9%",
                        "85.8%",
                        "86.5%",
                        "89.4%",
                        "85.2%"
                    ],
                    "cloudage": [
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "72.5%",
                        "79.9%",
                        "79.9%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            },
            {
                "date": {
                    "md": "06月14日",
                    "week": "星期三"
                },
                "day": {
                    "wicon": "1",
                    "wdesc": "多云",
                    "temp": "25℃",
                    "direct": "东北风",
                    "wind": "3~4级"
                },
                "night": {
                    "wicon": "1",
                    "wdesc": "多云",
                    "temp": "20℃",
                    "direct": "东北风",
                    "wind": "3~4级"
                },
                "details": {
                    "hour": [
                        "08:00",
                        "11:00",
                        "14:00",
                        "17:00",
                        "20:00",
                        "23:00",
                        "15日02:00",
                        "05:00"
                    ],
                    "wicon": [
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "1"
                    ],
                    "temp": [
                        "20.6℃",
                        "24.8℃",
                        "23.2℃",
                        "22.9℃",
                        "22.6℃",
                        "21.9℃",
                        "21.8℃",
                        "21.6℃"
                    ],
                    "rainfall": [
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水"
                    ],
                    "wind_speed": [
                        "2米/秒",
                        "2.5米/秒",
                        "2.3米/秒",
                        "1.1米/秒",
                        "1.8米/秒",
                        "2米/秒",
                        "1.8米/秒",
                        "1.2米/秒"
                    ],
                    "wind_direction": [
                        "东北风",
                        "东风",
                        "东风",
                        "东北风",
                        "东北风",
                        "东北风",
                        "东北风",
                        "东北风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "77.2%",
                        "79.6%",
                        "81.1%",
                        "84%",
                        "83.2%",
                        "91.6%",
                        "90%",
                        "88.4%"
                    ],
                    "cloudage": [
                        "79.9%",
                        "65.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            },
            {
                "date": {
                    "md": "06月15日",
                    "week": "星期四"
                },
                "day": {
                    "wicon": "1",
                    "wdesc": "多云",
                    "temp": "25℃",
                    "direct": "东风",
                    "wind": "微风"
                },
                "night": {
                    "wicon": "10",
                    "wdesc": "暴雨",
                    "temp": "17℃",
                    "direct": "无持续风向",
                    "wind": "微风"
                },
                "details": {
                    "hour": [
                        "08:00",
                        "11:00",
                        "14:00",
                        "17:00",
                        "20:00",
                        "23:00",
                        "16日02:00",
                        "05:00"
                    ],
                    "wicon": [
                        "1",
                        "1",
                        "1",
                        "1",
                        "1",
                        "2",
                        "2",
                        "2"
                    ],
                    "temp": [
                        "20.2℃",
                        "24.8℃",
                        "22.6℃",
                        "20.6℃",
                        "20.6℃",
                        "20.6℃",
                        "20.2℃",
                        "19.5℃"
                    ],
                    "rainfall": [
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水",
                        "无降水"
                    ],
                    "wind_speed": [
                        "1.6米/秒",
                        "1.5米/秒",
                        "1.6米/秒",
                        "0.1米/秒",
                        "1.6米/秒",
                        "1.2米/秒",
                        "1.5米/秒",
                        "1.9米/秒"
                    ],
                    "wind_direction": [
                        "东风",
                        "东风",
                        "东北风",
                        "东北风",
                        "东北风",
                        "北风",
                        "北风",
                        "东北风"
                    ],
                    "pressure": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [
                        "77%",
                        "79%",
                        "80.3%",
                        "81.7%",
                        "85.5%",
                        "89.4%",
                        "90%",
                        "84.7%"
                    ],
                    "cloudage": [
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "79.9%",
                        "100%",
                        "100%",
                        "91.4%"
                    ],
                    "visibility": [
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            }
        ]
    }
           

返回值较大,主要就是对应的七天天气,以及 七天的精准天气说明。下面为您把接口参数一一说明意思。

天气接口API 参数说明

{
        "updateTime": 1496988312667,//更新时间,一般1小时以内
        "alert": "2017年06月09日06时安徽省安庆市太湖县发布雷电黄色预警",//是否有天气预警
        "temperature": 24.4,//气温
        "rain": 0.1,//降水
        "humidity": 97,//相对湿度
        "weatherInfo": "大雨",//天气说明
        "feelst": 23.4,//体感温度
        "icomfort": {//舒适度
            "text": "温暖,较舒适",
            "color": "#00a44f",
            "value": "1"//舒适度级别
        },
        "airpressure": 996,//气压
        "speed": 1.9,//风速多少米/秒
        "direct": "西南风",//风向
        "power": "微风",//风力
        "title": "6小时内我县可能发生雷电活动,请注意防范。",//预警标题
        "description": "1.政府及相关部门按照职责做好防雷工作;\n2.密切关注天气,尽量避免户外活动。",//预警内容
        "aqi": {//空气质量
            "aqi": "26.0",//空气指数
            "aq": "1",//空气级别
            "info": "优",//空气指数对应级别描述
            "description": "空气质量令人满意,基本无空气污染。",//空气污染对人身伤害描述
            "color": "#32f43e"//对应的颜色表示
        },
    	//七天的天气,这里列了一个,这是一个数组,一共有7个Element
        "day7": [
            {
                "date": {
                    "date": "今天",//哪一天
                    "md": "06月09日",//哪一天日期
                    "week": "星期五"//星期
                },
                "day": {//白天
                    "wicon": "9",//天气标示
                    "wdesc": "大雨",//天气
                    "temp": "28℃",//温度
                    "direct": "南风",//风向
                    "wind": "微风"//风大小
                },
                "night": {
                    "wicon": "8",//天气标示
                    "wdesc": "中雨",//天气
                    "temp": "23℃",//温度
                    "direct": "南风",//风向
                    "wind": "微风"//风大小
                },
                "details": {
                    "hour": [//对应当天8个时间段
                        "17:00",
                        "20:00",
                        "23:00",
                        "10日02:00",
                        "05:00",
                        "08:00",
                        "11:00",
                        "14:00"
                    ],
                    "wicon": [//对应当天8个时间段天气标示
                        "8",
                        "8",
                        "8",
                        "7",
                        "7",
                        "8",
                        "7",
                        "7"
                    ],
                    "temp": [//对应当天8个时间段温度
                        "24.2℃",
                        "23.2℃",
                        "23.4℃",
                        "25.7℃",
                        "27.3℃",
                        "24.6℃",
                        "28.5℃",
                        "29.8℃"
                    ],
                    "rainfall": [//对应当天8个时间段降水
                        "5.5毫米",
                        "8.9毫米",
                        "3.9毫米",
                        "1毫米",
                        "0.5毫米",
                        "8毫米",
                        "2.3毫米",
                        "1.3毫米"
                    ],
                    "wind_speed": [//对应当天8个时间段风速
                        "0.4米/秒",
                        "0.6米/秒",
                        "1米/秒",
                        "1.8米/秒",
                        "3.1米/秒",
                        "3.4米/秒",
                        "3.7米/秒",
                        "2.6米/秒"
                    ],
                    "wind_direction": [//对应当天8个时间段风向
                        "东风",
                        "东南风",
                        "东南风",
                        "南风",
                        "西南风",
                        "西南风",
                        "西风",
                        "西风"
                    ],
                    "pressure": [//对应当天8个时间段气压
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ],
                    "humidity": [//对应当天8个时间段湿度
                        "95.1%",
                        "95.6%",
                        "98%",
                        "97.1%",
                        "93.7%",
                        "83%",
                        "85.6%",
                        "94.7%"
                    ],
                    "cloudage": [//对应当天8个时间段云量
                        "90.7%",
                        "70%",
                        "72.9%",
                        "100%",
                        "85.5%",
                        "70%",
                        "70%",
                        "70%"
                    ],
                    "visibility": [//对应当天8个时间段可见度
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-",
                        "-"
                    ]
                }
            }
    		//这里还有6个,省略了,一样
        ]
    }
           

个人使用,请勿商用。

转载注明出处:本文来自sojson在线工具,JSON在线解析的:http://www.sojson.com/blog/237.html