Skip to main content

Async ntfy client library

Project description

aiontfy

Asynchronous client library for the ntfy pub-sub notification service

build codecov PyPI version "Buy Me A Coffee" GitHub Sponsor


📖 Documentation


📦 Installation

You can install aiontfy via pip:

pip install aiontfy

🚀 Usage

Basic Examples

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

from aiohttp import ClientSession

from aiontfy import Message, Ntfy

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))
"""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](https://tr4nt0r.github.io/pynecil).

🛠 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.4.0.tar.gz (19.3 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.4.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiontfy-0.4.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for aiontfy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6105eb7b8ab03bd26fb41f8c7eb07b5479058573fb8b7e2f64b7a1fa7d4e6459
MD5 617d596cfd5a7cce7fc74deba88e80cd
BLAKE2b-256 11df621fb42c400543a9567762d596997b231a9489298bde478c2f2f980f9d42

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiontfy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for aiontfy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 270a3cf941e1855427e29f809fe3a2b855382a9f08f0a1c35c26ef41ce4bd8b5
MD5 1bc8065646582caafd4c21dfe7b5b72b
BLAKE2b-256 987d358759464eb9408d9b3cbe0b899f8146ae989163c2ec9d9780305a076030

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