聚合天气API

免费

提供实时天气、24小时预报、15天预报、生活指数等全面的天气信息服务

GET http://apis.juhe.cn/simpleWeather/query

请求参数

在个人中心获取免费API Key

请求示例

GET请求:
http://apis.juhe.cn/simpleWeather/query?key=YOUR_API_KEY&city=北京&format=json

响应结果

200 OK 耗时: 156ms

响应头:

Content-Type: application/json
Content-Length: 528
Server: nginx/1.18.0
Date: Mon, 15 Jan 2024 10:30:00 GMT

响应体:

{
  "error_code": 0,
  "reason": "查询成功",
  "result": {
    "city": "北京",
    "realtime": {
      "temperature": "26",
      "humidity": "65",
      "info": "晴",
      "wid": "00",
      "direct": "西南风",
      "power": "2级",
      "aqi": "35"
    },
    "future": [
      {
        "date": "2024-01-15",
        "temperature": "18/28°C",
        "weather": "晴",
        "wid": {
          "day": "00",
          "night": "00"
        },
        "direct": "西南风"
      },
      {
        "date": "2024-01-16",
        "temperature": "16/26°C",
        "weather": "多云",
        "wid": {
          "day": "01",
          "night": "01"
        },
        "direct": "北风"
      }
    ]
  }
}

代码生成

fetch('http://apis.juhe.cn/simpleWeather/query?key=YOUR_API_KEY&city=北京&format=json')
  .then(response => response.json())
  .then(data => {
    console.log('Success:', data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

测试历史

北京天气查询

2024-01-15 10:30

成功

上海天气查询

2024-01-15 09:45

成功

首页

分类

搜索

收藏

我的