A simple and easy to use package to help send push notifications via pushover.net.
Project description
PushOver Push Notification API Module
A single Python Module that allows for the interaction with PushOver's Push Notification API. PushOver offers a service that makes it really easy to send Push Notification to devices (laptops, phones, etc). This is all accomplished easily through the use of POST Requests to their API Endpoint. This module just takes the easy to use service and wraps it up in a nice and quick way to allow for quicker script writing.
Set up:
- Get an account at: https://pushover.net/ (This is the "Dashboard" URL once signed in)
- Copy
example.env
and rename it to.env
- Grab the "User Key" and add it to the designated place (
USER_KEY
) in the.env
, found in the root of the project directory (pushover/
) - Next create your application through: https://pushover.net/apps/build
- Grab the "API Token/Key" (we'll call it a "API Token" because the POST calls it a Token so therefore it is a TOKEN). Add the API Token to the designated place (
API_TOKEN
) in the.env
- Finally run:
pip install -r requirements.txt
- DON'T FORGET TO ADD A DEVICE AND INSTALL THE APP ON YOUR PHONE OR HAVE THE BROWSER REGISTERED! This can be done through the Dashboard.
Usage and Limitations:
Once you have completed the set up, you should be ready to use the module. There are some limitations the PushOver Push Notification API. These limitations are actually also handled within the python module itself, as validation, to help avoid users of this module from wasting API Calls and wasting their time. Before using the module make sure to give a quick glance to the limitations: https://pushover.net/api#limits.
None of the limitations are particularly major. Mainly max length restrictions on URLs and Text, and then Byte Size limits on Images.
Usage
from simple_pushover import PushoverAPI
# first create a PushoverAPI instance
api = PushoverAPI()
# To send a message (under 1024 Characters...) You can use the simple_send_push or the more featureful send_push.
# Really only the message kwarg is required.
api.simple_send_push(message="Hello World")
# You can also add the priority kwarg to set the priority level (-2 thru 2). I.E. priority=1 sends a message with a High Priority. It should be noted that the default is 0 which is normal priority
api.simple_send_push(message="Hello World", priority=1)
# For more complex Push notifications you can use:
api.send_push(
title="Test Title",
message="This is an example of a more complex push notification.",
url="https://example.com/",
url_title="Link Display Title",
attachment="path/to_img.png",
priority=1
)
# Once again the only required kwarg is message. However If you pass the kwarg url_title, you must also pass a URL.
Future Enhancements:
I may add some other minor pieces to the module to help with other APIs that PushOver offers ( maybe once I have a need for them :^) ). The Push Notification still has some touch ups needed which can be found below...
TO DO:
- Add filetype validation to the image attachments... Technically their API only handles images as attachments according to their API. I forgot to add that check, DOH!
- Add HTML parsing options
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
Built Distribution
Hashes for simple_pushover-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6098c8ea495b29d0d37322b284aecc1dbe933da84d31f3f07a349b77ecf6dc30 |
|
MD5 | 7b5bc538608b264975febef94cdbc892 |
|
BLAKE2b-256 | 39ea798be3a384416ea57469451832b43c686321e5686387206e2186e18634ee |