### Python Quickstart Example Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Fetches and prints bio-weather forecast data for a given location. Ensure the DwdBioWeatherAPI is initialized with a valid identifier. ```python from dwdwfsapi import DwdBioWeatherAPI dwd = DwdBioWeatherAPI(8) if dwd.data_valid: for k, v in dwd.forecast_data.items(): print(f"{k} - {v['name']}") for entry in v["forecast"]: print(f"\t{entry['start_time']} : {entry['color']} - {entry['level']} = {entry['impact']}") ``` -------------------------------- ### Example Weather Warning Data Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md This is an example of a current warning object, showing its structure including start and end times, event type, headline, description, and parameters. ```python { 'start_time': datetime.datetime(2020, 4, 18, 23, 0, tzinfo=datetime.timezone.utc), 'end_time': datetime.datetime(2020, 4, 19, 5, 0, tzinfo=datetime.timezone.utc), 'event': 'FROST', 'event_code': 22, 'headline': 'Amtliche WARNUNG vor FROST', 'description': 'Es tritt leichter Frost um 0 °C auf. In Bodennähe wird leichter Frost bis -4 °C erwartet.', 'instruction': None, 'level': 1, 'parameters': { 'Lufttemperatur': '~0 [°C]', 'Bodentemperatur': '>-4 [°C]' }, 'color': '#ffff00' } ``` -------------------------------- ### Install dwdwfsapi Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Install the dwdwfsapi library using pip. ```bash pip install dwdwfsapi ``` -------------------------------- ### Forecast Dictionary Structure Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Details the structure of each forecast entry within the `forecast` list, including start time, impact level, and color. ```APIDOC ## Forecast dictionary - **`start_time : datetime`** Timestamp when the forecast starts - **`level : int`** Impact level (0 - 6) - **`impact : str`** String representation of the impact level - **`color : str`** Forecast color formatted #rrggbb ``` -------------------------------- ### Initialize and Fetch Weather Warnings Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Initialize the DwdWeatherWarningsAPI with a warncell ID and access current and expected warning data. Ensure the data is valid before processing. ```python from dwdwfsapi import DwdWeatherWarningsAPI dwd = DwdWeatherWarningsAPI('813073088') if dwd.data_valid: print(f"Warncell id: {dwd.warncell_id}") print(f"Warncell name: {dwd.warncell_name}") print(f"Number of current warnings: {len(dwd.current_warnings)}") print(f"Current warning level: {dwd.current_warning_level}") print(f"Number of expected warnings: {len(dwd.expected_warnings)}") print(f"Expected warning level: {dwd.expected_warning_level}") print(f"Last update: {dwd.last_update}") print('-----------') for warning in dwd.current_warnings: print(warning) print('-----------') for warning in dwd.expected_warnings: print(warning) print('-----------') ``` -------------------------------- ### __init__(identifier) Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Initializes a new weather warnings API class instance. The identifier can be a warncell ID (int), warncell name (str), or GPS location (tuple). The `update()` method is automatically called upon successful initialization. ```APIDOC ## __init__(identifier) ### Description Create a new weather warnings API class instance. The `identifier` can either be a so called `warncell id` (int), a `warncell name` (str) or a `gps location` (tuple). ### Parameters #### Path Parameters - **identifier** (int | str | tuple) - Required - The warncell ID, warncell name, or GPS location (latitude, longitude) to initialize the API with. ### Notes - It is heavily advised to use `warncell id` over `warncell name` because the name is not unique in some cases. - The `gps location` consists of the latitude and longitude in this order. Keeping this order for the tuple is important for the query to work correctly. - A list of valid warncell ids and names can be found in [warncells.md](https://github.com/stephan192/dwdwfsapi/blob/master/docs/warncells.md). - Method `update()` is automatically called at the end of a successfull init. ``` -------------------------------- ### DwdBioWeatherAPI Initialization Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Initializes the DwdBioWeatherAPI with a cell identifier (ID or name). The `update()` method is automatically called upon successful initialization. ```APIDOC ## `__init__(identifier)` ### Description Create a new bio weather API class instance. The `identifier` can either be a so called `cell id` (int) or a `cell name` (str). It is heavily advised to use `cell id` over `cell name` because the name is not unique in some cases. A list of valid cell ids and names can be found in [biocells.md](https://github.com/stephan192/dwdwfsapi/blob/master/docs/biocells.md). Method `update()` is automatically called at the end of a successfull init. ``` -------------------------------- ### Fetch and Display Pollen Forecast Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Use this snippet to initialize the DwdPollenFlightAPI with a cell ID and print the pollen forecast data. Ensure the API key is valid and the cell ID exists. The data is automatically updated upon initialization. ```python from dwdwfsapi import DwdPollenFlightAPI dwd = DwdPollenFlightAPI(41) if dwd.data_valid: for k, v in dwd.forecast_data.items(): print(f"{k} - {v['name']}") for entry in v["forecast"]: print(f"\t{entry['start_time']} : {entry['color']} - {entry['level']} = {entry['impact']}") ``` -------------------------------- ### update() Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Updates the weather warning data by querying the DWD server and parsing the results. This function should be called regularly to ensure the data is up-to-date. ```APIDOC ## update() ### Description Update data by querying DWD server and parsing result. ### Notes Function should be called regularly, e.g. every 15minutes, to update the data stored in the class attributes. ``` -------------------------------- ### DwdPollenFlightAPI Initialization Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Initializes a new DwdPollenFlightAPI instance. The identifier can be a cell ID (int) or cell name (str). The `update()` method is called automatically upon successful initialization. ```APIDOC ## `__init__(identifier)` ### Description Create a new pollen flight API class instance. The `identifier` can either be a so called `cell id` (int) or a `cell name` (str). It is heavily advised to use `cell id` over `cell name` because the name is not unique in some cases. A list of valid cell ids and names can be found in [pollencells.md](https://github.com/stephan192/dwdwfsapi/blob/master/docs/pollencells.md). Method `update()` is automatically called at the end of a successfull init. ``` -------------------------------- ### Forecast Dictionary Structure Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Details the structure of each dictionary within the `forecast` list, providing specific forecast information for a given time. ```APIDOC ## Forecast dictionary - **`start_time : datetime`** Timestamp when the forecast starts - **`level : int`** Impact level (0 - 3) - **`impact : str`** String representation of the impact level - **`color : str`** Forecast color formatted #rrggbb ``` -------------------------------- ### Warning Dictionary Structure Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Details the structure of the warning dictionaries, including timestamps, event information, descriptions, urgency, level, parameters, and color. ```APIDOC ## Warning dictionary ### start_time - **Type**: datetime - **Description**: Timestamp when the warning starts. ### end_time - **Type**: datetime - **Description**: Timestamp when the warning ends. ### event - **Type**: str - **Description**: String representation of the warning event. ### event_code - **Type**: int - **Description**: Integer representation of the warning event. ### headline - **Type**: str - **Description**: The official warning headline. ### description - **Type**: str - **Description**: A detailed warning description. ### instruction - **Type**: str - **Description**: Instructions and safety notices. ### urgency - **Type**: str - **Description**: Warning urgency (either "immediate" or "future"). ### level - **Type**: int - **Description**: Warning level. Range: 0 (no warning) to 4 (extreme weather). ### parameters - **Type**: dict - **Description**: Dictionary containing warning specific parameters. ### color - **Type**: str - **Description**: Warning color formatted #rrggbb. ``` -------------------------------- ### Forecast Data Dictionary Structure Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Details the structure of the `forecast_data` dictionary, which holds all biological weather forecast information. ```APIDOC ## Forecast data dictionary - **`key : int`** Data type - **`name : str`** String representation of the data type - **`forecast : list of dicts`** List containing the forecast data See section forecast dictionary for more details ``` -------------------------------- ### DwdBioWeatherAPI Attributes Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Provides read-only access to the status and forecast data of the DwdBioWeatherAPI. ```APIDOC ## Attributes (read only) - **`data_valid : bool`** A flag wether or not the other attributes contain valid values - **`cell_id : int`** The id of the selected cell - **`cell_name : str`** The name of the selected ncell If the name is not unique `" (not unique use ID!)"` will be added to the name - **`last_update : datetime`** Timestamp of the last update - **`forecast_data : dict`** Dictionary containing all forecast data See section forecast data dictionary for more details ``` -------------------------------- ### DwdPollenFlightAPI Attributes Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Provides read-only access to the status and forecast data of the DwdPollenFlightAPI. ```APIDOC ## Attributes (read only) - **`data_valid : bool`** A flag wether or not the other attributes contain valid values - **`cell_id : int`** The id of the selected cell - **`cell_name : str`** The name of the selected ncell If the name is not unique `" (not unique use ID!)"` will be added to the name - **`last_update : datetime`** Timestamp of the last update - **`forecast_data : dict`** Dictionary containing all forecast data See section forecast data dictionary for more details ``` -------------------------------- ### Forecast Data Dictionary Structure Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Details the structure of the `forecast_data` dictionary, which contains pollen flight forecasts organized by data type. ```APIDOC ## Forecast data dictionary - **`key : int`** Data type - **`name : str`** String representation of the data type - **`forecast : list of dicts`** List containing the forecast data See section forecast dictionary for more details ``` -------------------------------- ### Attributes Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Provides read-only access to various weather warning data attributes, including data validity, warncell information, last update timestamp, current and expected warning levels, and detailed warning lists. ```APIDOC ## Attributes (read only) ### data_valid - **Type**: bool - **Description**: A flag indicating whether or not the other attributes contain valid values. ### warncell_id - **Type**: int - **Description**: The ID of the selected warncell. ### warncell_name - **Type**: str - **Description**: The name of the selected warncell. If the name is not unique, `" (not unique use ID!)"` will be appended. ### last_update - **Type**: datetime - **Description**: Timestamp of the last update. ### current_warning_level - **Type**: int - **Description**: Highest currently active warning level. Range: 0 (no warning) to 4 (extreme weather). ### current_warnings - **Type**: list of dicts - **Description**: Dictionary containing all currently active warnings ("Wetterwarnungen", urgency="immediate"). See section warning dictionary for more details. ### expected_warning_level - **Type**: int - **Description**: Highest expected warning level. Range: 0 (no warning) to 4 (extreme weather). ### expected_warnings - **Type**: list of dicts - **Description**: Dictionary containing all expected warnings ("Vorabinformationen", urgency="future"). See section warning dictionary for more details. ``` -------------------------------- ### DwdBioWeatherAPI Update Source: https://github.com/stephan192/dwdwfsapi/blob/master/README.md Updates the forecast data by querying the DWD server and parsing the results. This method should be called periodically to ensure the data is up-to-date. ```APIDOC ## `update()` ### Description Update data by querying DWD server and parsing result. Function should be called regularly, e.g. every 12hours, to update the data stored in the class attributes. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.