{"id":6752,"library":"openmeteo-requests","title":"Open-Meteo Python Library","description":"The openmeteo-requests library is an API client for the Open-Meteo Weather API, currently at version 1.7.5. It uses FlatBuffers for efficient data transfer, particularly for long time-series data, offering zero-copy data transfer to popular libraries like NumPy, Pandas, or Polars. Designed primarily for data scientists, it facilitates quick processing and analysis of weather data, including historical data from 1940 onwards. The library maintains an active development status with regular updates, often focusing on bug fixes and internal improvements, with new features and breaking changes typically introduced in minor or major version bumps.","status":"active","version":"1.7.5","language":"en","source_language":"en","source_url":"https://github.com/open-meteo/python-requests","tags":["weather","api client","flatbuffers","meteorology","data science","forecast"],"install":[{"cmd":"pip install openmeteo-requests","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"The client is based on this library for HTTP requests.","package":"niquests","optional":false},{"reason":"Required for FlatBuffers data parsing and accessing weather variable definitions (e.g., Variable enum).","package":"openmeteo-sdk","optional":false},{"reason":"Optional dependency for implementing caching for API requests.","package":"requests-cache","optional":true}],"imports":[{"note":"The primary client class is typically accessed via the top-level package import.","wrong":"from openmeteo_requests import Client","symbol":"Client","correct":"import openmeteo_requests\nom = openmeteo_requests.Client()"},{"note":"The Variable enum is part of the `openmeteo-sdk` package, not `openmeteo-requests` directly. It is used for filtering and identifying specific weather variables in the FlatBuffers response.","symbol":"Variable","correct":"from openmeteo_sdk.Variable import Variable"}],"quickstart":{"code":"import openmeteo_requests\nfrom openmeteo_sdk.Variable import Variable\n\n# Initialize the Open-Meteo API client\nom = openmeteo_requests.Client()\n\n# Define parameters for the weather request\nparams = {\n    \"latitude\": 52.52,\n    \"longitude\": 13.41,\n    \"hourly\": [\"temperature_2m\", \"precipitation\", \"wind_speed_10m\"],\n    \"current\": [\"temperature_2m\", \"relative_humidity_2m\"],\n    \"timezone\": \"Europe/Berlin\"\n}\n\n# Make the API call\nurl = \"https://api.open-meteo.com/v1/forecast\"\nresponses = om.weather_api(url, params=params)\n\n# Process the first location's response (assuming single location for brevity)\nresponse = responses[0]\n\nprint(f\"Coordinates: {response.Latitude()}°N {response.Longitude()}°E\")\nprint(f\"Elevation: {response.Elevation()} m asl\")\nprint(f\"Timezone: {response.Timezone()} {response.TimezoneAbbreviation()}\")\nprint(f\"Timezone difference to GMT+0: {response.UtcOffsetSeconds()} s\")\n\n# Access current weather data\ncurrent = response.Current()\ncurrent_variables = list(map(lambda i: current.Variables(i), range(0, current.VariablesLength())))\n\ncurrent_temperature_2m = next(filter(lambda x: x.Variable() == Variable.temperature and x.Altitude() == 2, current_variables))\ncurrent_relative_humidity_2m = next(filter(lambda x: x.Variable() == Variable.relative_humidity and x.Altitude() == 2, current_variables))\n\nprint(f\"Current time: {current.Time()}\")\nprint(f\"Current temperature_2m: {current_temperature_2m.Value()} °C\")\nprint(f\"Current relative_humidity_2m: {current_relative_humidity_2m.Value()} %\")\n","lang":"python","description":"This quickstart initializes the Open-Meteo client, defines weather parameters for a specific location (Berlin), and fetches current and hourly forecast data. It then demonstrates how to access the FlatBuffers-encoded data, specifically extracting current temperature and relative humidity. Note that Open-Meteo's API generally does not require an API key for non-commercial use."},"warnings":[{"fix":"Remove any explicit calls to `.close()` on `openmeteo_requests.Client` instances. The client automatically manages sessions or does not require explicit closing.","message":"The `.close()` method was removed from client objects in `v1.7.0`.","severity":"breaking","affected_versions":">=1.7.0"},{"fix":"Always use parentheses `()` when accessing properties on response objects (e.g., `response.Attribute()`, `hourly_data.Value()`). This is due to the FlatBuffers format and is necessary for dynamic data retrieval without expensive parsing. Consult the examples for correct usage.","message":"Data from the FlatBuffers response objects must be accessed using function calls (e.g., `response.Latitude()`) rather than direct attribute access (e.g., `response.Latitude`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `pip install openmeteo-sdk` is run alongside `pip install openmeteo-requests`. Import `Variable` from `openmeteo_sdk.Variable` as shown in the quickstart.","message":"The `openmeteo-requests` library works with `openmeteo-sdk`. You need to install `openmeteo-sdk` separately to properly work with `Variable` enums and fully process the FlatBuffers responses.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}