1.0.2 • Published 9 months ago

pishock-ts v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

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.

1.0.2

9 months ago

1.0.1

11 months ago

1.0.0

11 months ago