# iotery-client-sdk

> iotery.io client SDK for ES6

Latest version **0.0.5** (published 2019-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install iotery-client-sdk
pnpm add iotery-client-sdk
yarn add iotery-client-sdk
bun add iotery-client-sdk
```

## 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.5 |
| Published | 2019-04-06 |
| First published | 2019-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 332.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bjyurkovich |
| Maintainers | bjyurkovich |

## Links

- npm: https://www.npmjs.com/package/iotery-client-sdk
- npm.io page: https://npm.io/package/iotery-client-sdk

## Recent versions

- 0.0.5 (latest) — 2019-04-06
- 0.0.49 — 2019-04-06
- 0.0.48 — 2019-04-06
- 0.0.47 — 2019-04-06
- 0.0.46 — 2019-04-06
- 0.0.45 — 2019-04-06
- 0.0.44 — 2019-04-06
- 0.0.43 — 2019-04-06
- 0.0.42 — 2019-04-06
- 0.0.41 — 2019-04-06
- 0.0.4 — 2019-04-06
- 0.0.3 — 2019-04-06
- 0.0.2 — 2019-04-06
- 0.0.1 — 2019-04-06

## README

# iotery.io Client SDK

> ## WARNING: The is not officially supported and should be used with caution given its requirement for you to handle your own transpilation and bundling.

The iotery.io client SDK is intended to be used by our ES6 enabled build toolchain in order to interact with the itoery.io IoT Platform. The SDK is a fully featured wrapper for the [REST API](https://somelink_to_swagger_docs).

## Getting Started

Setup your free account on [iotery.io]() and go to your [settings dashboard]() to get your server API Key.

After you get your key, install the SDK:

```bash
npm install iotery-client-sdk
```

And finally, some simple example usage:

```js
import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";

import Iotery from "iotery-client-sdk";

const iotery = new Iotery("my-api-key", {
  baseUrl: "http://localhost:3005",
  token: "jwtToken"
});

class App extends Component {
  async componentDidMount() {
    let d = await iotery.getDeviceTypes();
    console.log(d);
  }
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
      </div>
    );
  }
}

export default App;
```

> The above code connects you to the iotary.io platform, creates a device type, and a device, then retrieves all your device types.

Next, you might want to create a data type for the the device type you created...here's an example snippet:

```js
let temperatureDataType = await iotery.createDataType(
  { deviceTypeUuid: thermalSensorDeviceType.uuid },
  {
    name: "Temperature",
    enum: "TEMPERATURE",
    units: "C",
    isNumber: true
  }
);
```

For a tutorial on setting up a full stack system in 15 minutes using iotery.io, check [this link](medium_article) out.

## API

This SDK simply wraps the [REST API](https://somelink_to_swagger_docs), so more information and specifics can be found there. Since the API is a wrapper around the REST API, the syntax is standard for each of the Create, Read, Update, and Delete operations on iotery.io resources. All methods return a `Promise`.

### Creating Resources

The generalized syntax for creating resources in iotery.io looks like:

```js
methodName({ input: "parameters" }, { data: "variables" });
```

For example, to create a device, the javascript would look like

```js
createDevice(
  { deviceTypeUuid: "a-valid-device-type-uuid" },
  { name: "My Device", other: "parameter" }
);
```

where `createDevice` maps to `methodName`, `deviceTypeUuid` maps to `input`, and `name` and `other` map to `data : "variables"` in the generalized form given above.

The available resource creation methods are

|    `methodName`    | `input` | link |  `description`
|:-----------:|:-----------:|:-----------:|:-----------:|
| createDeviceType |  | [link](https://iotery.io/v1/docs#createDeviceType) | Creates a new device type |
| createDevice | deviceTypeUuid | [link](https://iotery.io/v1/docs#createDevice) | Creates a new device with a given device type |

### Reading Resources

The generalized syntax for reading resources looks like:

```js
methodName({ input: "parameters" }, { query: "variables" });
```

For example, to get a device, the javascript would look like

```js
getDeviceByUuid({ deviceUuid: "a-valid-device-uuid" }, { limit: 1 });
```

where `getDeviceByUuid` maps to `methodName`, `deviceUuid` maps to `input`, and `limit` maps to `query` in the generalized form given above.

The available resource reading methods are

|    `methodName`    | `input` | link |  `description`
|:-----------:|:-----------:|:-----------:|:-----------:|
| getDeviceTypes |  | [link](https://iotery.io/v1/docs#getDeviceTypes) | Gets all device types |
| getDeviceTypeByUuid | deviceTypeUuid | [link](https://iotery.io/v1/docs#getDeviceyTypeByUuid) | Gets a device type by uuid |

### Updating Resources

The generalized syntax for updating resources in iotery.io looks like:

```js
methodName({ input: "parameters" }, { data: "variables to update" });
```

For example, to create a device, the javascript would look like

```js
updateDevice(
  { deviceUuid: "a-valid-device-uuid" },
  { name: "My New Device Name", other: "new value" }
);
```

where `updateDevice` maps to `methodName`, `deviceUuid` maps to `input`, and `name` and `other` map to `data : "variables to update"` in the generalized form given above.

The available update methods are

|    `methodName`    | `input` | link |  `description`
|:-----------:|:-----------:|:-----------:|:-----------:|
| updateDeviceType | deviceTypeUuid | [link](https://iotery.io/v1/docs#updateDeviceType) | Updates a device type by uuid |

### Deleting Resources

The generalized syntax for deleting resources looks like:

```js
methodName({ input: "parameters" });
```

For example, to delete a device, the javascript would look like

```js
deleteDevice({ deviceUuid: "a-valid-device-uuid" });
```

where `deleteDevice` maps to `methodName` and `deviceUuid` maps to `input` in the generalized form given above.

The available resource deleting methods are

|    `methodName`    | `input` | link |  `description`
|:-----------:|:-----------:|:-----------:|:-----------:|
| deleteDeviceType | deviceTypeUuid | [link](https://iotery.io/v1/docs#deleteDeviceType) | Deletes a device type by uuid |

## Contributing

We welcome contributors and PRs! Let us know if you are interested.

## Testing

To test, start the `mock-server.js` in `/test` and use `mocha` to run `test/index.js`.

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