实时天气

GET
https://api.xuewutheme.com/api/weather

获取实时天气和未来15天天气状况实时掌握

接口概述

获取实时天气和未来15天天气状况实时掌握

请求参数

参数名 类型 必填 描述
apikey string 整数 string

用户开通的apikey

city string 整数 string

城市

响应参数

成功响应

状态码: 200 OK
格式: json
参数名 类型 描述
code integer integer

返回的状态码

data object object

返回的数据/数据对象

msg string string

返回的消息

time string string

请求时间

data[].alarms array array

警报信息列表

data[].city string string

城市名称

data[].cityid integer integer

城市ID

data[].indexes array array

生活指数列表

data[].indexes[].abbreviation string string

指数缩写

data[].indexes[].alias string string

指数别名

data[].indexes[].content string string

指数内容描述

data[].indexes[].level string string

指数等级

data[].indexes[].name string string

指数名称

data[].pm25 object object

PM2.5信息

data[].pm25.advice string string

建议

data[].pm25.aqi string string

AQI指数

data[].pm25.citycount integer integer

城市数量

data[].pm25.cityrank integer integer

城市排名

data[].pm25.co string string

CO浓度

data[].pm25.color string string

颜色

data[].pm25.level string string

污染等级

data[].pm25.no2 string string

NO2浓度

data[].pm25.o3 string string

O3浓度

data[].pm25.pm10 string string

PM10浓度

data[].pm25.pm25 string string

PM2.5浓度

data[].pm25.quality string string

空气质量

data[].pm25.so2 string string

SO2浓度

data[].pm25.timestamp string string

时间戳

data[].pm25.upDateTime string string

更新时间

data[].provinceName string string

省份名称

data[].realtime object object

实时天气信息

data[].realtime.img string string

天气图标编号

data[].realtime.sD string string

相对湿度

data[].realtime.sendibleTemp string string

体感温度

data[].realtime.temp string string

当前温度

data[].realtime.time string string

数据时间

data[].realtime.wD string string

风向

data[].realtime.wS string string

风力等级

data[].realtime.weather string string

天气状况

data[].realtime.ziwaixian string string

紫外线强度

data[].weatherDetailsInfo object object

天气详情信息

data[].weatherDetailsInfo.publishTime string string

发布的时间

data[].weatherDetailsInfo.weather3HoursDetailsInfos array array

每三小时天气详情列表

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].endTime string string

结束时间

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].highestTemperature string string

最高温度

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].img string string

天气图标编号

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].isRainFall string string

是否降雨

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].lowerestTemperature string string

最低温度

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].precipitation string string

降水量

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].startTime string string

开始时间

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].wd string string

风向

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].weather string string

天气状况

data[].weatherDetailsInfo.weather3HoursDetailsInfos[].ws string string

风力等级

data[].weathers array array

天气预报列表

data[].weathers[].aqi string string

AQI指数

data[].weathers[].date string string

日期

data[].weathers[].img string string

天气图标编号

data[].weathers[].sun_down_time string string

日落时间

data[].weathers[].sun_rise_time string string

日出时间

data[].weathers[].temp_day_c string string

白天最高温度(摄氏度)

data[].weathers[].temp_day_f string string

白天最高温度(华氏度)

data[].weathers[].temp_night_c string string

夜间最低温度(摄氏度)

data[].weathers[].temp_night_f string string

夜间最低温度(华氏度)

data[].weathers[].wd string string

风向

data[].weathers[].weather string string

天气状况

data[].weathers[].week string string

星期几

data[].weathers[].ws string string

风力等级

响应示例

JSON
{
    "code": 200,
    "data": [
        {
            "alarms": [],
            "city": "北京市",
            "cityid": 2,
            "indexes": [
                {
                    "abbreviation": "gm",
                    "alias": "",
                    "content": "感冒较易发生,干净整洁的环境和清新流通的空气都有利于降低感冒的几率,体质较弱的童鞋们要特别加强自我保护。",
                    "level": "较易发",
                    "name": "感冒指数"
                },
                {
                    "abbreviation": "xc",
                    "alias": "",
                    "content": "较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。",
                    "level": "较适宜",
                    "name": "洗车指数"
                },
                {
                    "abbreviation": "ct",
                    "alias": "",
                    "content": "白天温度适中,但早晚凉,易穿脱的便携外套很实用。",
                    "level": "衬衫",
                    "name": "穿衣指数"
                },
                {
                    "abbreviation": "uv",
                    "alias": "",
                    "content": "辐射较弱,请涂擦SPF12-15、PA+护肤品。",
                    "level": "弱",
                    "name": "紫外线强度指数"
                },
                {
                    "abbreviation": "yd",
                    "alias": "",
                    "content": "空气轻度污染,不宜在户外运动。",
                    "level": "不适宜",
                    "name": "运动指数"
                },
                {
                    "abbreviation": "pp",
                    "alias": "",
                    "content": "",
                    "level": "暂无",
                    "name": "化妆指数"
                }
            ],
            "pm25": {
                "advice": "0",
                "aqi": "117",
                "citycount": 773,
                "cityrank": 12,
                "co": "1.1",
                "color": "0",
                "level": "0",
                "no2": "43",
                "o3": "64",
                "pm10": "147",
                "pm25": "88",
                "quality": "轻度",
                "so2": "3",
                "timestamp": "",
                "upDateTime": "2024-10-13 00:02:00"
            },
            "provinceName": "北京市",
            "realtime": {
                "img": "18",
                "sD": "92",
                "sendibleTemp": "18",
                "temp": "17",
                "time": "2024-10-12 23:55:08",
                "wD": "东北风",
                "wS": "2级",
                "weather": "雾",
                "ziwaixian": "N/A"
            },
            "weatherDetailsInfo": {
                "publishTime": "2024-10-13 00:00:00",
                "weather3HoursDetailsInfos": [
                    {
                        "endTime": "2024-10-13 04:00:00",
                        "highestTemperature": "15",
                        "img": "1",
                        "isRainFall": "",
                        "lowerestTemperature": "15",
                        "precipitation": "0",
                        "startTime": "2024-10-13 01:00:00",
                        "wd": "",
                        "weather": "多云",
                        "ws": ""
                    },
                    {
                        "endTime": "2024-10-13 07:00:00",
                        "highestTemperature": "13",
                        "img": "2",
                        "isRainFall": "",
                        "lowerestTemperature": "13",
                        "precipitation": "0",
                        "startTime": "2024-10-13 04:00:00",
                        "wd": "",
                        "weather": "阴",
                        "ws": ""
                    },
                    {
                        "endTime": "2024-10-13 10:00:00",
                        "highestTemperature": "16",
                        "img": "2",
                        "isRainFall": "",
                        "lowerestTemperature": "16",
                        "precipitation": "0",
                        "startTime": "2024-10-13 07:00:00",
                        "wd": "",
                        "weather": "阴",
                        "ws": ""
                    },
                    {
                        "endTime": "2024-10-13 13:00:00",
                        "highestTemperature": "17",
                        "img": "7",
                        "isRainFall": "",
                        "lowerestTemperature": "17",
                        "precipitation": "0",
                        "startTime": "2024-10-13 10:00:00",
                        "wd": "",
                        "weather": "小雨",
                        "ws": ""
                    },
                    {
                        "endTime": "2024-10-13 16:00:00",
                        "highestTemperature": "18",
                        "img": "2",
                        "isRainFall": "",
                        "lowerestTemperature": "18",
                        "precipitation": "0",
                        "startTime": "2024-10-13 13:00:00",
                        "wd": "",
                        "weather": "阴",
                        "ws": ""
                    },
                    {
                        "endTime": "2024-10-13 19:00:00",
                        "highestTemperature": "18",
                        "img": "2",
                        "isRainFall": "",
                        "lowerestTemperature": "18",
                        "precipitation": "0",
                        "startTime": "2024-10-13 16:00:00",
                        "wd": "",
                        "weather": "阴",
                        "ws": ""
                    },
                    {
                        "endTime": "2024-10-13 22:00:00",
                        "highestTemperature": "17",
                        "img": "2",
                        "isRainFall": "",
                        "lowerestTemperature": "17",
                        "precipitation": "0",
                        "startTime": "2024-10-13 19:00:00",
                        "wd": "",
                        "weather": "阴",
                        "ws": ""
                    }
                ]
            },
            "weathers": [
                {
                    "aqi": "120",
                    "date": "2024-10-13",
                    "img": "7",
                    "sun_down_time": "17:40",
                    "sun_rise_time": "06:22",
                    "temp_day_c": "18",
                    "temp_day_f": "64.4",
                    "temp_night_c": "12",
                    "temp_night_f": "53.6",
                    "wd": "",
                    "weather": "小雨",
                    "week": "星期日",
                    "ws": ""
                }
            ]
        }
    ],
    "msg": "请求成功!",
    "time": "2024-10-13 00:03:41"
}

请求示例

cURL

Bash
curl -X GET \
  "https://api.example.com/v1/users/12345" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json"

Python

Python
import requests

url = "https://api.example.com/v1/users/12345"
headers = {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())

JavaScript

JavaScript
const response = await fetch(
  'https://api.example.com/v1/users/12345',
  {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
      'Content-Type': 'application/json'
    }
  }
);

const data = await response.json();
console.log(data);

PHP

PHP
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.example.com/v1/users/12345");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

$headers = array();
$headers[] = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

curl_close($ch);

错误码

状态码 描述
100 您的apikey值为空!
101 您的apikey值不存在!
103 当前接口为实名认证后可用,请您先进行实名!
104 请求频率超限!
105 接口不存在或已下线!
106 您的余额不足,请及时充值!
107 您当前的接口免费使用次数已用完,请明日再来!
109 您的账号已被封禁,不可使用任何接口!

错误响应示例

JSON
{
  "code": 1001,
  "message": "用户不存在",
  "data": null
}