node-lanyard-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

node-lanyard-wrapper

Fully-typed Lanyard API wrapper for Node.js

npm npm

Features

  • Fully-typed
  • Supports both WebSocket and REST API
  • Supports fetching data for multiple users at once
  • Supports fetching data for a single user

Installation

NPM

npm i node-lanyard-wrapper

Yarn

yarn add node-lanyard-wrapper

Usage

Connecting with WebSocket

import { connectWebSocket } from 'node-lanyard-wrapper';

function onUpdate(data) {
    // data is a Lanyard data object
    console.log(data);
}

function onError(err) {
    // err is an error object
    console.error(err);
}

const ws = connectWebSocket('USER_ID', onUpdate, onError);

OR Using the REST API

import { fetchUserData, fetchUserDataForMultipleUsers } from 'node-lanyard-wrapper';

// Fetching data for a user
fetchUserData('USER_ID').then((data) => {
    // data is a Lanyard data object
    console.log(data);
});

// Fetching data for multiple users
fetchUserDataForMultipleUsers(['USER_ID_1', 'USER_ID_2']).then((data) => {
    // data is an array of Lanyard data objects
    console.log(data);
});

Contributing

Pull requests are welcome.

License

MIT

Package Sidebar

Install

npm i node-lanyard-wrapper

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.06 kB

Total Files

5

Last publish

Collaborators

  • brokiem