Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (41 sloc) 1.365 kb

DataSift Python Client Library

This is an unofficial Python library for Datasift.

It currently supports compiling CSDLs via the REST API and consuming an HTTP Stream via the Streaming API.

Requirements

Example

from datasift import (
  DataSiftUser,
  DataSiftDefinition,
  DataSiftStream,
  DataSiftStreamListener
)

# Fill in account credentials
DATASIFT_USERNAME = "my_username"
DATASIFT_API_KEY = "my_api_key"

# Create user
user = DataSiftUser(DATASIFT_USERNAME, DATASIFT_API_KEY)

# Create, compile CSDL
csdl = 'interaction.type == "twitter" and '\
  '(interaction.content contains "skrillex")'
definition = DataSiftDefinition(csdl, user)
definition.compile()

# Define listener
class MyListener(DataSiftStreamListener):
    def on_data(self, data):
        print data

# Create stream, listen
listener = MyListener()
stream = DataSiftStream(listener, definition, user)
stream.listen()

License

All code is released under the MIT license. Please read the LICENSE.txt file for more details.

Acknowledgements

Thanks to joshthecoder and his tweepy library for demonstrating HTTP stream consumption via httplib.

Jump to Line
Something went wrong with that request. Please try again.