### Import UkraineAlarm after Setuptools install Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Import the UkraineAlarm package into your Python script after installing it via Setuptools. ```python import UkraineAlarm ``` -------------------------------- ### Install UkraineAlarm using Setuptools Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Install the package locally using Setuptools. This can be done for the current user or system-wide. ```sh python setup.py install --user ``` ```sh sudo python setup.py install ``` -------------------------------- ### Install UkraineAlarm from GitHub Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Install the Python package directly from a GitHub repository using pip. You might need root permissions. ```sh pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git ``` ```sh sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git ``` -------------------------------- ### Import UkraineAlarm after pip install Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Import the UkraineAlarm package into your Python script after installing it via pip. ```python import UkraineAlarm ``` -------------------------------- ### Get all active alerts Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Retrieve a list of all active alerts for regions, areas, and communities. Requires API key configuration. ```python from __future__ import print_function import time import UkraineAlarm from UkraineAlarm.rest import ApiException from pprint import pprint # Configure API key authorization: Token configuration = UkraineAlarm.Configuration() configuration.api_key['Authorization'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Authorization'] = 'Bearer' # create an instance of the API class api_instance = UkraineAlarm.AlertsApi(UkraineAlarm.ApiClient(configuration)) try: # Області, регіони та громади з тривогами api_response = api_instance.api_v3_alerts_get() pprint(api_response) except ApiException as e: print("Exception when calling AlertsApi->api_v3_alerts_get: %s\n" % e) ``` -------------------------------- ### Get All Regions Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/docs/RegionsApi.md Retrieves a list of all regions, areas, and cities. Configure your API key before making the call. Handles potential API exceptions. ```python from __future__ import print_function import time import UkraineAlarm from UkraineAlarm.rest import ApiException from pprint import pprint # Configure API key authorization: Token configuration = UkraineAlarm.Configuration() configuration.api_key['Authorization'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Authorization'] = 'Bearer' # create an instance of the API class api_instance = UkraineAlarm.RegionsApi(UkraineAlarm.ApiClient(configuration)) try: # Повертає список усіх областей, регіонів та міст api_response = api_instance.api_v3_regions_get() pprint(api_response) except ApiException as e: print("Exception when calling RegionsApi->api_v3_regions_get: %s\n" % e) ``` -------------------------------- ### Get last 25 alerts for a specific region Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Retrieve the last 25 alerts for a given region. Ensure your API key is configured. ```python # Configure API key authorization: Token configuration = UkraineAlarm.Configuration() configuration.api_key['Authorization'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Authorization'] = 'Bearer' # create an instance of the API class api_instance = UkraineAlarm.AlertsApi(UkraineAlarm.ApiClient(configuration)) region_id = 'region_id_example' # str | (optional) try: # Отримати останніх 25 тривог регіону api_response = api_instance.api_v3_alerts_region_history_get(region_id=region_id) pprint(api_response) except ApiException as e: print("Exception when calling AlertsApi->api_v3_alerts_region_history_get: %s\n" % e) ``` -------------------------------- ### Get status of a specific region Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Check the current status of a specific region, area, or community. Requires a valid region ID and API key. ```python # Configure API key authorization: Token configuration = UkraineAlarm.Configuration() configuration.api_key['Authorization'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Authorization'] = 'Bearer' # create an instance of the API class api_instance = UkraineAlarm.AlertsApi(UkraineAlarm.ApiClient(configuration)) region_id = 'region_id_example' # str | ID області/регіону/громади try: # Статус області/регіону/громади api_response = api_instance.api_v3_alerts_region_id_get(region_id) pprint(api_response) except ApiException as e: print("Exception when calling AlertsApi->api_v3_alerts_region_id_get: %s\n" % e) ``` -------------------------------- ### Create WebHook Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/docs/WebHookApi.md This endpoint allows for the creation of a new webhook. It accepts a WebHookModel in the request body and returns an AlertRegionModel upon successful creation. Authorization is required using a token. ```APIDOC ## POST /webhook ### Description Creates a new webhook. ### Method POST ### Endpoint /webhook ### Parameters #### Request Body - **body** (WebHookModel) - Optional - The webhook model containing details for the new webhook. ### Authorization [Token](../README.md#Token) ### HTTP request headers - **Content-Type**: application/json, text/json, application/*+json - **Accept**: text/plain, application/json, text/json ### Response #### Success Response (200) - Returns an AlertRegionModel upon successful creation. ### Response Example (Response example not provided in source) ``` -------------------------------- ### api_v3_regions_get Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/docs/RegionsApi.md Retrieves a list of all oblasts, regions, and cities. ```APIDOC ## GET /api/v3/regions ### Description Retrieves a list of all oblasts, regions, and cities. ### Method GET ### Endpoint /api/v3/regions ### Parameters This endpoint does not require any parameters. ### Response #### Success Response (200) Returns a list of regions, provinces, and cities. ### Response Example ```json { "example": "response body" } ``` ### Authorization Token ``` -------------------------------- ### Check for the latest action status Source: https://github.com/ukrainealarm/ukrainealarm-python/blob/master/README.md Verify the number of the latest action to determine if data needs to be updated. Requires API key configuration. ```python # Configure API key authorization: Token configuration = UkraineAlarm.Configuration() configuration.api_key['Authorization'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Authorization'] = 'Bearer' # create an instance of the API class api_instance = UkraineAlarm.AlertsApi(UkraineAlarm.ApiClient(configuration)) try: # Перевірка номеру останньої дії. Використовувати для перевірки необхідності оновлювати дані api_response = api_instance.api_v3_alerts_status_get() pprint(api_response) except ApiException as e: print("Exception when calling AlertsApi->api_v3_alerts_status_get: %s\n" % e) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.