# thethingsio-coap

> CoAP library for coap.thethings.io endpoint

Latest version **0.1.0** (published 2015-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install thethingsio-coap
pnpm add thethingsio-coap
yarn add thethingsio-coap
bun add thethingsio-coap
```

## 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.1.0 |
| Published | 2015-03-04 |
| First published | 2014-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | thethingsiO |
| Maintainers | thethingsio |
| Keywords | coap, client, theThings, thethings.iO, internet of things, IoT |

## Links

- npm: https://www.npmjs.com/package/thethingsio-coap
- Repository: https://github.com/theThings/thethingsio-coap-node
- Issues: https://github.com/theThings/thethingsio-coap-node/issues
- npm.io page: https://npm.io/package/thethingsio-coap

## Dependencies (1)

- [coap](https://npm.io/package/coap.md) 0.8.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2015-03-04
- 0.0.1 — 2014-10-09

## README

#theThings.IO node CoAP lib
This lib allows to connect to the coap.thethings.io endpoint.

Please visit the [documentation page](https://developers.thethings.io) page at [theThings.IO](https://thethings.io)


#Install
```
npm install thethingsio-coap
```

##Getting started

Sign up to [thethings.iO](https://thethings.io) and create a user. Log in and go to the [things manager](https://panel.thethings.io/#/things-manager) and press "get activation codes".

You can put your activation code in a file called config.json with this format:

```js

{
    "activationCode" : "one of your activation codes"
}
```

If you already have your thing activated you can just put the thing token
```js

{
    "thingToken" : "one of your thing tokens"
}
```

With this package you can perform 4 types of actions:

  * thingRead: Reads the last values with a certain key.
  * thingWrite: Writes one or several values to the things.
  * thingSubscribe: Subscribes to the realtime channel of the thing.

If you provide an activation code your thing will be activated automatically when you create the client. Then the thing token will be saved to the same config.json.

Please, take a look at the source folder examples/ to see some code examples.


```js
var theThingsCoAP = require('thethingsio-coap');

var client = theThingsCoAP.createClient();

var params = {limit:15}
client.on('ready', function () {
    client.thingRead('voltage', params, function (error, data) {
        console.log(error ? error : data)
    })
})
```
The previous code reads from the key 'voltage' the last 15 values. In the params object you can also add startDate and endDate in YYYYMMDDTHHmmss format. Note that the 'ready' event is fired when the activation is completed. If the thing is already activated the event will we fired after createClient()

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