pishock-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

PiShock TS Library

A simple TypeScript-based library to interact with the PiShock API.

Installation

Install the package using npm or the package manager of your choice:

$ npm install pishock-ts

Setup

Simply create a client with the required login data.

import { PiShockDevice } from "pishock-ts";

const device = PiShockDevice({
    username: "myAwesomeUsername",
    apiKey: "12345678-1234-1234-1234-123412341234",
    code: "ABCDEFGHIJK",
    name: "MyShockinglyAwesomeTSApp"
});

See here to see where you can get the specific keys from: https://apidocs.pishock.com/#header-authenticating

Usage

Simple usage for each function. Please refer to the comments for more details.

Get Infos

const deviceInfo = await device.getInfo();
/**
 * {
 * "clientId": 1234,
 * "id": 12345,
 * "name": "PiShock 1",
 * "paused": false,
 * "maxIntensity": 100,
 * "maxDuration": 15,
 * "online": true
 * }
 */

Shock

await device.shock(
    0.3,  // Duration
    10    // Intensity
);

Vibrate

await device.vibrate(
    0.3,  // Duration
    10    // Intensity
);

Beep

await device.beep(
    0.3,  // Duration
);

Contributing

Contributions to this library are always welcome and highly encouraged.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Readme

Keywords

Package Sidebar

Install

npm i pishock-ts

Weekly Downloads

10

Version

1.0.2

License

MIT

Unpacked Size

28.3 kB

Total Files

18

Last publish

Collaborators

  • steffospieler
  • hlxid