Skip to main content

Python Pushover Open Client

py-pushover-open-client aims to provide unofficial Python bindings for Pushover's Open Client API.

Usage

Setup

pip3 install py-pushover-open-client 

Or simply clone this repository, change into it's root directory and run "pip3 install ."

How to Use

You can now import the main client using:

from pushover_open_client import Client

Please see the examples provided for more detail.

Device Registration

The first step is to register a new desktop device with the Pushover servers. This gives us certain device properties, specifically a secret, user key and device key, which can be saved and used by our client to recieve messages.

To do this, you must setup a configuration file in JSON format containing your Pushover's email and password as below:

{
	"email": "myPushoverEmail@example.com",
	"password": "myPushoverPassword",
	"secret": "",
	"deviceID": "",
	"userID": ""
}

Then run code that looks like below. Replace "deviceName" with a device name between 0 and 25 characters long, "yourInConfig.cfg" with the name of your input configuration file, and "yourOutConfig.cfg" with the name intended for your output configuration file.
Note: These can be the same name if you wish.

from pushover_open_client import Client

client = Client("yourInConfig.cfg")
client.login()
client.registerDevice("deviceName")
client.writeConfig("yourOutConfig.cfg")

Assuming the deviceName has not already been taken, your new device will be registered!

Note: If you receive an error message saying you could not register the device, try changing the name to be a unique name.

Receiving Messages

Once you have completed registration of the device, you want to continue to use the output configuration file which was written during registration. This will contain the information needed to log in to the servers and to receive messages.

When you initially start a client, you will want to flush out any previously recorded messages. This is also a good way to test that your registration has been successful, as you will receive at least one test message from Pushover.

To do this, start a new session using the written configuration and get any outstanding messages as below:

client = Client("yourOutConfig.cfg")
messageList = client.getOustandingMessages()

#Process/do work with messageList
if(messageList):
	for m in messageList:
		print m.message

	client.deleteMessages(messageList[-1].id)

After you have flushed out any previous messages, you can connect to the websocket to receive real time messages! This can be done in one of two methods - via polling, or via passing in a callback function (recommended). Here are examples of both:

Polling:
while(True):
	messageList = client.getWebSocketMessages()

	#Prcoess/do work with messageList!
	if(messageList):
		for message in messageList:

			#Do work with message here!

			#Make sure to acknowledge messages with priority >= 2
			if(message.priority >= 2):
				client.acknowledgeEmergency(message.receipt)			

		#Make sure you delete messages that you recieve!
		client.deleteMessages(messageList[-1].id)

	sleep(5) #Wait a few seconds between requests
Callback:
def messageCallback(messageList):
	#Prcoess/do work with messageList!
	if(messageList):
		for message in messageList:

			#Do work with message here!

			#Make sure to acknowledge messages with priority >= 2
			if(message.priority >= 2):
				client.acknowledgeEmergency(message.receipt)			

		#Make sure you delete messages that you recieve!
		client.deleteMessages(messageList[-1].id)

client.getWebSocketMessages(messageCallback)	

And that's it! Please remember to be responsible when accessing Pushover's API!

Message Object

Please see the open client documentation for information regarding what each message contains. Conditional elements are set to None if they do not exist to prevent exceptions.

All Messages Include:
id, umid, title, message, app, aid, icon, date, priority

Some Messages Conditionally Include: 
sound, url, url_title, acked, receipt, html

Acknowledgments

Thanks to the developers of:

  • websocket-client
  • requests

This client is not written or supported by Superblock, the creators of Pushover.

Metadata

Release files for py-pushover-open-client 1.3.0

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

Source distribution (sdist)

Source distribution for py-pushover-open-client 1.3.0
File Size Uploaded Provenance
py_pushover_open_client-1.3.0.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for py-pushover-open-client 1.3.0
File Interpreter ABI Platform
py_pushover_open_client-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / py_pushover_open_client-1.3.0.tar.gz

Download URL py_pushover_open_client-1.3.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cb5281b67ef75c17664981a56a0628a5d02f49efc5bf0533b24db34938be92a1
BLAKE2b-256 checksum
How to use checksums
9f1e37d0a829e3d80b9b438259f9a619973f1fdb6b36b11f722908917866a13c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Release files / py_pushover_open_client-1.3.0-py3-none-any.whl

Download URL py_pushover_open_client-1.3.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
003f181722cfa6e719f83444615c9154e43760cd98e312fabde2bfabe983f45f
BLAKE2b-256 checksum
How to use checksums
9ddcf3e91813ad786e17c42ff88f98b40051b1d25fa0d23077640b8d779fcf8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Security for py-pushover-open-client 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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