Skip to main content

Async ntfy client library

Project description

aiontfy

Asynchronous client library for the ntfy pub-sub notification service

build codecov Spectra Assure Community Badge PyPI version PyPI - Downloads GitHub Sponsor


📖 Documentation


📦 Installation

You can install aiontfy via pip:

pip install aiontfy

🚀 Usage

Basic Examples

"""Publish to a ntfy topic."""

import asyncio

from aiohttp import ClientSession

from aiontfy import Message, Ntfy


async def main() -> None:
    async with ClientSession() as session:

        ntfy = Ntfy("https://ntfy.sh", session)

        message = Message(
            topic="aiontfy",
            title="Hello",
            message="World",
            click="https://example.com/",
            delay="10s",
            priority=3,
            tags=["octopus"],
        )
        print(await ntfy.publish(message))

asyncio.run(main())
"""Subscribe to ntfy topics."""

import asyncio

from aiohttp import ClientSession

from aiontfy import Event, Notification, Ntfy


def callback(message: Notification) -> None:
    """Process notifications callback function."""
    if message.event is Event.MESSAGE:
        print(message.to_dict())


async def main() -> None:
    async with ClientSession() as session:
        ntfy = Ntfy("https://ntfy.sh", session)

        await ntfy.subscribe(
            ["aiontfy", "test"],  # Subscribe to multiple topics
            callback,
            priority=[3, 4, 5],  # Only subscribe to priority >= 3
        )


asyncio.run(main())

For more advanced usage, refer to the documentation.


🛠 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes and commit them.
  4. Submit a pull request.

Make sure to follow the contributing guidelines.


📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


❤️ Support

If you find this project useful, consider buying me a coffee ☕ or sponsoring me on GitHub!

Project details


Download files

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

Source Distribution

aiontfy-0.8.4.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiontfy-0.8.4-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file aiontfy-0.8.4.tar.gz.

File metadata

  • Download URL: aiontfy-0.8.4.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for aiontfy-0.8.4.tar.gz
Algorithm Hash digest
SHA256 3eb240e59b1af0403844dd8a060a499a54e1678daa317918340d5abd027cf897
MD5 f39cde06c077f32a7d3c9798a2fa4023
BLAKE2b-256 eaaec75306c8a09f9c8d46de8df4b9b72383e7ed7b27d669d46b214a279a3482

See more details on using hashes here.

File details

Details for the file aiontfy-0.8.4-py3-none-any.whl.

File metadata

  • Download URL: aiontfy-0.8.4-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for aiontfy-0.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f0d9a969c973cc3237ccca280492fca57ee7620ec3e9d99569ba06f2ae95965d
MD5 be0b4df5421cc9c0a6f58b721d5becd1
BLAKE2b-256 6e7a3d58c90bec64eda711bbff5858eccdcbc8491cd6708629a54135f53db940

See more details on using hashes here.

Supported by

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