加载中...

基础信息

查看接口基本信息和返回格式

免责声明

本平台提供的API服务均来自互联网,可能包含生成式AI内容。所有返回内容仅供参考,平台不对内容的准确性、完整性、时效性或适用性做任何保证。使用者应自行判断并承担使用风险。

接口描述

查询指定城市实时天气预报

七日请求统计
本周总请求: - 日均: -
请求方式
GET POST 推荐
请求地址
https://dome.api.yunmge.com/api/weather
返回方式
JSON 默认返回格式,包含完整数据结构
TEXT 纯文本格式,适合简单数据返回
返回预览
JSON
TEXT
JSON
{
  "code": 200,
  "data": {
    "province": "北京市",
    "city": "北京市",
    "weather": "阴",
    "temperature": "25°C",
    "minTemp": "24°C",
    "maxTemp": "31°C",
    "winddirection": "东北风",
    "windscale": "2级",
    "humidity": "94%",
    "airqualitynum": "20",
    "airqualitytext": "优",
    "todayComment": "今天有雨,冷热适宜,感觉很舒适。",
    "suggestion": [
      "约会 较不适宜",
      "美发 一般",
      "舒适度 较不舒适",
      "路况 干燥",
      "运动 不适宜",
      "逛街 较适宜",
      "钓鱼 不适宜",
      "防晒 中等",
      "雨伞 不带伞",
      "风寒 无需防护",
      "猫咪 不太适宜",
      "心情 较差",
      "感冒 易发",
      "狗狗 较适宜",
      "广场舞 较适宜",
      "放风筝 不宜",
      "旅游 较适宜",
      "晨练 较适宜",
      "晾晒 适宜",
      "洗车 较适宜",
      "空气污染扩散 较差",
      "空调开启 部分时间开启",
      "息斯敏过敏 不易发",
      "中暑 易中暑",
      "交通 良好",
      "划船 适宜",
      "化妆 控油",
      "啤酒 适宜",
      "夜生活 较适宜",
      "穿衣 闷热",
      "紫外线 弱"
    ],
    "hour24": [
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 8,
        "Fcondition_id": 67,
        "Ftemp": 25,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 27,
        "Fpredict_hour": 3,
        "Fhumidity": 85,
        "wind_degrees": "90",
        "Fcondition": "中雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 8,
        "Fcondition_id": 67,
        "Ftemp": 25,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 26,
        "Fpredict_hour": 4,
        "Fhumidity": 86,
        "wind_degrees": "90",
        "Fcondition": "中雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 8,
        "Fcondition_id": 67,
        "Ftemp": 25,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 27,
        "Fpredict_hour": 5,
        "Fhumidity": 88,
        "wind_degrees": "90",
        "Fcondition": "中雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 7,
        "Fcondition_id": 66,
        "Ftemp": 25,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 27,
        "Fpredict_hour": 6,
        "Fhumidity": 86,
        "wind_degrees": "90",
        "Fcondition": "小雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 7,
        "Fcondition_id": 66,
        "Ftemp": 24,
        "Fwspd": 2.06,
        "Fwind_dir_id": "6",
        "Ffeelslike": 28,
        "Fpredict_hour": 7,
        "Fhumidity": 84,
        "wind_degrees": "135",
        "Fcondition": "小雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 7,
        "Fcondition_id": 66,
        "Ftemp": 24,
        "Fwspd": 2.06,
        "Fwind_dir_id": "6",
        "Ffeelslike": 29,
        "Fpredict_hour": 8,
        "Fhumidity": 83,
        "wind_degrees": "135",
        "Fcondition": "小雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 26,
        "Fwspd": 2.06,
        "Fwind_dir_id": "6",
        "Ffeelslike": 30,
        "Fpredict_hour": 9,
        "Fhumidity": 81,
        "wind_degrees": "135",
        "Fcondition": "雷阵雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 28,
        "Fwspd": 2.06,
        "Fwind_dir_id": "6",
        "Ffeelslike": 29,
        "Fpredict_hour": 10,
        "Fhumidity": 80,
        "wind_degrees": "135",
        "Fcondition": "雷阵雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 30,
        "Fwspd": 2.06,
        "Fwind_dir_id": "6",
        "Ffeelslike": 29,
        "Fpredict_hour": 11,
        "Fhumidity": 78,
        "wind_degrees": "135",
        "Fcondition": "雷阵雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 30,
        "Fwspd": 2.58,
        "Fwind_dir_id": "6",
        "Ffeelslike": 30,
        "Fpredict_hour": 12,
        "Fhumidity": 78,
        "wind_degrees": "135",
        "Fcondition": "雷阵雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 31,
        "Fwspd": 3.08,
        "Fwind_dir_id": "6",
        "Ffeelslike": 31,
        "Fpredict_hour": 13,
        "Fhumidity": 81,
        "wind_degrees": "135",
        "Fcondition": "雷阵雨",
        "Fwdir": "ESE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 31,
        "Fwspd": 3.08,
        "Fwind_dir_id": "5",
        "Ffeelslike": 31,
        "Fpredict_hour": 14,
        "Fhumidity": 81,
        "wind_degrees": "90",
        "Fcondition": "雷阵雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 31,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 32,
        "Fpredict_hour": 15,
        "Fhumidity": 79,
        "wind_degrees": "90",
        "Fcondition": "雷阵雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 30,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 33,
        "Fpredict_hour": 16,
        "Fhumidity": 77,
        "wind_degrees": "90",
        "Fcondition": "雷阵雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 30,
        "Fwspd": 2.58,
        "Fwind_dir_id": "5",
        "Ffeelslike": 32,
        "Fpredict_hour": 17,
        "Fhumidity": 74,
        "wind_degrees": "90",
        "Fcondition": "雷阵雨",
        "Fwdir": "E",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 30,
        "Fwspd": 2.58,
        "Fwind_dir_id": "2",
        "Ffeelslike": 32,
        "Fpredict_hour": 18,
        "Fhumidity": 79,
        "wind_degrees": "45",
        "Fcondition": "雷阵雨",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 30,
        "Fwspd": 2.58,
        "Fwind_dir_id": "2",
        "Ffeelslike": 31,
        "Fpredict_hour": 19,
        "Fhumidity": 81,
        "wind_degrees": "45",
        "Fcondition": "雷阵雨",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 4,
        "Fcondition_id": 90,
        "Ftemp": 29,
        "Fwspd": 2.06,
        "Fwind_dir_id": "2",
        "Ffeelslike": 30,
        "Fpredict_hour": 20,
        "Fhumidity": 83,
        "wind_degrees": "45",
        "Fcondition": "雷阵雨",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 31,
        "Fcondition_id": 82,
        "Ftemp": 27,
        "Fwspd": 2.06,
        "Fwind_dir_id": "2",
        "Ffeelslike": 29,
        "Fpredict_hour": 21,
        "Fhumidity": 84,
        "wind_degrees": "45",
        "Fcondition": "多云",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 31,
        "Fcondition_id": 82,
        "Ftemp": 27,
        "Fwspd": 2.06,
        "Fwind_dir_id": "2",
        "Ffeelslike": 29,
        "Fpredict_hour": 22,
        "Fhumidity": 85,
        "wind_degrees": "45",
        "Fcondition": "多云",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-03",
        "Ficon_id": 31,
        "Fcondition_id": 82,
        "Ftemp": 25,
        "Fwspd": 2.06,
        "Fwind_dir_id": "2",
        "Ffeelslike": 29,
        "Fpredict_hour": 23,
        "Fhumidity": 86,
        "wind_degrees": "45",
        "Fcondition": "多云",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-04",
        "Ficon_id": 31,
        "Fcondition_id": 82,
        "Ftemp": 25,
        "Fwspd": 2.58,
        "Fwind_dir_id": "2",
        "Ffeelslike": 28,
        "Fpredict_hour": 0,
        "Fhumidity": 86,
        "wind_degrees": "45",
        "Fcondition": "多云",
        "Fwdir": "NNE",
        "wind_level": 2
      },
      {
        "Fpredict_date": "2025-07-04",
        "Ficon_id": 31,
        "Fcondition_id": 82,
        "Ftemp": 25,
        "Fwspd": 0.89,
        "Fwind_dir_id": "9",
        "Ffeelslike": 30,
        "Fpredict_hour": 1,
        "Fhumidity": 38,
        "wind_degrees": "180",
        "Fcondition": "多云",
        "Fwdir": "S",
        "wind_level": 1
      }
    ]
  },
  "msg": "请求成功",
  "time": "2025-07-03 02:07:10",
  "ip": "127.0.0.1"
}

计费标准

了解接口的计费方式和价格
付费接口定价
付费
每日免费 666
超出后计费
普通用户
额度消耗 1额度/次
余额扣费 0.01元/次
会员用户
调用费用 免费
QPS限制
普通用户
999999
次/分钟
会员用户
999999
次/分钟
每日请求次数
普通用户
999999
次/天
会员用户
999999
次/天

安全认证

了解接口的认证方式和访问凭证管理
Token 认证

登录后可查看您的Token

立即登录
实名认证
无需实名认证
本接口对所有用户开放,无需实名认证即可访问
认证方式
推荐 Header 认证

通过 HTTP Header 传递认证信息

Authorization
Bearer {access_token}

或通过curl请求参数传递:

curl
curl "https://dome.api.yunmge.com/api/weather?token=YOUR_TOKEN"

参数文档

查看接口请求参数和返回字段说明
请求参数
参数名 类型 必填 默认值 可选值 说明
token string 必填 登录后显示你的请求token 接口请求唯一认证标识!
mode string 可选 json json、text 返回类型
city string 可选 根据访问者ip自动获取 城市名称<br/>支持城市名称和ip
citynum string 可选 具体看返回城市列表id 城市ID(为空时查询城市id)
hour24 string 可选 false false(获取)、true(不获取) 查询24小时天气
返回参数
字段名 类型 说明
code
int 返回状态码
province
string 城市省份
city
string 城市名称
weather
string 天气
temperature
string 当前温度
minTemp
string 最低温度
maxTemp
string 最高温度
winddirection
string 风向
windscale
string 风级
humidity
string 湿度
airqualitynum
string 空气质量指数
airqualitytext
string 空气质量等级
todayComment
string 今日评语
suggestion
array 生活指数
hour24
array 24小时天气(多参数请自行查看)

状态码

了解接口返回的状态码含义及处理方式
接口状态码
状态码 说明
200 请求成功
351 请输入查询城市名称
352 请选择查询具体城市
服务器状态码

在线测试

在线调试接口,实时查看响应结果
发起请求
GET/POST

示例代码

多种语言的接口调用示例
PHP
JavaScript
NodeJs
Python
Go
Java
C#
C
C++
易语言
PHP
<?php
$API_TOKEN = 'YOUR_TOKEN';
$API_URL = 'https://dome.api.yunmge.com/api/weather';

$params = array(
    'token' => 'YOUR_TOKEN',
    'mode' => 'json',
    'city' => '根据访问者ip自动获取',
    'citynum' => '无',
    'hour24' => 'false',
);

$res = api::send($API_URL, $params, 'GET/POST');
print($res);

class api {
    public static function send($url, $data, $type) {
        $data = http_build_query($data);
        $ch = curl_init();
        if ($type == 'POST') {
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        } else {
            curl_setopt($ch, CURLOPT_URL, $url . '?' . $data);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $res = curl_exec($ch);
        curl_close($ch);
        return $res;
    }
}
JavaScript
$.ajax({
    url: 'https://dome.api.yunmge.com/api/weather',
    data: {
        token: 'YOUR_TOKEN',
        mode: 'json',
        city: '根据访问者ip自动获取',
        citynum: '无',
        hour24: 'false',
    },
    type: 'GET/POST',
    dataType: 'json',
    success: function(data) {
        console.log(data);
    },
    error: function(err) {
        console.log('请求失败', err);
    }
});
Python
import requests

url = "https://dome.api.yunmge.com/api/weather"
data = {
    "token": "YOUR_TOKEN",
    "mode": "json",
    "city": "根据访问者ip自动获取",
    "citynum": "无",
    "hour24": "false",
}

response = requests.post(url, data=data)
print(response.json())
Java
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.*;

public class ApiRequest {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://dome.api.yunmge.com/api/weather");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET/POST");
        conn.setConnectTimeout(10000);

        BufferedReader reader = new BufferedReader(
            new InputStreamReader(conn.getInputStream()));
        String line;
        StringBuilder result = new StringBuilder();
        while ((line = reader.readLine()) != null) {
            result.append(line);
        }
        reader.close();
        System.out.println(result.toString());
    }
}
Go
package main

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

func main() {
    data := "token=YOUR_TOKEN&mode=json&city=%E6%A0%B9%E6%8D%AE%E8%AE%BF%E9%97%AE%E8%80%85ip%E8%87%AA%E5%8A%A8%E8%8E%B7%E5%8F%96&citynum=%E6%97%A0&hour24=false"
    resp, _ := http.Post("https://dome.api.yunmge.com/api/weather",
        "application/x-www-form-urlencoded", strings.NewReader(data))
    defer resp.Body.Close()
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program {
    static async Task Main() {
        using var client = new HttpClient();
        var data = new FormUrlEncodedContent(new Dictionary<string, string> {
            {"token", "YOUR_TOKEN"},
            {"mode", "json"},
            {"city", "根据访问者ip自动获取"},
            {"citynum", "无"},
            {"hour24", "false"},
        });
        var response = await client.PostAsync("https://dome.api.yunmge.com/api/weather", data);
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(response);
    }
}
NodeJs
const https = require('https');
const querystring = require('querystring');

const postData = querystring.stringify({
    'token': 'YOUR_TOKEN',
    'mode': 'json',
    'city': '根据访问者ip自动获取',
    'citynum': '无',
    'hour24': 'false',
});
const options = {
    hostname: 'dome.api.yunmge.com',
    path: '/api/weather',
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
};
const req = https.request(options, res => {
    let data = '';
    res.on('data', d => data += d);
    res.on('end', () => console.log(data));
});
req.write(postData);
req.end();
C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>

static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
    ((char*)userp)[0] = '\0';
    strcat(userp, contents);
    return size * nmemb;
}

int main() {
    CURL *curl;
    CURLcode res;
    char response[4096] = {0};

    curl_global_init(CURL_GLOBAL_DEFAULT);
    curl = curl_easy_init();

    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://dome.api.yunmge.com/api/weather");
        curl_easy_setopt(curl, CURLOPT_POST, 1L);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "token=YOUR_TOKEN&mode=json&city=%E6%A0%B9%E6%8D%AE%E8%AE%BF%E9%97%AE%E8%80%85ip%E8%87%AA%E5%8A%A8%E8%8E%B7%E5%8F%96&citynum=%E6%97%A0&hour24=false");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, response);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);

        res = curl_easy_perform(curl);
        if(res == CURLE_OK) printf("%s\n", response);
        curl_easy_cleanup(curl);
    }
    curl_global_cleanup();
    return 0;
}
C++
#include <iostream>
#include <string>
#include <curl/curl.h>

size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* userp) {
    userp->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    std::string response;

    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://dome.api.yunmge.com/api/weather");
        curl_easy_setopt(curl, CURLOPT_POST, 1L);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "token=YOUR_TOKEN&mode=json&city=%E6%A0%B9%E6%8D%AE%E8%AE%BF%E9%97%AE%E8%80%85ip%E8%87%AA%E5%8A%A8%E8%8E%B7%E5%8F%96&citynum=%E6%97%A0&hour24=false");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK) std::cout << response << std::endl;
        curl_easy_cleanup(curl);
    }
    curl_global_cleanup();
    return 0;
}
易语言
.版本 2
.支持库 spec

.局部变量 url, 文本型
.局部变量 params, 文本型
.局部变量 result, 文本型

url = "https://dome.api.yunmge.com/api/weather"
params = "token=YOUR_TOKEN&mode=json&city=%E6%A0%B9%E6%8D%AE%E8%AE%BF%E9%97%AE%E8%80%85ip%E8%87%AA%E5%8A%A8%E8%8E%B7%E5%8F%96&citynum=%E6%97%A0&hour24=false"

result = 编码_URL解码 (网页_访问 (url, , params))
调试输出 (result)

AI开发文档

导出接口文档供AI助手快速理解接口结构
复制下方内容粘贴给AI助手,即可快速生成对接代码。
JSON 格式 0 KB