# flowthings-browser

> Browser client for flowthings.io

Latest version **1.0.2** (published 2015-10-12) · Apache license · 0 weekly downloads

## Install

```sh
npm install flowthings-browser
pnpm add flowthings-browser
yarn add flowthings-browser
bun add flowthings-browser
```

## 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.0.2 |
| Published | 2015-10-12 |
| First published | 2015-07-09 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | flowthings.io |
| Maintainers | natefaubion |
| Keywords | browser, flowthings, iot |

## Links

- npm: https://www.npmjs.com/package/flowthings-browser
- npm.io page: https://npm.io/package/flowthings-browser

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-10-12
- 1.0.1 — 2015-07-09
- 1.0.0 — 2015-07-09

## README

flowthings-browser-client
=========================

## Install

NPM
```
npm install flowthings-browser
```

Bower
```
bower install flowthings-browser
```

## Example

```js
var path = '/my/flow/path';
var api = flowthings.API({
  account: '<account>',
  token: '<token>'
});

// Connect to WebSockets
api.ws.connect(function() {
  console.log('Connected');
});

// Subsribe to Drops
api.ws.subscribe(path, handler, function(err, res) {
  if (res) {
    console.log('Subscribed');
  }
});

function handler(drop) {
  console.log('Drop', drop);
}

// Query for the Flow
api.flow.find({ filter: { path: path }}, function(err, flow) {
  if (flow) {
    console.log('Flow', flow);
  }
});
```

## Configuration

### flowthings.API(config)

*   `account`
*   `token`

## WebSockets

### api.ws.connect([callback])

Initiates a WebSocket connection.

### api.ws.subscribe(flowIdOrPath, handler[, callback])

Subscribes to the provided Flow and invokes the handler when receiving Drops.

### api.ws.unsubscribe(flowIdOrPath, handler[, callback])

Unsubscribes the provided handler from the Flow.

### api.ws.send(command[, callback])

Sends arbitrary commands through the WebSocket API.

## REST

### api.flow.read(flowId[, params], callback)

### api.flow.findMany(params, callback)

### api.flow.find(..., callback)

Overloaded find method, dispatched on first argument.

### api.drop.create(drop[, callback])

### api.drop(flowId).create(drop[, callback])

### api.drop(flowId).update(drop[, callback])

### api.drop(flowId).save(...[, callback])

Overloaded save method, dispatched on first argument.

### api.drop(flowId).read(dropId[, params], callback)

### api.drop(flowId).findMany(params, callback)

### api.drop(flowId).find(..., callback)

Overloaded find method, dispatched on first argument.

### api.drop(flowId).aggregate(spec[, params], callback)

Aggregation spec options:

*   `filter`
*   `groupBy`
*   `rules`
*   `output`
*   `sorts`

Please visit the [flowthings.io aggregation documentation](https://flowthings.io/docs/flow-drop-aggregate)
for more details on how to use these options.

## Promises

Anything that takes a callback can return a `Promise` instead by using the
`promisify` transform when creating your `API`. Just provide your promise
implementation of choice.

```js
var api = flowthings.API({
  account: '<account>',
  token: '<token>',
  transform: flowthings.promisify(Promise)
});

// Query for a Flow
api.flow.find({ filter: { path: '/my/path' }})
  .then(function(flow) {
    console.log('Flow', flow)
  });
```

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