0.0.7 • Published 10 years ago

twitter-streaming-client v0.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

twitter-streaming-client

Build Status

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 received
  • delete(status): when a status is deleted
  • favorite(event): when a authorized user's status is favorited
  • friends(friends): when authorized user's friends data are recived
  • error(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.

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago