🌤️

实时天气预报

已测试可用GET
天气与环境提供商: Open-Meteo Weather无需认证

Open-Meteo 提供免费的全球天气预报服务,无需 API Key 即可使用。

🔗 请求地址

GETEndpoint
https://api.open-meteo.com/v1/forecast

功能特性

无需认证
RESTful API
JSON 响应格式

🎯 适用场景

天气预报应用

适合天气与环境相关的天气预报应用项目

出行规划系统

适合天气与环境相关的出行规划系统项目

农业气象监测

适合天气与环境相关的农业气象监测项目

📖 集成指南

1

获取 API 端点

端点地址: https://api.open-meteo.com/v1/forecast

2

直接调用

无需认证,可直接发送请求

3

解析响应数据

响应为 JSON 格式,根据业务需求处理数据

💻 开发文档

在线测试

GEThttps://api.open-meteo.com/v1/forecast
注册并登录后即可在线测试 实时天气预报

请求参数

参数名类型必填描述
latitudenumber纬度坐标,例如 39.9042
longitudenumber经度坐标,例如 116.4074
current_weatherboolean是否包含当前天气数据

代码示例

JavaScript (Fetch)
浏览器 / Node.js
// JavaScript - 使用 fetch 调用 实时天气预报
async function callweatherAPI() {
  try {
    const response = await fetch('https://api.open-meteo.com/v1/forecast');
    const data = await response.json();
    console.log(data);
    return data;
  } catch (error) {
    console.error('API调用失败:', error);
  }
}
🐍Python (Requests)
Python 3.x
# Python - 使用 requests 调用 实时天气预报
import requests

def call_weather_api():
    url = "https://api.open-meteo.com/v1/forecast"
    headers = {"Content-Type": "application/json"
    }
    
    try:
        response = requests.get(url, headers=headers)
        data = response.json()
        print(data)
        return data
    except Exception as e:
        print(f"API调用失败: {e}")
cURL
命令行
# cURL - 命令行调用 实时天气预报
curl -X GET "https://api.open-meteo.com/v1/forecast"

响应示例

JSON 响应格式200 OK
{
  "status": "success",
  "data": {
    // 根据实时天气预报的具体功能返回相应数据
    // 请参考官方文档获取完整的响应字段说明
  },
  "message": "请求成功"
}

常见问题

Q:实时天气预报 如何调用?

调用 实时天气预报 需要向 https://api.open-meteo.com/v1/forecast 发送 GET 请求。该 API 无需认证,可直接调用。

Q:实时天气预报 返回什么数据格式?

实时天气预报 返回 JSON 格式的数据,具体字段请参考官方文档或查看代码示例中的响应结构。

Q:实时天气预报 有调用限制吗?

关于调用限制,请参考 Open-Meteo Weather 的官方文档。建议在代码中实现错误处理和重试机制。