Skip to main content

Python library for alerts.in.ua API

Project description

Introduction

The Alerts.in.ua API Client is a Python library that simplifies access to the alerts.in.ua API service. It provides real-time information about air raid alerts and other potential threats.

Installation

To install the Alerts.in.ua API Client, run the following command in your terminal:

pip install alerts_in_ua

Usage

⚠️ Before you can use this library, you need to obtain an API token by contacting api@alerts.in.ua.

Here's an basic example of how to use the library to get a list of active alerts:

Async:

import asyncio
from alerts_in_ua import AsyncClient as AsyncAlertsClient

async def main():
    # Initialize the client with your token
    alerts_client = AsyncAlertsClient(token="your_token")
    
    # Get the active alerts
    active_alerts = await alerts_client.get_active_alerts()
    print(active_alerts)


# Run the asynchronous function
asyncio.run(main())

or sync:

from alerts_in_ua import Client as AlertsClient

alerts_client = AlertsClient(token="your_token")

# Get the active alerts
active_alerts = alerts_client.get_active_alerts()
print(active_alerts)

Alerts

Alerts class is a collection of alerts and provides various methods to filter and access these alerts.

When user call client.get_active_alerts() it returns Alerts class.

Methods

filter(*args: str) -> List[Alert]

This method filters the alerts based on the given parameters.

filtered_alerts = active_alerts.filter('location_oblast', 'Донецька область','alert_type','air_raid')

In this example, filtered_alerts will contain all the air raid alerts that have the location oblast as 'Донецька область'.

get_alerts_by_location_title(location_title: str) -> List[Alert]

This method returns all the alerts from specified location.

kyiv_alerts = active_alerts.get_alerts_by_location_title('м. Київ')

get_air_raid_alerts() -> List[Alert]

This method returns all the alerts that are of alert type 'air_raid'.

air_raid_alerts = active_alerts.get_air_raid_alerts()

get_oblast_alerts() -> List[Alert]

This method returns all the alerts that are of location type 'oblast'.

oblast_alerts = active_alerts.get_oblast_alerts()

get_raion_alerts() -> List[Alert]

This method returns all the alerts that are of location type 'raion'.

raion_alerts = active_alerts.get_raion_alerts()

get_hromada_alerts() -> List[Alert]

This method returns all the alerts that are of location type 'hromada'.

hromada_alerts = active_alerts.get_hromada_alerts()

get_city_alerts() -> List[Alert]

This method returns all the alerts that are of location type 'city'.

city_alerts = active_alerts.get_city_alerts()

get_alerts_by_alert_type(alert_type: str) -> List[Alert]

This method returns all the alerts that are of the given alert type.

artillery_shelling_alerts = active_alerts.get_alerts_by_alert_type('artillery_shelling')

get_alerts_by_location_type(location_type: str) -> List[Alert]

This method returns all the alerts that are of the given location type.

urban_location_alerts = active_alerts.get_alerts_by_location_type('raion')

get_alerts_by_oblast(oblast_title: str) -> List[Alert]

This method returns all the alerts that are of the given oblast title.

donetsk_oblast_alerts = active_alerts.get_alerts_by_oblast('Донецька область')

get_alerts_by_location_uid(location_uid: str) -> List[Alert]

This method returns all the alerts that have the given location uid.

location_uid_alerts = active_alerts.get_alerts_by_location_uid('123456')

get_artillery_shelling_alerts() -> List[Alert]

This method returns all the alerts that are of alert type 'artillery_shelling'.

artillery_shelling_alerts = active_alerts.get_artillery_shelling_alerts()

get_urban_fights_alerts() -> List[Alert]

This method returns all the alerts that are of alert type 'urban_fights'.

urban_fights_alerts = active_alerts.get_urban_fights_alerts()

get_nuclear_alerts() -> List[Alert]

This method returns all the alerts that are of alert type 'nuclear'.

nuclear_alerts = active_alerts.get_nuclear_alerts()

get_chemical_alerts() -> List[Alert]

This method returns all the alerts that are of alert type 'chemical'.

chemical_alerts = active_alerts.get_chemical_alerts()

get_all_alerts() -> List[Alert]

This method returns all alerts.

all_alerts = active_alerts.get_all_alerts()

or you can use shortcut:

for alert in active_alerts:
    print(alert)

get_last_updated_at() -> datetime.datetime

This method returns the datetime object representing the time when the alert information was last updated (Kyiv timezone).

last_updated_at = alerts.get_last_updated_at()

get_disclaimer() -> str

This method returns the disclaimer associated with the alert information.

disclaimer = alerts.get_disclaimer()

License

MIT 2023

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

alerts_in_ua-0.2.5-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file alerts_in_ua-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: alerts_in_ua-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for alerts_in_ua-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c47adf77c6dcf3f1cc34148d1e4e68289cdb4ceef775c8368d40197488bbba73
MD5 7b6fadc1883ec34e17b27b6bf910a939
BLAKE2b-256 f516e1ba75af8ce6ff645e1861db271c33894bf95bd8b956ef4a7e099a0dc745

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page