Skip to content

Python client library for Spire realtime notifications service

Notifications You must be signed in to change notification settings

spire-io/spire.io.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spire.io.py

Python client library for Spire.io APIs.

Examples

Here's an example using the message service.

client = spire.Client(async=False, key=key) # key is your account key
session = client.session()
channel = session.channel('foo', 'the foo channel')
channel.publish('What hath Shark wrought?')

Let's create a second session and get our messages.

client2 = spire.Client(async=False, key=key) # key is your account key
session2 = client2.session()
channel2 = session2.channel('foo', 'the foo channel')
channel2.subscribe() # => 'What hath Shark wrought?'

You can also assign listener blocks to a subscription which will be called with each message received. async=True indicates your system has libevent/gevent installed for evented callbacks.

client3 = spire.Client(async=True, key=key) # key is your account key
session3 = client3.session()
channel3 = session3.channel('foo', 'the foo channel')

def get_callback(channel_name):
    def _callback(events):
        print events
    return _callback

channel3.subscribe(callback=get_callback("foo"))

Documentation

API documentation

Dependencies

(up-to-date dependencies will always be in setup.py)

  • Requests is the only external dependency on Python 2.6+
  • If you are running Python 2.5, you will need to install simplejson
  • Asynchronous operation requires gevent (which in turn requires greenlet and libevent) - if you are running Debian or Ubuntu the system package (python-gevent) is recommended as installing from source via pip may lead to segfaults, and nobody likes those.

About

Python client library for Spire realtime notifications service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages