{
    "openapi": "3.0.0",
    "info": {
        "title": "天气预报 - API文档",
        "version": "1.0.0",
        "description": "支持根据国内城市天气ID（建议）、行政区划代码、城市名称（市区县级）、IP地址，查询天气状态和空气质量及天气预警消息。通过type参数传值1查询实时天气预报及空气质量指数，传值7可查询七天内天气详情。查询详细AQI空气质量指数可使用<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/apiview\/178\">空气质量<\/a>接口。推荐和<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/apiview\/91\">天气古诗句<\/a>接口配合使用，可以让天气类应用更有意境。天气状态代码和图标文件请<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/article\/164\">点此查看<\/a>，查询城市天气ID使用<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/apiview\/239\">地区搜索<\/a>接口。"
    },
    "servers": [
        {
            "url": "https:\/\/apis.tianapi.com"
        }
    ],
    "paths": {
        "\/tianqi\/index": {
            "get": {
                "summary": "实时及七天",
                "tags": [
                    "天气预报"
                ],
                "description": "根据城市名称查询实时或七天内天气预报",
                "parameters": [
                    {
                        "name": "key",
                        "in": "query",
                        "description": "API密钥",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "description": "API密钥"
                        }
                    },
                    {
                        "name": "city",
                        "in": "query",
                        "description": "城市天气ID、行政代码、城市名称、IP地址",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "example": "101020100",
                            "description": "城市天气ID、行政代码、城市名称、IP地址"
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "description": "查询类型，实时1，七天7",
                        "required": true,
                        "schema": {
                            "type": "int",
                            "example": 1,
                            "description": "查询类型，实时1，七天7"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "aqi": {
                                            "type": "string",
                                            "example": "34",
                                            "description": "空气质量指数（七天无此字段）"
                                        },
                                        "vis": {
                                            "type": "string",
                                            "example": "9",
                                            "description": "能见度（公里）"
                                        },
                                        "area": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "结果地区（市\/区\/县）"
                                        },
                                        "date": {
                                            "type": "string",
                                            "example": "2020-05-23",
                                            "description": "日期"
                                        },
                                        "pcpn": {
                                            "type": "string",
                                            "example": "0.0",
                                            "description": "降雨量（毫米）"
                                        },
                                        "real": {
                                            "type": "string",
                                            "example": "18℃",
                                            "description": "实时气温（七天为估测）"
                                        },
                                        "tips": {
                                            "type": "string",
                                            "example": "天气暖和，适宜着单层......",
                                            "description": "生活指数提示"
                                        },
                                        "week": {
                                            "type": "string",
                                            "example": "星期一",
                                            "description": "星期"
                                        },
                                        "wind": {
                                            "type": "string",
                                            "example": "东南风",
                                            "description": "风向（方位）"
                                        },
                                        "+city": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "预警城市"
                                        },
                                        "+time": {
                                            "type": "string",
                                            "example": "2020-05-23 20:30:00",
                                            "description": "预警时间"
                                        },
                                        "+type": {
                                            "type": "string",
                                            "example": "大雾",
                                            "description": "预警类型"
                                        },
                                        "+level": {
                                            "type": "string",
                                            "example": "黄色",
                                            "description": "预警级别"
                                        },
                                        "areaid": {
                                            "type": "string",
                                            "example": "101020100",
                                            "description": "城市天气ID"
                                        },
                                        "lowest": {
                                            "type": "string",
                                            "example": "6℃",
                                            "description": "最低温（夜间温度）"
                                        },
                                        "sunset": {
                                            "type": "string",
                                            "example": "18:31",
                                            "description": "日落时间"
                                        },
                                        "windsc": {
                                            "type": "string",
                                            "example": "1-2级",
                                            "description": "风力"
                                        },
                                        "highest": {
                                            "type": "string",
                                            "example": "22℃",
                                            "description": "最高温（日间温度）"
                                        },
                                        "quality": {
                                            "type": "string",
                                            "example": "优",
                                            "description": "空气质量提示（七天无此字段）"
                                        },
                                        "sunrise": {
                                            "type": "string",
                                            "example": "06:10",
                                            "description": "日出时间"
                                        },
                                        "weather": {
                                            "type": "string",
                                            "example": "晴转多云",
                                            "description": "天气状况"
                                        },
                                        "+content": {
                                            "type": "string",
                                            "example": "上海中心气象台发布大雾黄色预警信号...",
                                            "description": "预警内容"
                                        },
                                        "humidity": {
                                            "type": "string",
                                            "example": "23",
                                            "description": "相对湿度（百分比）"
                                        },
                                        "moondown": {
                                            "type": "string",
                                            "example": "17:22",
                                            "description": "月落时间"
                                        },
                                        "moonrise": {
                                            "type": "string",
                                            "example": "06:02",
                                            "description": "月升时间"
                                        },
                                        "province": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "所属省份"
                                        },
                                        "uv_index": {
                                            "type": "string",
                                            "example": "9",
                                            "description": "紫外线强度指数"
                                        },
                                        "+province": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "预警省份"
                                        },
                                        "alarmlist": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            },
                                            "example": "[]",
                                            "description": "天气预警列表（七天无此字段）"
                                        },
                                        "windspeed": {
                                            "type": "string",
                                            "example": "7",
                                            "description": "风速（km\/h）"
                                        },
                                        "weatherimg": {
                                            "type": "string",
                                            "example": "duoyun.png",
                                            "description": "天气图标（废弃）"
                                        },
                                        "weathercode": {
                                            "type": "string",
                                            "example": "qing_duoyun",
                                            "description": "天气过程代码"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "aqi": "34",
                                        "vis": "25",
                                        "area": "上海市",
                                        "date": "2020-05-23",
                                        "pcpn": "0.0",
                                        "real": "18℃",
                                        "tips": "天气暖和，适宜着单层棉麻面料的短套装、T恤衫、薄牛仔衫裤、休闲服、职业套装等春秋过渡装。年老体弱者请适当增减衣服。空气质量优秀，快去户外呼吸清新空气吧。",
                                        "week": "星期二",
                                        "wind": "东北风",
                                        "areaid": "101020100",
                                        "lowest": "6℃",
                                        "sunset": "18:31",
                                        "windsc": "1-2级",
                                        "highest": "22℃",
                                        "quality": "优",
                                        "sunrise": "06:10",
                                        "weather": "晴转多云",
                                        "humidity": "23",
                                        "moondown": "17:22",
                                        "moonrise": "06:02",
                                        "province": "上海市",
                                        "uv_index": "9",
                                        "alarmlist": [
                                            {
                                                "city": "上海市",
                                                "time": "2020-05-23 20:30:00",
                                                "type": "大雾",
                                                "level": "黄色",
                                                "content": "上海中心气象台2020年05月23日20时30分发布大雾黄色预警信号：预计今天下半夜到明天早晨本市大部郊区将出现能见度小于500米的雾，局部地区小于200米，请注意防范。",
                                                "province": "上海市"
                                            }
                                        ],
                                        "windspeed": "7",
                                        "weatherimg": "duoyun.png",
                                        "weathercode": "qing_duoyun"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "实时及七天",
                "tags": [
                    "天气预报"
                ],
                "description": "根据城市名称查询实时或七天内天气预报",
                "requestBody": {
                    "content": {
                        "application\/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API密钥"
                                    },
                                    "city": {
                                        "type": "string",
                                        "example": "101020100",
                                        "description": "城市天气ID、行政代码、城市名称、IP地址"
                                    },
                                    "type": {
                                        "type": "int",
                                        "example": 1,
                                        "description": "查询类型，实时1，七天7"
                                    }
                                },
                                "required": [
                                    "key",
                                    "city",
                                    "type"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "aqi": {
                                            "type": "string",
                                            "example": "34",
                                            "description": "空气质量指数（七天无此字段）"
                                        },
                                        "vis": {
                                            "type": "string",
                                            "example": "9",
                                            "description": "能见度（公里）"
                                        },
                                        "area": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "结果地区（市\/区\/县）"
                                        },
                                        "date": {
                                            "type": "string",
                                            "example": "2020-05-23",
                                            "description": "日期"
                                        },
                                        "pcpn": {
                                            "type": "string",
                                            "example": "0.0",
                                            "description": "降雨量（毫米）"
                                        },
                                        "real": {
                                            "type": "string",
                                            "example": "18℃",
                                            "description": "实时气温（七天为估测）"
                                        },
                                        "tips": {
                                            "type": "string",
                                            "example": "天气暖和，适宜着单层......",
                                            "description": "生活指数提示"
                                        },
                                        "week": {
                                            "type": "string",
                                            "example": "星期一",
                                            "description": "星期"
                                        },
                                        "wind": {
                                            "type": "string",
                                            "example": "东南风",
                                            "description": "风向（方位）"
                                        },
                                        "+city": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "预警城市"
                                        },
                                        "+time": {
                                            "type": "string",
                                            "example": "2020-05-23 20:30:00",
                                            "description": "预警时间"
                                        },
                                        "+type": {
                                            "type": "string",
                                            "example": "大雾",
                                            "description": "预警类型"
                                        },
                                        "+level": {
                                            "type": "string",
                                            "example": "黄色",
                                            "description": "预警级别"
                                        },
                                        "areaid": {
                                            "type": "string",
                                            "example": "101020100",
                                            "description": "城市天气ID"
                                        },
                                        "lowest": {
                                            "type": "string",
                                            "example": "6℃",
                                            "description": "最低温（夜间温度）"
                                        },
                                        "sunset": {
                                            "type": "string",
                                            "example": "18:31",
                                            "description": "日落时间"
                                        },
                                        "windsc": {
                                            "type": "string",
                                            "example": "1-2级",
                                            "description": "风力"
                                        },
                                        "highest": {
                                            "type": "string",
                                            "example": "22℃",
                                            "description": "最高温（日间温度）"
                                        },
                                        "quality": {
                                            "type": "string",
                                            "example": "优",
                                            "description": "空气质量提示（七天无此字段）"
                                        },
                                        "sunrise": {
                                            "type": "string",
                                            "example": "06:10",
                                            "description": "日出时间"
                                        },
                                        "weather": {
                                            "type": "string",
                                            "example": "晴转多云",
                                            "description": "天气状况"
                                        },
                                        "+content": {
                                            "type": "string",
                                            "example": "上海中心气象台发布大雾黄色预警信号...",
                                            "description": "预警内容"
                                        },
                                        "humidity": {
                                            "type": "string",
                                            "example": "23",
                                            "description": "相对湿度（百分比）"
                                        },
                                        "moondown": {
                                            "type": "string",
                                            "example": "17:22",
                                            "description": "月落时间"
                                        },
                                        "moonrise": {
                                            "type": "string",
                                            "example": "06:02",
                                            "description": "月升时间"
                                        },
                                        "province": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "所属省份"
                                        },
                                        "uv_index": {
                                            "type": "string",
                                            "example": "9",
                                            "description": "紫外线强度指数"
                                        },
                                        "+province": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "预警省份"
                                        },
                                        "alarmlist": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            },
                                            "example": "[]",
                                            "description": "天气预警列表（七天无此字段）"
                                        },
                                        "windspeed": {
                                            "type": "string",
                                            "example": "7",
                                            "description": "风速（km\/h）"
                                        },
                                        "weatherimg": {
                                            "type": "string",
                                            "example": "duoyun.png",
                                            "description": "天气图标（废弃）"
                                        },
                                        "weathercode": {
                                            "type": "string",
                                            "example": "qing_duoyun",
                                            "description": "天气过程代码"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "aqi": "34",
                                        "vis": "25",
                                        "area": "上海市",
                                        "date": "2020-05-23",
                                        "pcpn": "0.0",
                                        "real": "18℃",
                                        "tips": "天气暖和，适宜着单层棉麻面料的短套装、T恤衫、薄牛仔衫裤、休闲服、职业套装等春秋过渡装。年老体弱者请适当增减衣服。空气质量优秀，快去户外呼吸清新空气吧。",
                                        "week": "星期二",
                                        "wind": "东北风",
                                        "areaid": "101020100",
                                        "lowest": "6℃",
                                        "sunset": "18:31",
                                        "windsc": "1-2级",
                                        "highest": "22℃",
                                        "quality": "优",
                                        "sunrise": "06:10",
                                        "weather": "晴转多云",
                                        "humidity": "23",
                                        "moondown": "17:22",
                                        "moonrise": "06:02",
                                        "province": "上海市",
                                        "uv_index": "9",
                                        "alarmlist": [
                                            {
                                                "city": "上海市",
                                                "time": "2020-05-23 20:30:00",
                                                "type": "大雾",
                                                "level": "黄色",
                                                "content": "上海中心气象台2020年05月23日20时30分发布大雾黄色预警信号：预计今天下半夜到明天早晨本市大部郊区将出现能见度小于500米的雾，局部地区小于200米，请注意防范。",
                                                "province": "上海市"
                                            }
                                        ],
                                        "windspeed": "7",
                                        "weatherimg": "duoyun.png",
                                        "weathercode": "qing_duoyun"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/tianqi\/hour": {
            "get": {
                "summary": "24小时天气",
                "tags": [
                    "天气预报"
                ],
                "description": "查询地区未来24小时分段天气预报",
                "parameters": [
                    {
                        "name": "key",
                        "in": "query",
                        "description": "API密钥",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "description": "API密钥"
                        }
                    },
                    {
                        "name": "city",
                        "in": "query",
                        "description": "城市天气ID、行政代码、城市名称、IP地址",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "example": "101020100",
                            "description": "城市天气ID、行政代码、城市名称、IP地址"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "area": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "结果地区（市\/区\/县）"
                                        },
                                        "temp": {
                                            "type": "string",
                                            "example": "34℃",
                                            "description": "气温"
                                        },
                                        "time": {
                                            "type": "string",
                                            "example": "202406121700",
                                            "description": "时间"
                                        },
                                        "wind": {
                                            "type": "string",
                                            "example": "东南风",
                                            "description": "风向（方位）"
                                        },
                                        "areaid": {
                                            "type": "string",
                                            "example": "101020100",
                                            "description": "城市天气ID"
                                        },
                                        "windsc": {
                                            "type": "string",
                                            "example": "1-2级",
                                            "description": "风力"
                                        },
                                        "weather": {
                                            "type": "string",
                                            "example": "多云",
                                            "description": "天气状况"
                                        },
                                        "province": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "所属省份"
                                        },
                                        "weathercode": {
                                            "type": "string",
                                            "example": "duoyun",
                                            "description": "天气图标"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "area": "上海",
                                        "list": [
                                            {
                                                "temp": "26℃",
                                                "time": "202406121800",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "多云",
                                                "weathercode": "duoyun"
                                            },
                                            {
                                                "temp": "25℃",
                                                "time": "202406121900",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "多云",
                                                "weathercode": "duoyun"
                                            },
                                            {
                                                "temp": "25℃",
                                                "time": "202406122000",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "24℃",
                                                "time": "202406122100",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "24℃",
                                                "time": "202406122200",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406122300",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406130000",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406130100",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406130200",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            }
                                        ],
                                        "areaid": "101020100",
                                        "province": "上海"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "24小时天气",
                "tags": [
                    "天气预报"
                ],
                "description": "查询地区未来24小时分段天气预报",
                "requestBody": {
                    "content": {
                        "application\/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API密钥"
                                    },
                                    "city": {
                                        "type": "string",
                                        "example": "101020100",
                                        "description": "城市天气ID、行政代码、城市名称、IP地址"
                                    }
                                },
                                "required": [
                                    "key",
                                    "city"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "area": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "结果地区（市\/区\/县）"
                                        },
                                        "temp": {
                                            "type": "string",
                                            "example": "34℃",
                                            "description": "气温"
                                        },
                                        "time": {
                                            "type": "string",
                                            "example": "202406121700",
                                            "description": "时间"
                                        },
                                        "wind": {
                                            "type": "string",
                                            "example": "东南风",
                                            "description": "风向（方位）"
                                        },
                                        "areaid": {
                                            "type": "string",
                                            "example": "101020100",
                                            "description": "城市天气ID"
                                        },
                                        "windsc": {
                                            "type": "string",
                                            "example": "1-2级",
                                            "description": "风力"
                                        },
                                        "weather": {
                                            "type": "string",
                                            "example": "多云",
                                            "description": "天气状况"
                                        },
                                        "province": {
                                            "type": "string",
                                            "example": "上海市",
                                            "description": "所属省份"
                                        },
                                        "weathercode": {
                                            "type": "string",
                                            "example": "duoyun",
                                            "description": "天气图标"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "area": "上海",
                                        "list": [
                                            {
                                                "temp": "26℃",
                                                "time": "202406121800",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "多云",
                                                "weathercode": "duoyun"
                                            },
                                            {
                                                "temp": "25℃",
                                                "time": "202406121900",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "多云",
                                                "weathercode": "duoyun"
                                            },
                                            {
                                                "temp": "25℃",
                                                "time": "202406122000",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "24℃",
                                                "time": "202406122100",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "24℃",
                                                "time": "202406122200",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406122300",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406130000",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406130100",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            },
                                            {
                                                "temp": "23℃",
                                                "time": "202406130200",
                                                "wind": "东南风",
                                                "windsc": "<3级",
                                                "weather": "晴",
                                                "weathercode": "qing"
                                            }
                                        ],
                                        "areaid": "101020100",
                                        "province": "上海"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}