Python lib for adding Pusher support into your application
Switch branches/tags
Nothing to show
Pull request Compare This branch is 2 commits ahead, 234 commits behind pusher:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Pusher Python module


This module has been tested with Python 2.5 and 2.6.

You can install this module using your package management method or choice, normally easy_install or pip. For example:

pip install pusher

Getting started

After registering at, create an instance, specifying your security credentials:

p = pusher.Pusher(app_id='your-pusher-app-id', key='your-pusher-key', secret='your-pusher-secret')

You can then create channels and trigger events. Channel and event names may only contain alphanumeric characters, '-' and '_':

p['a_channel'].trigger('an_event', {'some': 'data'})

You can also specify socket_id as a separate argument, as described in

p['a_channel'].trigger('an_event', {'some': 'data'}, socket_id)

Advanced usage

A custom json encoder class, such as the one provided by Django may also be specified:

from django.core.serializers.json import DjangoJSONEncoder
p = pusher.Pusher(app_id=..., encoder=DjangoJSONEncoder)


If you're using Pusher as a Heroku add-on, you can just get the config information like this:

p = pusher.pusher_from_url()


To use the Tornado web server to trigger events, set channel_type:

pusher.channel_type = pusher.TornadoChannel

To see this functionality in action, look at examples/

Google AppEngine

To force the module to use AppEngine's urlfetch, do the following on setup:

pusher.channel_type = pusher.GoogleAppEngineChannel

I haven't been able to test this though. Can somebody confirm it works? Thanks! :-)

Running the tests

The pusher directory contains the following test files:


The tests can be run using nose. You will need to run them individually using nosetests <filename> e.g nosetests

The tests defined in execute against the Pusher service. For these to run you must rename the file to and update the values in it to valid Pusher application credential files.

Special thanks

Special thanks go to Steve Winton, who implemented a Pusher module in Python for the first time, with focus on AppEngine. This module borrows from his contribution at


Copyright (c) 2012 Pusher Ltd. See LICENSE for details.