npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iotery-client-sdk

v0.0.5

Published

iotery.io client SDK for ES6

Downloads

9

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.

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:

npm install iotery-client-sdk

And finally, some simple example usage:

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:

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 out.

API

This SDK simply wraps the REST API, 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:

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

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

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 | Creates a new device type | | createDevice | deviceTypeUuid | link | Creates a new device with a given device type |

Reading Resources

The generalized syntax for reading resources looks like:

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

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

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 | Gets all device types | | getDeviceTypeByUuid | deviceTypeUuid | link | Gets a device type by uuid |

Updating Resources

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

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

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

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 | Updates a device type by uuid |

Deleting Resources

The generalized syntax for deleting resources looks like:

methodName({ input: "parameters" });

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

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 | 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.