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.

Hosebird Client Library

Example Client for Gnip PowerTrack API streams


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.


Other Options

The following utilities are not built or maintained by Gnip, but may provide a jumping-off point for your app.

University of Wollongong Smart Infrastructure Facility PowerTrack consumer

A NodeJS application.

Gnip4j

Gnip4j is an Java Open Source (ASFL 2.0) library to access and process Activities (tweets) from Gnip.

Gnacs

Python code that normalizes social data activities JSON to CSV parser.

Gnip-Stream-Collector-Metrics

Python script for monitoring rule production, latency, token frequency, etc.