Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Include the DataSift library
import datasift
# Create a client
client = datasift.Client('DATASIFT_USERNAME', 'DATASIFT_API_KEY')
# Declare a filter in CSDL, looking for content mentioning music
csdl = 'interaction.content contains "music"'
# Compile the filter
fltr = client.compile(csdl)
# Handler: Message deleted by user
def on_delete(interaction):
print "You must delete this to be compliant with T&Cs: ", interaction
# Handler: Connection was closed
def on_close(wasClean, code, reason):
print "Stream subscriber shutting down because ", reason
# Handler: Picks up any error, warning, information messages from the platform
def on_ds_message(msg):
print( 'DS Message %s' % msg)
# Handler: Connected to DataSift
def on_open():
print "Connected to DataSift"
def on_interaction(interaction):
print "Recieved interaction: ", interaction
# Start streaming

This comment has been minimized.

Copy link

aosterloh commented Sep 16, 2015

How would I grab individual records to e.g. filter/process/enhance and then move them per HTTP to somewhere else ? (Sorry, Python beginner)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.