# kinesis

> A stream implementation of Amazon's Kinesis

Latest version **1.2.2** (published 2015-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install kinesis
pnpm add kinesis
yarn add kinesis
bun add kinesis
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2015-07-02 |
| First published | 2013-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 148 |
| Author | Michael Hart |
| Maintainers | hichaelmart |
| Keywords | kinesis, stream, streaming, aws, logs, logging |

## Links

- npm: https://www.npmjs.com/package/kinesis
- Repository: https://github.com/mhart/kinesis
- Homepage: https://github.com/mhart/kinesis#readme
- Issues: https://github.com/mhart/kinesis/issues
- npm.io page: https://npm.io/package/kinesis

## Dependencies (5)

- [aws4](https://npm.io/package/aws4.md) ^0.3.0
- [once](https://npm.io/package/once.md) ^1.3.1
- [async](https://npm.io/package/async.md) ^0.9.0
- [awscred](https://npm.io/package/awscred.md) ^1.0.3
- [lru-cache](https://npm.io/package/lru-cache.md) ^2.5.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2015-07-02
- 1.2.1 — 2015-05-31
- 1.2.0 — 2015-04-25
- 1.1.2 — 2015-01-06
- 1.1.1 — 2014-12-30
- 1.1.0 — 2014-12-24
- 1.0.2 — 2014-07-16
- 1.0.1 — 2014-04-04
- 1.0.0 — 2014-03-16
- 0.2.3 — 2014-02-26
- 0.2.2 — 2014-02-19
- 0.2.1 — 2014-02-19
- 0.2.0 — 2014-02-14
- 0.1.0 — 2013-12-18
- 0.0.3 — 2013-12-17
- … 3 more at https://npm.io/package/kinesis/versions

## README

kinesis
-------

[![Build Status](https://secure.travis-ci.org/mhart/kinesis.png?branch=master)](http://travis-ci.org/mhart/kinesis)

A Node.js stream implementation of [Amazon's Kinesis](http://docs.aws.amazon.com/kinesis/latest/APIReference/).

Allows the consumer to pump data directly into (and out of) a Kinesis stream.

This makes it trivial to setup Kinesis as a logging sink with [Bunyan](https://github.com/trentm/node-bunyan), or any other logging library.

For setting up a local Kinesis instance (eg for testing), check out [Kinesalite](https://github.com/mhart/kinesalite).

NB: API has changed from 0.x to 1.x
-----------------------------------

Example
-------

```js
var fs = require('fs'),
    Transform = require('stream').Transform,
    kinesis = require('kinesis'),
    KinesisStream = kinesis.KinesisStream

// Uses credentials from process.env by default

kinesis.listStreams({region: 'us-west-1'}, function(err, streams) {
  if (err) throw err

  console.log(streams)
  // ["http-logs", "click-logs"]
})


var kinesisSink = kinesis.stream('http-logs')
// OR new KinesisStream('http-logs')

fs.createReadStream('http.log').pipe(kinesisSink)


var kinesisSource = kinesis.stream({name: 'click-logs', oldest: true})

// Data is retrieved as Record objects, so let's transform into Buffers
var bufferify = new Transform({objectMode: true})
bufferify._transform = function(record, encoding, cb) {
  cb(null, record.Data)
}

kinesisSource.pipe(bufferify).pipe(fs.createWriteStream('click.log'))


// Create a new Kinesis stream using the raw API
kinesis.request('CreateStream', {StreamName: 'test', ShardCount: 2}, function(err) {
  if (err) throw err

  kinesis.request('DescribeStream', {StreamName: 'test'}, function(err, data) {
    if (err) throw err

    console.dir(data)
  })
})
```

API
---

### kinesis.stream(options)
### new KinesisStream(options)

Returns a readable and writable Node.js stream for the given Kinesis stream

`options` include:

  - `region`: a string, or (deprecated) object with AWS credentials, host, port, etc (resolved from env or file by default)
  - `credentials`: an object with `accessKeyId`/`secretAccessKey` properties (resolved from env, file or IAM by default)
  - `shards`: an array of shard IDs, or shard objects. If not provided, these will be fetched and cached.
  - `oldest`: if truthy, then will start at the oldest records (using `TRIM_HORIZON`) instead of the latest
  - `writeConcurrency`: how many parallel writes to allow (`1` by default)
  - `cacheSize`: number of PartitionKey-to-SequenceNumber mappings to cache (`1000` by default)
  - `agent`: HTTP agent used (uses Node.js defaults otherwise)
  - `timeout`: HTTP request timeout (uses Node.js defaults otherwise)
  - `initialRetryMs`: first pause before retrying under the default policy (`50` by default)
  - `maxRetries`: max number of retries under the default policy (`10` by default)
  - `errorCodes`: array of Node.js error codes to retry on (`['EADDRINFO',
    'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'EMFILE']` by default)
  - `errorNames`: array of Kinesis exceptions to retry on
    (`['ProvisionedThroughputExceededException', 'ThrottlingException']` by default)
  - `retryPolicy`: a function to implement a retry policy different from the default one

### kinesis.listStreams([options], callback)

Calls the callback with an array of all stream names for the AWS account

### kinesis.request(action, [data], [options], callback)

Makes a generic Kinesis request with the given action (eg, `ListStreams`) and data as the body.

`options` include:

  - `region`: a string, or (deprecated) object with AWS credentials, host, port, etc (resolved from env or file by default)
  - `credentials`: an object with `accessKeyId`/`secretAccessKey` properties (resolved from env, file or IAM by default)
  - `agent`: HTTP agent used (uses Node.js defaults otherwise)
  - `timeout`: HTTP request timeout (uses Node.js defaults otherwise)
  - `initialRetryMs`: first pause before retrying under the default policy (`50` by default)
  - `maxRetries`: max number of retries under the default policy (`10` by default)
  - `errorCodes`: array of Node.js error codes to retry on (`['EADDRINFO',
    'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'EMFILE']` by default)
  - `errorNames`: array of Kinesis exceptions to retry on
    (`['ProvisionedThroughputExceededException', 'ThrottlingException']` by default)
  - `retryPolicy`: a function to implement a retry policy different from the default one

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