# twitter-streaming-client

> Twitter Streaming API Client

Latest version **0.0.7** (published 2015-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install twitter-streaming-client
pnpm add twitter-streaming-client
yarn add twitter-streaming-client
bun add twitter-streaming-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2015-07-18 |
| First published | 2015-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Junpei Tajima |
| Maintainers | p-baleine |
| Keywords | twitter |

## Links

- npm: https://www.npmjs.com/package/twitter-streaming-client
- Repository: https://github.com/p-baleine/twitter-streaming-client
- Issues: https://github.com/p-baleine/twitter-streaming-client/issues
- npm.io page: https://npm.io/package/twitter-streaming-client

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [request](https://npm.io/package/request.md) ^2.58.0
- [component-emitter](https://npm.io/package/component-emitter.md) ^1.2.0

## Recent versions

- 0.0.7 (latest) — 2015-07-18
- 0.0.6 — 2015-07-18
- 0.0.5 — 2015-07-17
- 0.0.4 — 2015-07-17
- 0.0.3 — 2015-07-17
- 0.0.2 — 2015-07-17
- 0.0.1 — 2015-07-17

## 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 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](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: "<comma separated keywords>" } }` 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.

---
_Source: https://npm.io/package/twitter-streaming-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
