gnip

Connect to Gnip streaming API and manage rules

gnip

Connect to Gnip streaming API and manage rules. You must have a Gnip account with any data source available, like Twitter Power Track.

Currenly, this module only supports JSON activity stream format, so you must enable data normalization in your admin panel.

Gnip.Stream

This class is an EventEmitter and allows you to connect to the stream and start receiving data.

Connect to the stream and start receiving data. At this point you should have registered at least one event listener for any of these events: 'data', 'object' or 'tweet'.

Terminates the connection.

Gnip.Rules

This class allows you to manage an unlimited number of tracking rules.

Get cached rules.

Creates or replaces the live tracking rules.
Rules are sent in batches of 5000 (API limit), so you can pass an unlimited number of rules.
The current tracking rules are stored in a local JSON file so you can update the existing rules efficiently without having to remove them all.

Clears cached rules.

Example Usage

var Gnip = require('gnip');

var stream = new Gnip.Stream({
    url : 'https://stream.gnip.com:443/accounts/xxx/publishers/twitter/streams/track/prod.json',
    user : 'xxx',
    password : 'xxx'
});
stream.on('ready', function() {
    console.log('Stream ready!');
});
stream.on('tweet', function(tweet) {
    console.log(tweet);
});
stream.on('error', function(err) {
    console.error(err);
});

var rules = new Gnip.Rules({
    url : 'https://api.gnip.com:443/accounts/xxx/publishers/twitter/streams/track/prod/rules.json',
    user : 'xxx',
    password : 'xxx'
});

rules.update(['#hashtag', 'keyword', '@user'], function(err) {
    if (err) throw err;
    stream.start();
});

More details and tests soon...