PowerTrack / Firehose Stream Connection
Example Code Snippets
The following snippets are examples of establishing a streaming connection to a PowerTrack or Firehose stream. You may use them as a starting point, building them out to incorporate the other functionality that is important to your app.
In general, these snippets do not handle reconnections to the stream, parse or process the JSON data, or implement any additional functionality.
Twitter Hosebird client
A Java HTTP client for consuming Twitter’s and Gnip’s Streaming API.
Gnip sample connectors
The examples below were built by Gnip, but are not actively maintained or supported. However, they illustrate asynchronous stream processing, with one process handling the incoming stream and another managing those Tweets (e.g. preparing for a datastore). These examples also implement reconnection logic, have more real-world configuration management and logging, and provide simple examples of writing Tweets to MongoDB and Redis.
The following utilities are not built or maintained by Gnip, but may provide a jumping-off point for your app.
A NodeJS application.
Gnip4j is an Java Open Source (ASFL 2.0) library to access and process Activities (tweets) from Gnip.
Python code that normalizes social data activities JSON to CSV parser.
Python script for monitoring rule production, latency, token frequency, etc.