/pushbullet.py

A python client for http://pushbullet.com

Primary LanguagePythonMIT LicenseMIT

PushBullet.py

This is a python library for the wonderful PushBullet service. It allows you to send push notifications to Android and iOS devices.

In order to use the API you need an API key that can be obtained here. This is user specific and is used instead of passwords.

Installation

The easiest way is to just open your favorite terminal and type

pip install pushbullet.py

Alternatively you can clone this repo and install it with

python setup.py install

Requirements

  • Python. Tested on 2.7 and 3.
  • The wonderful requests library.

Usage

Authentication

from pushbullet import PushBullet

pb = PushBullet(api_key)

Getting the devices

# Get all devices that the current user has access to.
print(pb.devices)
# [Device("api_key", 12345)]

# Get a device by it's ID
phone = pb.get(12345)
# or
phone = pb[12345]

# Reload the list of devices, in case a new one was added.
pb.reload_devices()

You can also create Device objects directly:

from pushbullet import Device

phone = Device(api_key, device_id)

This doesn't make a network request.

Pushing things

Pushing a text note

push = phone.push_note("This is the title", "This is the body".)

Pushing an address

address = " 25 E 85th St, 10028 New York, NY"
push = phone.push_address("home", address)

Pushing a list

to_buy = ["milk", "bread", "cider"]
push = phone.push_list("Shopping list", to_buy)

Pushing a link

push = phone.push_link("Cool site", "https://github.com")

Pushing a file

with open("my_cool_app.apk", "rb") as apk:
	push = phone.push_file(apk)

Error checking

All pushes return the underlying requests object that can be used to check the status of the operation

print(push.status_code)
# 200

The pushbullet api documetation contains a list of possible status codes.

TODO

  • Add better error handling
  • Tests, tests, tests. Write them.

License

MIT license. See LICENSE for full text.