Hi all,
I’ve been tinkering a bit with my new Tidbyt. I’ve build a full featured, promise-based, zero-dependency module to help you integrate.
Installation
You can install the package with npm:
> npm install tidbyt
Usage
const Tidbyt = require('tidbyt')
async function main() {
const deviceId = process.argv[2]
const tidbyt = new Tidbyt(process.env.TIDBYT_API_TOKEN)
// get our requested device
const device = await tidbyt.devices.get(deviceId)
const { displayName, lastSeen } = device
console.log(displayName, `Last Seen: (${lastSeen})`)
// get a list of officially available apps
// return as map so we can lookup app name/descriptions by id
const apps = await tidbyt.apps.list({ asMap: true })
// get the list of installations for this device
const installations = await device.installations.list()
for (const { id, appID } of installations) {
const {
name = 'Custom',
description = `Unlike a regular Tidbyt app, this "installation" was pushed to ${displayName} via Tidbyt's API.`,
} = apps.get(appID) || {}
console.log(``)
console.log(` ${name} - ${id}`)
console.log(` ${description}`)
}
}
main()
I’ve already used this module to build an application that can render star files and push updates to custom installations on a cron schedule. I’m using this library in conjunction with the Twitter Followers app I published to refresh and display the count a few times a day.
Things are fairly new, but I’m open to any suggestions or feedback.
Thanks and have fun tinkering!