实时天气

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

API 文档

  • 接口地址: https://api.makuo.cc/api/get.info.weather
  • 返回格式: JSON
  • 请求方式: GET
  • 请求示例: https://api.makuo.cc/api/get.info.weather?city=北京

请求参数说明:

名称 必填 类型 说明
token string 登录获取token
city string 城市

返回参数说明:

名称 类型 说明
code integer 返回的状态码
data object 返回的数据/数据对象
msg string 返回的消息
time string 请求时间
data[].alarms array 警报信息列表
data[].city string 城市名称
data[].cityid integer 城市ID
data[].indexes array 生活指数列表
data[].indexes[].abbreviation string 指数缩写
data[].indexes[].alias string 指数别名
data[].indexes[].content string 指数内容描述
data[].indexes[].level string 指数等级
data[].indexes[].name string 指数名称
data[].pm25 object PM2.5信息
data[].pm25.advice string 建议
data[].pm25.aqi string AQI指数
data[].pm25.citycount integer 城市数量
data[].pm25.cityrank integer 城市排名
data[].pm25.co string CO浓度
data[].pm25.color string 颜色
data[].pm25.level string 污染等级
data[].pm25.no2 string NO2浓度
data[].pm25.o3 string O3浓度
data[].pm25.pm10 string PM10浓度
data[].pm25.pm25 string PM2.5浓度
data[].pm25.quality string 空气质量
data[].pm25.so2 string SO2浓度
data[].pm25.timestamp string 时间戳
data[].pm25.upDateTime string 更新时间
data[].provinceName string 省份名称
data[].realtime object 实时天气信息
data[].realtime.img string 天气图标编号
data[].realtime.sD string 相对湿度
data[].realtime.sendibleTemp string 体感温度
data[].realtime.temp string 当前温度
data[].realtime.time string 数据时间
data[].realtime.wD string 风向
data[].realtime.wS string 风力等级
data[].realtime.weather string 天气状况
data[].realtime.ziwaixian string 紫外线强度
data[].weatherDetailsInfo object 天气详情信息
data[].weatherDetailsInfo.publishTime string 发布的时间
data[].weatherDetailsInfo.weather3HoursDetailsInfos array 每三小时天气详情列表
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].endTime string 结束时间
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].highestTemperature string 最高温度
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].img string 天气图标编号
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].isRainFall string 是否降雨
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].lowerestTemperature string 最低温度
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].precipitation string 降水量
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].startTime string 开始时间
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].wd string 风向
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].weather string 天气状况
data[].weatherDetailsInfo.weather3HoursDetailsInfos[].ws string 风力等级
data[].weathers array 天气预报列表
data[].weathers[].aqi string AQI指数
data[].weathers[].date string 日期
data[].weathers[].img string 天气图标编号
data[].weathers[].sun_down_time string 日落时间
data[].weathers[].sun_rise_time string 日出时间
data[].weathers[].temp_day_c string 白天最高温度(摄氏度)
data[].weathers[].temp_day_f string 白天最高温度(华氏度)
data[].weathers[].temp_night_c string 夜间最低温度(摄氏度)
data[].weathers[].temp_night_f string 夜间最低温度(华氏度)
data[].weathers[].wd string 风向
data[].weathers[].weather string 天气状况
data[].weathers[].week string 星期几
data[].weathers[].ws string 风力等级

返回示例:

{
    "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"
}

错误码格式说明:

名称 类型 说明
200 string 返回状态码(成功)
500 string 返回的状态码(失败)

代码示例:


<?php
// 初始化cURL会话
$ch = curl_init();
// 设置请求URL,用户中心获取token,自行替换其他参数
curl_setopt($ch, CURLOPT_URL, "https://api.makuo.cc/api/get.info.weather?city=北京");
// 设置请求头
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: YOUR_TOKEN'
));
// 返回响应而不是直接输出
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 执行请求并获取响应
$response = curl_exec($ch);
// 关闭cURL会话
curl_close($ch);
// 将响应解析为JSON格式
$data = json_decode($response, true);
// 输出JSON数据
print_r($data);
?>
            

import requests

# 设置请求URL和头部,用户中心获取token,自行替换其他参数
url = "https://api.makuo.cc/api/get.info.weather?city=北京"
headers = {
    'Authorization': 'YOUR_TOKEN'
}

# 发送GET请求
response = requests.get(url, headers=headers)
# 将响应解析为JSON格式
data = response.json()
# 输出JSON数据
print(data)
            

// 发送GET请求,用户中心获取token,自行替换其他参数
fetch("https://api.makuo.cc/api/get.info.weather?city=北京", {
    method: "GET",
    headers: {
        "Authorization": "YOUR_TOKEN"
    }
})
.then(response => response.json()) // 将响应解析为JSON格式
.then(data => console.log(data)) // 输出JSON数据
.catch(error => console.error('Error:', error));
            

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) throws Exception {
        // 创建URL对象,用户中心获取token,自行替换其他参数
        URL url = new URL("https://api.makuo.cc/api/get.info.weather?city=北京");
        // 打开连接
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        // 设置请求方法
        conn.setRequestMethod("GET");
        // 设置请求头
        conn.setRequestProperty("Authorization", "YOUR_TOKEN");

        // 读取响应
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String inputLine;
        StringBuffer content = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
            content.append(inputLine);
        }
        in.close();
        // 输出JSON数据
        System.out.println(content.toString());
    }
}
            

using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program {
    static async Task Main() {
        using (HttpClient client = new HttpClient()) {
            // 设置请求头
            client.DefaultRequestHeaders.Add("Authorization", "YOUR_TOKEN");
            // 发送GET请求,用户中心获取token,自行替换其他参数
            HttpResponseMessage response = await client.GetAsync("https://api.makuo.cc/api/get.info.weather?city=北京");
            // 将响应解析为字符串
            string responseBody = await response.Content.ReadAsStringAsync();
            // 输出JSON数据
            Console.WriteLine(responseBody);
        }
    }
}
            

require 'net/http'
require 'uri'

# 创建URI对象,用户中心获取token,自行替换其他参数
uri = URI.parse("https://api.makuo.cc/api/get.info.weather?city=北京")
# 创建GET请求
request = Net::HTTP::Get.new(uri)
# 设置请求头
request["Authorization"] = "YOUR_TOKEN"

# 发送请求并获取响应
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end

# 输出JSON数据
puts response.body
            

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    client := &http.Client{}
    // 创建GET请求,用户中心获取token,自行替换其他参数
    req, err := http.NewRequest("GET", "https://api.makuo.cc/api/get.info.weather?city=北京", nil)
    if err != nil {
        panic(err)
    }
    // 设置请求头
    req.Header.Add("Authorization", "YOUR_TOKEN")

    // 发送请求并获取响应
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    // 读取响应体
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }
    // 输出JSON数据
    fmt.Println(string(body))
}