Integrate Open-Meteo Weather Forecast, Air Quality, and Geocoding APIs: query design, variable selection, timezone/timeformat/units, multi-location batching, and robust error handling...
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.
Pick the correct API and base URL
https://api.open-meteo.com/v1/forecasthttps://air-quality-api.open-meteo.com/v1/air-qualityhttps://geocoding-api.open-meteo.com/v1/searchResolve coordinates (if you only have a name)
name and optional language, countryCode, count.latitude, longitude, and timezone for subsequent calls.Design your time axis (timezone, timeformat, and range)
timezone=auto when results must align to local midnight.daily=..., set timezone (docs: daily requires timezone).timeformat=iso8601 for readability, or timeformat=unixtime for compactness.unixtime, remember timestamps are GMT+0 and you must apply utc_offset_seconds for correct local dates.forecast_days and optional past_days, orstart_date/end_date (YYYY-MM-DD), and for sub-daily start_hour/end_hour.Choose variables minimally (avoid "download everything")
hourly=..., daily=..., current=....hourly=..., current=....error: true.Choose units and model selection deliberately
temperature_unit (celsius / fahrenheit)wind_speed_unit (kmh / ms / mph / kn)precipitation_unit (mm / inch)models=auto / “Best match” combines the best models.models=....references/models.md (section "Endpoints vs models=") for examples and doc links.references/models.md.domains=auto (default) or cams_europe / cams_global.Implement robust request/response handling
{"error": true, "reason": "..."}format=csv or format=xlsx when you need data export.Validate correctness with a “known city” check
hourly=temperature_2m for 1–2 days → verify timezone and array lengths.hourly=pm10,pm2_5,european_aqi → verify units and presence of hourly_units.timezone when requesting daily variables (per docs).unixtime timestamps are local time; they are GMT+0 and require utc_offset_seconds adjustment.{"error": true} responses; fail fast with the provided reason.hourly, one daily (with timezone), and one current variable.error: true with clear messages.references/forecast-api.mdreferences/models.mdreferences/weather-codes.mdreferences/air-quality-api.mdreferences/geocoding-api.mdreferences/examples.md