2.2.0 • Published 3 years ago

waziup-js v2.2.0

Weekly downloads
7
License
Apache License v2
Repository
-
Last release
3 years ago

WAZIUP-JS

Waziup-js is a javascript client to interact with the Waziup plaform.

Installation

Install it via:

npm install --save -g waziup-js

Getting Started

Here is an example code to retrieve all devices from Waziup:

const WaziupApi = require("waziup-js");

WaziupApi.ApiClient.instance.basePath = "https://api.waziup.io/api/v2";
var api = new WaziupApi.DevicesApi();

api.getDevices().then(devices => {
  console.log("List of devices: ", JSON.stringify(devices));
});

Save this file as test.js and run:

node test.js

You should get a list of devices. The format of the devices is given here.

Authentication

You need a token to access protected resources. You can retrieve one like that:

const WaziupApi = require("waziup-js");

WaziupApi.ApiClient.instance.basePath = "https://api.waziup.io/api/v2";
var deviceApi = new WaziupApi.DevicesApi();
var authApi = new WaziupApi.AuthApi();

//Deleting a resource requires authentication
async function testDelete() {
  var token = await authApi.getAuthToken(
    "waziup",
    new WaziupApi.AuthBody("YOUR_USERNAME", "YOUR_PASSWORD")
  );
  WaziupApi.ApiClient.instance.authentications["Bearer"].apiKey =
    "Bearer " + token;

  try {
    await deviceApi.deleteDevice("MyDevice");
  } catch (error) {
    console.log("Error " + error.status);
  }
}

testDelete();

You should create a user beforehand on https://dashboard.waziup.io. As a rule of thumb, you can only update or delete resources that you are owner of.

Documentation for API Endpoints

There are 8 endpoints:

Documentation for Authorization

Bearer

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Developement

Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your waziup-js from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('waziup-js') in javascript files from the directory you ran the last command above from.

Publish

Simply type:

npm publish
2.2.0

3 years ago

2.2.0-beta1

3 years ago

2.1.2

4 years ago

2.1.3

4 years ago

2.1.1

4 years ago

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-alpha.17

5 years ago

2.0.0-alpha.16

5 years ago

2.0.0-alpha.14

5 years ago

2.0.0-alpha.13

5 years ago

2.0.0-alpha.12

5 years ago

2.0.0-alpha.11

5 years ago

2.0.0-alpha.10

5 years ago

2.0.0-alpha.9

5 years ago

2.0.0-alpha.8

5 years ago

2.0.0-alpha.7

5 years ago

2.0.0-alpha.6

5 years ago

2.0.0-alpha.5

5 years ago

2.0.0-alpha.4

5 years ago

2.0.0-alpha.3

5 years ago

2.0.0-alpha.2

5 years ago

2.0.0-alpha.1

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.2-security

6 years ago

1.0.0

6 years ago