chirp-stream
v1.0.1
Published
twitter streaming apis in nodejs
Downloads
4
Readme
chirp-stream
twitter streaming apis in nodejs
Installation
npm i chirp-stream --save
Usage
var twitter = Chirp({
consumer: {
public: 'xxxxx',
secret: 'xxxxx'
},
token: {
public: 'xxxxx',
secret: 'xxxxx'
}
});
var userstream = twitter.stream('https://userstream.twitter.com/1.1/user.json');
userstream.on('data', function(data) {
console.log(data);
});
userstream.on('json', function(json) {
console.log(json);
});
userstream.on('end', function() {
console.log('end');
});
userstream.on('error', function(error) {
console.log(error);
});
Example
Public streams
statuses/filter
var filterstream = twitter.stream('https://stream.twitter.com/1.1/statuses/filter.json', {
follow: 61260444 //me :)
});
//listen to events...
statuses/sample
var samplestream = twitter.stream('https://stream.twitter.com/1.1/statuses/sample.json');
//listen to events...
User streams
var userstream = twitter.stream('https://userstream.twitter.com/1.1/user.json');
//listen to events...
Option
consumer
:Object
Twitter app public and secret consumer.token
:Object
Client public and secret token.
API
.stream()
create a stream
options
url
:String
Twitter endpointparam
:Object
Twitter parametersoptional
method
:String
defaultGET
return
streaming object
event
data
:String
twitter raw data. Beware: there are some incomplete datajson
:Object
twitter data Use this instead ofdata
response
:Object
response objecterror
: status code (404, 503, ...)end