Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Python client to interface with DataSift
Python Shell

This branch is 241 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
datasift
examples
tests
.gitignore
LICENSE
README.md
config.py
setup.py

README.md

DataSift Python Client Library

This is the official Python library for accessing Datasift. See the examples folder for some simple example usage.

All examples and tests use the username and API key in config.py.

Installation

The simplest way...

easy_install datasift

From source...

python setup.py install

Simple example

This example looks for anything that contains the word "datasift" and simply prints the content to the screen as they come in.

import sys, os, config, datasift

class EventHandler(datasift.StreamConsumerEventHandler):
  def on_interaction(self, consumer, data, hash):
    print data['interaction']['content']
  def on_warning(self, consumer, message):
    print 'WARN: %s' % (message)
  def on_error(self, consumer, message):
    print 'ERR: %s' % (message)

user = datasift.User(config.username, config.api_key)
definition = user.create_definition('interaction.content contains "datasift"')
consumer = definition.get_consumer(EventHandler(), 'http')
consumer.consume()
consumer.run_forever()

See the DataSift documentation for full details of the data contained within each interaction. See this page on our developer site for an example tweet: http://dev.datasift.com/docs/targets/twitter/tweet-output-format

The library will use SSL connections by default. While we recommend using SSL you may disable it if required by passing False as the third parameter when creating a user, or by calling enable_ssl(False) on the user object.

Requirements

  • Python 2.4+

License

All code contained in this repository is Copyright 2012 MediaSift Ltd.

This code is released under the BSD license. Please see the LICENSE file for more details.

Changelog

  • v.0.5.3 Added missing Historic sample size into historic/prepare requests (2012-12-03)

  • v.0.5.2 Patch for the missing availability info after Historic/prepare woozyking (2012-11-28)

  • v.0.5.1 Removed unit tests that are no longer required (2012-08-30)

  • v.0.5.0 Added support for Historic queries and Push delivery (2012-08-27)

  • v.0.4.0 Fixed issues with SSL timeouts & low throughput streams (2012-08-08)

  • v.0.3.0 Added SSL support and fixed a reconnection bug (2012-05-16)

    The SSL support is enabled by default and can be disabled by passing false as the third parameter to the User constructor, or calling enableSSL(false) on the User object.

  • v.0.2.0 Fixed the handling of error messages in streams (2012-05-04)

  • v.0.1.1 Initial release (2012-03-09)

Something went wrong with that request. Please try again.