open-meteo

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Open Meteo

Open Meteo

When to use

适用场景

  • You need weather forecasts (hourly/daily/current) for coordinates.
  • You need air quality / pollen forecasts (hourly/current) for coordinates.
  • You need to resolve a user-provided place name to coordinates and timezone (geocoding).
  • You need to support multi-location batching (comma-separated lat/lon lists).
  • You need a deterministic checklist for Open-Meteo query parameters, response parsing, and error handling.
  • 当你需要根据坐标获取天气预报(逐小时/逐日/实时)时。
  • 当你需要根据坐标获取空气质量/花粉预报(逐小时/实时)时。
  • 当你需要将用户提供的地点名称解析为坐标及时区(地理编码)时。
  • 当你需要支持多位置批量处理(逗号分隔的纬度/经度列表)时。
  • 当你需要一份关于Open-Meteo查询参数、响应解析和错误处理的确定性检查清单时。

Goal

目标

Provide a reliable, production-friendly way to call Open-Meteo APIs (Forecast, Air Quality, Geocoding), choose variables, control time/units/timezone, and parse responses consistently.
提供一种可靠、适合生产环境的方式来调用Open-Meteo API(预报、空气质量、地理编码),选择变量,控制时间/单位/时区,并一致地解析响应。

Steps

步骤

  1. Pick the correct API and base URL
    • Forecast:
      https://api.open-meteo.com/v1/forecast
    • Air Quality:
      https://air-quality-api.open-meteo.com/v1/air-quality
    • Geocoding:
      https://geocoding-api.open-meteo.com/v1/search
  2. Resolve coordinates (if you only have a name)
    • Call Geocoding with
      name
      and optional
      language
      ,
      countryCode
      ,
      count
      .
    • Use the returned
      latitude
      ,
      longitude
      , and
      timezone
      for subsequent calls.
  3. Design your time axis (timezone, timeformat, and range)
    • Prefer
      timezone=auto
      when results must align to local midnight.
    • If you request
      daily=...
      , set
      timezone
      (docs: daily requires timezone).
    • Choose
      timeformat=iso8601
      for readability, or
      timeformat=unixtime
      for compactness.
      • If using
        unixtime
        , remember timestamps are GMT+0 and you must apply
        utc_offset_seconds
        for correct local dates.
    • Choose range controls:
      • forecast_days
        and optional
        past_days
        , or
      • explicit
        start_date
        /
        end_date
        (YYYY-MM-DD), and for sub-daily
        start_hour
        /
        end_hour
        .
  4. Choose variables minimally (avoid "download everything")
    • Forecast: request only the variables you need via
      hourly=...
      ,
      daily=...
      ,
      current=...
      .
    • Air Quality: request only the variables you need via
      hourly=...
      ,
      current=...
      .
    • Keep variable names exact; typos return a JSON error with
      error: true
      .
  5. Choose units and model selection deliberately
    • Forecast units:
      • temperature_unit
        (
        celsius
        /
        fahrenheit
        )
      • wind_speed_unit
        (
        kmh
        /
        ms
        /
        mph
        /
        kn
        )
      • precipitation_unit
        (
        mm
        /
        inch
        )
    • Forecast model selection:
      • default
        models=auto
        / “Best match” combines the best models.
      • you can explicitly request models via
        models=...
        .
      • provider-specific forecast endpoints also exist (provider implied by path). See
        references/models.md
        (section "Endpoints vs
        models=
        ") for examples and doc links.
      • for provider/model-specific selection tradeoffs, see
        references/models.md
        .
    • Air Quality domain selection:
      • domains=auto
        (default) or
        cams_europe
        /
        cams_global
        .
  6. Implement robust request/response handling
    • Treat HTTP errors and JSON-level errors separately.
    • JSON error format is:
      • {"error": true, "reason": "..."}
    • When requesting multiple locations (comma-separated coordinates), expect the JSON output shape to change to a list of structures.
    • Optionally use
      format=csv
      or
      format=xlsx
      when you need data export.
  7. Validate correctness with a “known city” check
    • Geocode “Berlin” → Forecast
      hourly=temperature_2m
      for 1–2 days → verify timezone and array lengths.
    • Air Quality
      hourly=pm10,pm2_5,european_aqi
      → verify units and presence of
      hourly_units
      .
  1. 选择正确的API和基础URL
    • 预报API:
      https://api.open-meteo.com/v1/forecast
    • 空气质量API:
      https://air-quality-api.open-meteo.com/v1/air-quality
    • 地理编码API:
      https://geocoding-api.open-meteo.com/v1/search
  2. 解析坐标(若仅知晓地点名称)
    • 调用地理编码API时传入
      name
      以及可选的
      language
      countryCode
      count
      参数。
    • 使用返回的
      latitude
      longitude
      timezone
      进行后续调用。
  3. 设计时间轴(时区、时间格式和范围)
    • 当结果需要与当地午夜对齐时,优先使用
      timezone=auto
    • 若请求
      daily=...
      参数,必须设置
      timezone
      (文档说明:逐日数据需要指定时区)。
    • 为了可读性选择
      timeformat=iso8601
      ,或为了紧凑性选择
      timeformat=unixtime
      • 若使用
        unixtime
        ,请记住时间戳为GMT+0时区,需要通过
        utc_offset_seconds
        调整为正确的当地时间。
    • 选择范围控制方式:
      • forecast_days
        和可选的
        past_days
        ,或
      • 显式设置
        start_date
        /
        end_date
        (格式为YYYY-MM-DD),对于亚日级数据可设置
        start_hour
        /
        end_hour
  4. 最小化选择变量(避免“全量下载”)
    • 预报API:仅通过
      hourly=...
      daily=...
      current=...
      请求所需变量。
    • 空气质量API:仅通过
      hourly=...
      current=...
      请求所需变量。
    • 变量名称必须完全匹配;拼写错误会返回包含
      error: true
      的JSON错误信息。
  5. 谨慎选择单位和模型
    • 预报API单位:
      • temperature_unit
        celsius
        /
        fahrenheit
      • wind_speed_unit
        kmh
        /
        ms
        /
        mph
        /
        kn
      • precipitation_unit
        mm
        /
        inch
    • 预报API模型选择:
      • 默认
        models=auto
        / “最佳匹配”会整合最优模型。
      • 可通过
        models=...
        显式指定模型。
      • 也存在特定服务商的预报端点(服务商由路径隐含)。请查看
        references/models.md
        中的“端点与
        models=
        参数”部分获取示例和文档链接。
      • 关于服务商/模型选择的权衡,请查看
        references/models.md
    • 空气质量API领域选择:
      • domains=auto
        (默认)或
        cams_europe
        /
        cams_global
  6. 实现健壮的请求/响应处理
    • 区分HTTP错误和JSON级错误。
    • JSON错误格式为:
      • {"error": true, "reason": "..."}
    • 当请求多个位置(逗号分隔的坐标)时,JSON输出结构会变为结构体列表。
    • 当需要导出数据时,可选择使用
      format=csv
      format=xlsx
  7. 通过“已知城市”检查验证正确性
    • 对“Berlin”进行地理编码 → 调用预报API并设置
      hourly=temperature_2m
      ,获取1-2天的数据 → 验证时区和数组长度。
    • 调用空气质量API并设置
      hourly=pm10,pm2_5,european_aqi
      → 验证单位和
      hourly_units
      是否存在。

Critical prohibitions

重要禁忌

  • Do not include out-of-scope APIs in this skill’s implementation guidance: Historical Weather, Ensemble Models, Seasonal Forecast, Climate Change, Marine, Satellite Radiation, Elevation, Flood.
  • Do not omit
    timezone
    when requesting
    daily
    variables (per docs).
  • Do not assume
    unixtime
    timestamps are local time; they are GMT+0 and require
    utc_offset_seconds
    adjustment.
  • Do not silently ignore
    {"error": true}
    responses; fail fast with the provided
    reason
    .
  • Do not request huge variable sets by default; keep queries minimal to reduce payload and avoid accidental overuse.
  • 请勿将本技能实现指南之外的API纳入范围:历史天气、集合模型、季节预报、气候变化、海洋、卫星辐射、海拔、洪水相关API。
  • 请求
    daily
    变量时请勿省略
    timezone
    参数(符合文档要求)。
  • 请勿假设
    unixtime
    时间戳为当地时间;它们属于GMT+0时区,需要通过
    utc_offset_seconds
    进行调整。
  • 请勿忽略
    {"error": true}
    响应;应根据提供的
    reason
    快速终止流程并抛出错误。
  • 默认情况下请勿请求大量变量集;保持查询最小化以减少负载并避免意外过度使用API。

Definition of done

完成标准

  • You can geocode a place name and obtain coordinates/timezone.
  • You can fetch Forecast data with at least one
    hourly
    , one
    daily
    (with timezone), and one
    current
    variable.
  • You can fetch Air Quality data for at least one pollutant and one AQI metric.
  • Your client code handles both HTTP-level failures and JSON-level
    error: true
    with clear messages.
  • Attribution requirements from the docs are captured for Air Quality (CAMS) and Geocoding (GeoNames).
  • 能够对地点名称进行地理编码并获取坐标/时区。
  • 能够获取至少包含一个
    hourly
    、一个
    daily
    (带时区)和一个
    current
    变量的预报数据。
  • 能够获取至少包含一种污染物和一项AQI指标的空气质量数据。
  • 客户端代码能够处理HTTP级故障和JSON级
    error: true
    错误,并返回清晰的提示信息。
  • 已记录空气质量(CAMS)和地理编码(GeoNames)所需的归属要求。

Links

链接