{"id":6753,"library":"openmeteo-sdk","title":"Open-Meteo Python SDK","description":"The Open-Meteo Python SDK provides FlatBuffer data models for interacting with the Open-Meteo weather API. It allows developers to construct API requests and parse API responses using highly efficient binary serialization. The library is actively maintained with frequent updates (often monthly or bi-monthly) to support new weather models and variables as the Open-Meteo API evolves.","status":"active","version":"1.26.0","language":"en","source_language":"en","source_url":"https://github.com/open-meteo/sdk","tags":["weather","api client","data models","flatbuffers","open-meteo"],"install":[{"cmd":"pip install openmeteo-sdk","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core library for efficient serialization and deserialization of API requests and responses based on the FlatBuffers schema.","package":"flatbuffers","optional":false},{"reason":"Commonly used for making HTTP calls to the Open-Meteo API, as the SDK only provides data models, not an HTTP client itself.","package":"requests","optional":true}],"imports":[{"symbol":"WeatherApiRequest","correct":"from openmeteo_sdk.WeatherApiRequest import WeatherApiRequest"},{"symbol":"WeatherApiResponse","correct":"from openmeteo_sdk.WeatherApiResponse import WeatherApiResponse"},{"symbol":"Variables","correct":"from openmeteo_sdk.Variables import Variables"},{"note":"Required for building and parsing FlatBuffer objects, even though it's an underlying dependency, it's often imported directly in examples.","symbol":"flatbuffers","correct":"import flatbuffers"}],"quickstart":{"code":"import requests\nimport flatbuffers\nfrom openmeteo_sdk.WeatherApiRequest import WeatherApiRequest\nfrom openmeteo_sdk.WeatherApiResponse import WeatherApiResponse\nfrom openmeteo_sdk.Variables import Variables\n\ndef get_weather_data(latitude: float, longitude: float):\n    builder = flatbuffers.Builder(0)\n    request = WeatherApiRequest.WeatherApiRequest.StartWeatherApiRequest(builder)\n    WeatherApiRequest.WeatherApiRequest.AddLatitude(request, latitude)\n    WeatherApiRequest.WeatherApiRequest.AddLongitude(request, longitude)\n    WeatherApiRequest.WeatherApiRequest.AddHourly(request, Variables.Variables().TEMPERATURE_2M)\n    WeatherApiRequest.WeatherApiRequest.AddDaily(request, Variables.Variables().SUNSHINE_DURATION)\n    WeatherApiRequest.WeatherApiRequest.AddTimezone(request, builder.CreateString(\"Europe/Berlin\"))\n    request_object = WeatherApiRequest.WeatherApiRequest.EndWeatherApiRequest(builder)\n    builder.Finish(request_object)\n\n    # Send request to Open-Meteo API\n    response = requests.post(\n        \"https://api.open-meteo.com/v1/forecast?models=gfs_seamless\",\n        data=builder.Output(),\n        headers={\n            \"Content-Type\": \"application/flatbuffers\",\n            \"Accept\": \"application/flatbuffers\"\n        }\n    )\n    response.raise_for_status()\n\n    # Parse response\n    weather_api_response = WeatherApiResponse.WeatherApiResponse.GetRootAsWeatherApiResponse(response.content)\n\n    # Access hourly data\n    if weather_api_response.Hourly() is not None:\n        hourly_temperatures = []\n        for i in range(weather_api_response.Hourly().VariablesLength()):\n            variable = weather_api_response.Hourly().Variables(i)\n            if variable.Variable() == Variables.Variables().TEMPERATURE_2M:\n                for j in range(variable.ValuesLength()):\n                    hourly_temperatures.append(variable.Values(j))\n        print(f\"Hourly Temperatures (2m): {hourly_temperatures[:5]}...\") # Print first 5 for brevity\n\n    # Access daily data\n    if weather_api_response.Daily() is not None:\n        daily_sunshine = []\n        for i in range(weather_api_response.Daily().VariablesLength()):\n            variable = weather_api_response.Daily().Variables(i)\n            if variable.Variable() == Variables.Variables().SUNSHINE_DURATION:\n                for j in range(variable.ValuesLength()):\n                    daily_sunshine.append(variable.Values(j))\n        print(f\"Daily Sunshine Duration: {daily_sunshine[:5]}...\") # Print first 5 for brevity\n\nif __name__ == '__main__':\n    get_weather_data(latitude=52.52, longitude=13.41)\n","lang":"python","description":"This quickstart demonstrates how to use `openmeteo-sdk` to build a FlatBuffer request for weather data, send it to the Open-Meteo API using the `requests` library, and then parse the binary FlatBuffer response to extract hourly temperatures and daily sunshine duration. It highlights the use of `flatbuffers.Builder` for request creation and direct access to data via the generated `WeatherApiResponse` classes."},"warnings":[{"fix":"Always import and use an HTTP client (e.g., `import requests`) to handle the network communication with the Open-Meteo API.","message":"The `openmeteo-sdk` primarily provides FlatBuffer data models (schemas and generated classes) for constructing API requests and parsing responses. It does NOT include an HTTP client. You must use a separate library like `requests` to send the serialized FlatBuffer request and receive the binary response.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the generated class methods (e.g., `response.Hourly().Variables(0).Values(0)`) as shown in the quickstart or SDK examples to correctly retrieve data fields. Use `Length()` methods for iteration.","message":"Accessing data from the `WeatherApiResponse` and other FlatBuffer objects requires specific methods (e.g., `Hourly()`, `Variables(i)`, `Values(j)`, `Variable()`) rather than direct attribute access. This is due to the FlatBuffers design for efficient memory access.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the Open-Meteo API documentation for available variables, models, and parameters for your specific use case. Validate the contents of `response.Hourly().VariablesLength()` or `response.Daily().VariablesLength()` to ensure data was received as expected.","message":"The Open-Meteo API is highly configurable. Requesting variables or models that are incompatible or unavailable for a given latitude/longitude or time range can result in empty data arrays in the response without an explicit error from the SDK itself. The SDK will simply parse what the API returns.","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":[]}