node-lanyard-wrapper
v1.0.2
Published
Fully-typed Lanyard API wrapper for Node.js
Downloads
2
Readme
node-lanyard-wrapper
Fully-typed Lanyard API wrapper for Node.js
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.