Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p-baleine/twitter-streaming-client
Twitter Streaming API Client.
https://github.com/p-baleine/twitter-streaming-client
Last synced: 21 days ago
JSON representation
Twitter Streaming API Client.
- Host: GitHub
- URL: https://github.com/p-baleine/twitter-streaming-client
- Owner: p-baleine
- License: mit
- Created: 2015-07-17T12:37:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-18T23:13:27.000Z (over 9 years ago)
- Last Synced: 2024-10-11T16:09:59.700Z (28 days ago)
- Language: JavaScript
- Size: 270 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# twitter-streaming-client
[![Build Status](https://travis-ci.org/p-baleine/twitter-streaming-client.svg?branch=master)](https://travis-ci.org/p-baleine/twitter-streaming-client)
Twitter Streaming API Client.
## Installation
```bash
$ npm install twitter-streaming-client
```## Example
The following code connects to [User Stream](https://dev.twitter.com/streaming/userstreams) and displays statuses.
```js
var format = require("util").format;
var userStream = require("..").userStream;var oauth = {
consumer_key: '',
consumer_secret: '',
token: '',
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](https://dev.twitter.com/streaming/public) 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](https://dev.twitter.com/streaming/userstreams).
### publicStream(oauth)
Create a `TwitterStreamClient` that connects to [Public streams](https://dev.twitter.com/streaming/public).
### TwitterStreamClient#open(requestOption)
Open a connection to Streaming API.
Tracking keywords can be specified as `{ form: { track: "" } }` form in `requestOptions`.### TwitterStreamClient#close()
Close a connection to Streaming API.
## Development
twitter-streaming-client takes advantage of [Babel](https://babeljs.io/). Source code are in `src` directory and generated code are in `lib` directory.
### Build
```bash
$ npm run build
```### Test
```bash
$ npm test
```### Lint
```bash
$ npm run lint
```## License
twitter-streaming-client is released under the MIT License.