An ntfy library aiming for feature completeness
Project description
A Python Library For ntfy
An easy-to-use python library for the ntfy notification service. Aiming for full feature support and a super easy to use interface.
Quickstart
- Install using pip with
pip3 install python-ntfy
- 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 tohttps://ntft.sh
)
- 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")
See the full documentation site at https://matthewcane.github.io/python-ntfy/.
Supported Features
- Username + password auth
- Access token auth
- Custom servers
- Sending plaintext messages
- Sending Markdown formatted text messages
- Retrieving cached messages
- Scheduled delivery
- Tags
- Action buttons
Future Features
- Email notifications
- Send to multiple topics at once
Testing and Development
This project uses:
- Poetry as it's dependency manager
- Ruff for linting and code formatting
- MyPy for static type checking
To install dev dependencies, run poetry install --with dev
.
Linting, Formatting and Type Checking
These can be run with:
poetry run ruff format
poetry run ruff check
poetry run mypy .
These tools are also run in the CI pipeline and must pass before merging.
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
- To test against a local
ntfy
instance: i. Create a container usingdocker 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) - To test against
https://ntfy.sh
: i. Add username and password for ntfy.sh to.env
(see example.env) - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python_ntfy-0.3.6.tar.gz
.
File metadata
- Download URL: python_ntfy-0.3.6.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31490685fea9daac92a93a06e7113ec713d23354867f8a1c9e1f2af709a621f1 |
|
MD5 | 2185848cdddb0ae0a1072c273682f03e |
|
BLAKE2b-256 | 4f16f28522f6e5ecb7720e5054babdd3547274d15a887176707b65bbc20b705a |
File details
Details for the file python_ntfy-0.3.6-py3-none-any.whl
.
File metadata
- Download URL: python_ntfy-0.3.6-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8653dbed9ef9c21d4fba482a8d6770e9a2c35f33f06db620ec0f160e8a93c912 |
|
MD5 | 6e2355424ba142e072d7dcb84077e570 |
|
BLAKE2b-256 | dbc09cbac273405dcf982b9bdae8424b9b4ed3c05861afeb743a4eed12b37689 |