Skip to content
A Google App Engine wrapper for the pusherapp service (
Find file
Pull request Compare This branch is 1 commit ahead, 1 commit behind swinton:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Google App Engine Pusherapp Wrapper

Getting started

Request pusher credentials from

First, instantiate a pusher, using your API key

import pusherapp
pusher = pusherapp.Pusher(app_id='your-pusher-app-id',
    key='your-pusher-api-key', secret='your-pusher-secret')

Next, trigger an event

pusher['channel'].trigger('event', data={'msg': 'Hello world!'})

You probably want to run this in a taskqueue... read on for details...

Using within Google App Engine

Typical usage (e.g. using a taskqueue, see:

import pusherapp

from google.appengine.api import urlfetch
from google.appengine.api.labs import taskqueue
from google.appengine.ext import webapp

class MyWebAppRequestHandler(webapp.RequestHandler):

    def get(self):
        # ...

    def post(self):
        # ...

        # Trigger some event with pusherapp, using a taskqueue
        # The task will be picked up by WorkerPushRequestHandler, below
        taskqueue.add(url='/worker/push/channel/event', params={'msg': 'Hello world!'})

        # ...

class WorkerPushRequestHandler(webapp.RequestHandler):

    pusher_api_key = "{your-pusher-api-key}"
    pusher_app_id  = "{your-pusher-app-id}"
    pusher_secret  = "{your-pusher-secret}"

    def post(self, channel, event):

        # Construct pusher...
        pusher = pusherapp.Pusher(app_id=self.pusher_app_id,
            key=self.pusher_api_key, secret=self.pusher_secret)

        # Construct data from request parameters...
        data = dict([(arg, self.request.get(arg)) for arg in self.request.arguments()])

        # Trigger the event...
        result = pusher[channel].trigger(event, data=data)

        # Handle success/failure...
        if result.status_code >= 200 and result.status_code <= 299:
            self.response.headers["Content-Type"] = "text/plain"
Something went wrong with that request. Please try again.