Skip to main content

An ntfy library aiming for feature completeness

Project description

A Python Library For ntfy.sh

An easy-to-use ntfy python library. Aiming for full feature support.

Quickstart

  1. Install using pip with pip3 install python-ntfy
  2. Configure the following environment variables:
    • NTFY_USER: The username for your server (if required)
    • NTFY_PASSWORD: The password for your server (if required)
    • NTFY_SERVER: The server URL (defaults to https://ntft.sh)
  3. Setup your application to use the library:
# Import the ntfy client
from python_ntfy import NtfyClient

# Create an `NtfyClient` instance with a topic
client = NtfyClient(topic="Your topic")

# Send a message
client.send("Your message here")

Supported Features

  • Username + password auth
  • Custom servers
  • Sending plaintext messages
  • Sending Markdown formatted text messages
  • Retrieving cached messages
  • Scheduled delivery

Future Features

  • Access token auth
  • Email notifications
  • Tags
  • Action buttons
  • Send to multiple topics at once

Test and Development

This project uses:

  • Poetry as it's dependency manager
  • Ruff for linting and code formatting

To install dev dependencies, run poetry install --with dev.

Linting and Formatting

These can be run with:

  • poetry run ruff format
  • poetry run ruff check

Tests

This project is aiming for 95% code coverage. Any added features must include comprihensive tests.

You can run the tests against a local instance of ntfy or ntfy.sh.

Setup Steps

  1. To test against a local ntfy instance: i. Create a container using docker run -p 80:80 -it binwiederhier/ntfy serve --attachment-cache-dir=/cache --base-url=http://localhost ii. Set the following key in the .env file: NTFY_SERVER=http://localhost iii. Add a dummy username and password to .env (see example.env)
  2. To test against https://ntfy.sh: i. Add username and password for ntfy.sh to .env (see example.env)
  3. Run the tests with poetry run pytest --cov

The tests will sent messages to the python_ntfy_testing topic so you will need to subcribe to that topic to see the test messages.

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

python_ntfy-0.2.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

python_ntfy-0.2.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file python_ntfy-0.2.1.tar.gz.

File metadata

  • Download URL: python_ntfy-0.2.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for python_ntfy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f6ff1641af8844c2299be4ca78e7c4c5d9232183f24dc4b54e31671a0b77d1bf
MD5 b9100bb2f0d2ce5f096d938a86a45b1f
BLAKE2b-256 d3bdf0e7c93e40d06d0cce897949cd6cec921f6a40cf645be1264edf48a94cc3

See more details on using hashes here.

File details

Details for the file python_ntfy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: python_ntfy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for python_ntfy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75585b44fa5c046b4d58a28ed3515d2891662b6e6601d71dcc46c02a64370fe4
MD5 491efcb71e4ad9b4e1037f883f4b2768
BLAKE2b-256 1af30a458ab5d2b195ab671e4d0ebf86124caf1fe94ba77497be48fc87a32c56

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