# Frequenz Weather API Client
[](https://github.com/frequenz-floss/frequenz-client-weather-python/actions/workflows/ci.yaml)
[](https://pypi.org/project/frequenz-client-weather/)
[](https://frequenz-floss.github.io/frequenz-client-weather-python/)
## Introduction
Weather API Client for Python providing access to historical and live weather forecast data.
## Supported Platforms
The following platforms are officially supported (tested):
- **Python:** 3.11
- **Operating System:** Ubuntu Linux 20.04
- **Architectures:** amd64, arm64
## Contributing
If you want to know how to build this project and contribute to it, please
check out the [Contributing Guide](CONTRIBUTING.md).
## Usage
### Installation
```bash
pip install frequenz-client-weather
```
### Initialize the client
The Client can optionally be initialized with keep alive options.
```python
from frequenz.client.weather import Client
from frequenz.client.base.channel import ChannelOptions, KeepAliveOptions, SslOptions
from datetime import timedelta
client = Client(
service_address,
channel_defaults=ChannelOptions(
ssl=SslOptions(
enabled=False,
),
keep_alive=KeepAliveOptions(
enabled=True,
timeout=timedelta(minutes=5),
interval=timedelta(seconds=20),
),
),
)
```
### Get historical weather forecast
```python
from datetime import datetime
from frequenz.client.weather._types import ForecastFeature, Location
location = [Location(latitude=46.2276, longitude=15.2137, country_code="DE")]
features = [ForecastFeature.TEMPERATURE_2_METRE, ForecastFeature.V_WIND_COMPONENT_10_METRE]
start = datetime(2024, 1, 1)
end = datetime(2024, 1, 31)
location_forecast_iterator = client.hist_forecast_iterator(
features=features, locations=locations, start=start, end=end
)
async for forecasts in location_forecast_iterator:
print(forecasts)
```
### Get live weather forecast
```python
from datetime import datetime
from frequenz.client.weather._types import ForecastFeature, Location
location = [Location(latitude=46.2276, longitude=15.2137, country_code="DE")]
features = [ForecastFeature.TEMPERATURE_2_METRE, ForecastFeature.V_WIND_COMPONENT_10_METRE]
rx = await client.stream_live_forecast(
locations=[location],
features=feature_names,
)
while True:
forecast = await rx.__anext__()
print(forecasts)
```
## Command Line Interface
The package also provides a command line interface to get weather forecast data.
Use `-h` to see the available options.
### Get historical weather forecast
```bash
weather-cli \
--url <service-address> \
--location <latitude,longitude> \ # e.g. "40, 15"
--feature <feature-name> \ # e.g. TEMPERATURE_2_METRE
--start <start-datetime> \ # e.g. 2024-03-14
--end <end-datetime> # e.g. 2024-03-15
```
### Get live weather forecast
```bash
weather-cli \
--url <service-address> \
--location <latitude,longitude> \ # e.g. "40, 15"
--feature <feature-name> \ # e.g. TEMPERATURE_2_METRE
```
Raw data
{
"_id": null,
"home_page": null,
"name": "frequenz-client-weather",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.11",
"maintainer_email": null,
"keywords": "frequenz, python, lib, library, client-weather",
"author": null,
"author_email": "Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>",
"download_url": "https://files.pythonhosted.org/packages/76/c6/2ca06e7abed06817486598f8d1b98e08222755186411a6d3c22a788d200c/frequenz_client_weather-0.1.0.tar.gz",
"platform": null,
"description": "# Frequenz Weather API Client\n\n[](https://github.com/frequenz-floss/frequenz-client-weather-python/actions/workflows/ci.yaml)\n[](https://pypi.org/project/frequenz-client-weather/)\n[](https://frequenz-floss.github.io/frequenz-client-weather-python/)\n\n## Introduction\n\nWeather API Client for Python providing access to historical and live weather forecast data.\n\n## Supported Platforms\n\nThe following platforms are officially supported (tested):\n\n- **Python:** 3.11\n- **Operating System:** Ubuntu Linux 20.04\n- **Architectures:** amd64, arm64\n\n## Contributing\n\nIf you want to know how to build this project and contribute to it, please\ncheck out the [Contributing Guide](CONTRIBUTING.md).\n\n## Usage\n\n### Installation\n\n```bash\npip install frequenz-client-weather\n```\n\n### Initialize the client\n\nThe Client can optionally be initialized with keep alive options.\n\n```python\nfrom frequenz.client.weather import Client\nfrom frequenz.client.base.channel import ChannelOptions, KeepAliveOptions, SslOptions\nfrom datetime import timedelta\n\nclient = Client(\n service_address,\n channel_defaults=ChannelOptions(\n ssl=SslOptions(\n enabled=False,\n ),\n keep_alive=KeepAliveOptions(\n enabled=True,\n timeout=timedelta(minutes=5),\n interval=timedelta(seconds=20),\n ),\n ),\n)\n```\n\n### Get historical weather forecast\n\n```python\nfrom datetime import datetime\nfrom frequenz.client.weather._types import ForecastFeature, Location\n\nlocation = [Location(latitude=46.2276, longitude=15.2137, country_code=\"DE\")]\nfeatures = [ForecastFeature.TEMPERATURE_2_METRE, ForecastFeature.V_WIND_COMPONENT_10_METRE]\nstart = datetime(2024, 1, 1)\nend = datetime(2024, 1, 31)\n\nlocation_forecast_iterator = client.hist_forecast_iterator(\n features=features, locations=locations, start=start, end=end\n)\n\nasync for forecasts in location_forecast_iterator:\n print(forecasts)\n```\n\n### Get live weather forecast\n\n```python\nfrom datetime import datetime\nfrom frequenz.client.weather._types import ForecastFeature, Location\n\nlocation = [Location(latitude=46.2276, longitude=15.2137, country_code=\"DE\")]\nfeatures = [ForecastFeature.TEMPERATURE_2_METRE, ForecastFeature.V_WIND_COMPONENT_10_METRE]\n\nrx = await client.stream_live_forecast(\n locations=[location],\n features=feature_names,\n)\n\nwhile True:\n forecast = await rx.__anext__()\n print(forecasts)\n```\n\n## Command Line Interface\n\nThe package also provides a command line interface to get weather forecast data.\nUse `-h` to see the available options.\n\n### Get historical weather forecast\n\n```bash\nweather-cli \\\n --url <service-address> \\\n --location <latitude,longitude> \\ # e.g. \"40, 15\"\n --feature <feature-name> \\ # e.g. TEMPERATURE_2_METRE\n --start <start-datetime> \\ # e.g. 2024-03-14\n --end <end-datetime> # e.g. 2024-03-15\n```\n\n### Get live weather forecast\n\n```bash\nweather-cli \\\n --url <service-address> \\\n --location <latitude,longitude> \\ # e.g. \"40, 15\"\n --feature <feature-name> \\ # e.g. TEMPERATURE_2_METRE\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Weather API Client for Python",
"version": "0.1.0",
"project_urls": {
"Changelog": "https://github.com/frequenz-floss/frequenz-client-weather-python/releases",
"Documentation": "https://frequenz-floss.github.io/frequenz-client-weather-python/",
"Issues": "https://github.com/frequenz-floss/frequenz-client-weather-python/issues",
"Repository": "https://github.com/frequenz-floss/frequenz-client-weather-python",
"Support": "https://github.com/frequenz-floss/frequenz-client-weather-python/discussions/categories/support"
},
"split_keywords": [
"frequenz",
" python",
" lib",
" library",
" client-weather"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5d15c005f3b250d7f46ef1065b2818407094a983928bc80abaf52c7e981a46f4",
"md5": "4fe1e08b07115936895dd09141c895fc",
"sha256": "1733c419f6fe592f5aa0303ecff8423420f93934ffa31ba46a4635fec5423ecf"
},
"downloads": -1,
"filename": "frequenz_client_weather-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4fe1e08b07115936895dd09141c895fc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.11",
"size": 13851,
"upload_time": "2025-03-20T14:34:47",
"upload_time_iso_8601": "2025-03-20T14:34:47.158057Z",
"url": "https://files.pythonhosted.org/packages/5d/15/c005f3b250d7f46ef1065b2818407094a983928bc80abaf52c7e981a46f4/frequenz_client_weather-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "76c62ca06e7abed06817486598f8d1b98e08222755186411a6d3c22a788d200c",
"md5": "562f20db1552f1d6f261002deae0a88c",
"sha256": "29e3c9c5c8a135130b961d2fdec57ee4c3930d9e04745df3fce06ae21fb65009"
},
"downloads": -1,
"filename": "frequenz_client_weather-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "562f20db1552f1d6f261002deae0a88c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.11",
"size": 15288,
"upload_time": "2025-03-20T14:34:48",
"upload_time_iso_8601": "2025-03-20T14:34:48.794915Z",
"url": "https://files.pythonhosted.org/packages/76/c6/2ca06e7abed06817486598f8d1b98e08222755186411a6d3c22a788d200c/frequenz_client_weather-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-03-20 14:34:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "frequenz-floss",
"github_project": "frequenz-client-weather-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "frequenz-client-weather"
}