A Python wrapper around the ntfy API.
Project description
ntfy-api
A Python wrapper around the ntfy API
Install
$ pip install ntfy-api
Usage
This package supports sending and receiving messages. Here is an example of how to send a message:
import ntfy_api
# create a client
client = ntfy_api.NtfyClient(
base_url="https://www.example.com",
credentials=ntfy_api.Credentials(...), # if authorization is needed
)
# create a message
msg = Message(
topic="my-topic",
message="**Hello World**",
title="Super Cool Message",
priority=Priority.urgent, # or `5`
tags=[Tag._100], # or `["100"]`
markdown=True,
delay="10m",
actions=[
ViewAction(label="GOOGLE", url="https://google.com"),
BroadcastAction(
label="Take picture",
extras={"cmd": "pic", "camera": "front"}
)
],
click="https://youtube.com",
attach="https://docs.ntfy.sh/static/img/ntfy.png",
filename="ntfy_api.png",
icon="https://ntfy.sh/_next/static/media/logo.077f6a13.svg"
)
# send message
client.publish(msg)
For polling or subscribing:
# poll messages
for msg in client.poll("my-topic"):
print('>> Message received <<')
print(f'Title: {msg.title}')
print(f'Message: {msg.message}')
print(f'Click: {msg.click}')
if msg.attachment:
print(f'Attachments: {msg.attachment}')
# subscribe
with client.subscribe("my-topic") as subscription:
msg = subscription.messages.get()
print('>> Message received <<')
print(f'Title: {msg.title}')
print(f'Message: {msg.message}')
print(f'Click: {msg.click}')
if msg.attachment:
print(f'Attachments: {msg.attachment}')
Tests and Coverage Policies
This project does not have coverage reports or test results available. As part of the release process, full (100%) code coverage is required, and all tests must pass for all supported versions on all major operating systems.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ntfy_api-1.0.0rc1.tar.gz.
File metadata
- Download URL: ntfy_api-1.0.0rc1.tar.gz
- Upload date:
- Size: 44.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a407251e585fd9c1f777eafdc648f99c739890c4b87e056442c4b71033237d4e
|
|
| MD5 |
fcc9c4d28245d29f3e51df4de7937ece
|
|
| BLAKE2b-256 |
79f02d12b5405016aa8a75bb433ba930692af6b71ea56d69a0fd675f565f80ee
|
File details
Details for the file ntfy_api-1.0.0rc1-py3-none-any.whl.
File metadata
- Download URL: ntfy_api-1.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 42.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
833c1bf355f979075015670aa8fbbc0997072f807a4d337488a3a367e16942a0
|
|
| MD5 |
81b88c1602d8ed8e51350ca09cd055df
|
|
| BLAKE2b-256 |
7eeb6688f5c4d83e90cec7a396578f592cb80bba21bdf536d71fe96ab37b8dec
|