twitter-streaming-client
v0.0.7
Published
Twitter Streaming API Client
Downloads
16
Readme
twitter-streaming-client
Twitter Streaming API Client.
Installation
$ npm install twitter-streaming-client
Example
The following code connects to User Stream and displays statuses.
var format = require("util").format;
var userStream = require("..").userStream;
var oauth = {
consumer_key: '<CONSUMER KEY>',
consumer_secret: '<CONSUMER SECRET>',
token: '<ACCESS TOKEN>',
token_secret: '<ACCESS TOKEN SECRET>'
};
function printStatus(status) {
console.log(format("%s %s\n%s\n\n", status.user.screen_name,
status.created_at, status.text));
}
userStream(oauth).open()
.on("error", function(err) { console.log(err); })
.on("status", printStatus);
Another example connected to Public streams is in the examples
directory.
Events
Currently only following events are supported. Other events would be supported soon.
status
(status): when a status is receiveddelete
(status): when a status is deletedfavorite
(event): when a authorized user's status is favoritedfriends
(friends): when authorized user's friends data are recivederror
(err): when an error occurred
API
userStream(oauth)
Create a TwitterStreamClient
that connects to User Stream.
publicStream(oauth)
Create a TwitterStreamClient
that connects to Public streams.
TwitterStreamClient#open(requestOption)
Open a connection to Streaming API.
Tracking keywords can be specified as { form: { track: "<comma separated keywords>" } }
form in requestOptions
.
TwitterStreamClient#close()
Close a connection to Streaming API.
Development
twitter-streaming-client takes advantage of Babel. Source code are in src
directory and generated code are in lib
directory.
Build
$ npm run build
Test
$ npm test
Lint
$ npm run lint
License
twitter-streaming-client is released under the MIT License.