Skip to main content

aiontfy

Asynchronous client library for the ntfy pub-sub notification service

build codecov PyPI version PyPI - Downloads "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."""

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!

Metadata

Release files for aiontfy 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiontfy 0.6.1
File Size Uploaded
aiontfy-0.6.1.tar.gz 24.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiontfy 0.6.1
File Interpreter ABI Platform
aiontfy-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 39.1 kB

Release files / aiontfy-0.6.1.tar.gz

Download URL aiontfy-0.6.1.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
01588b10cb0c58def5be1bd40815be72136adc3da659fc9ca4a3437020900312
BLAKE2b-256 checksum
How to use checksums
b9184dcb3195de7435fc85235e8c62453805948cc1c83cd5928d45bd23edd594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via python-httpx/0.28.1

Release files / aiontfy-0.6.1-py3-none-any.whl

Download URL aiontfy-0.6.1-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e279afa4651c552a083f63f9631a2cf7e4248b31c97de2c543956108dc2a75fb
BLAKE2b-256 checksum
How to use checksums
8fd39cc1ca280dad9574643356d5cbfb3f66aff10e331c79ae11833254c29724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via python-httpx/0.28.1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page