npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@streamlabswater/stream

v0.4.0

Published

StreamLabs Water Developer API client

Downloads

15

Readme

StreamLabs Node.js Library

This is the official node.js client for the StreamLabs Developer API.

API Documentation

See the StreamLabs Developer API docs

Install


npm i @streamlabswater/stream

Usage

The package needs to configured with your accounts API Key available when you login into your http://my.streamlabswater.com account.


const Stream = require('@streamlabswater/stream')
const stream = new Stream('YOUR_STREAMLABSWATER_API_KEY')

or using ES modules

import Stream from '@streamlabswater/stream'
const stream = new Stream('YOUR_STREAMLABSWATER_API_KEY')

All of the methods return Promises and use async/wait

Get all Locations

Start by fetching all your locations


const example = async () =>  {
  try {
    const locations = await stream.locations.get()
    console.log('LOCATIONS', locations)
  } catch (e) {
    console.error(e)
  }
}

Get a Location

A locationId is required to fetch details of a location, water usage and for updating homeAway.

// ...

const locationId = 'ae926a02...dbc8'
const location = await stream.location.get(locationId)

// ...

Update a Location

Currently you can only update the homeAway mode of the location When updating a location the response is always the updated location details

// ...

const locationId = 'ae926a02...dbc8'
const options = {
  homeAway: 'away'
}

const location = await stream.location.update(locationId, options)

// ...

Subscribe to Location Alerts

If you choose to recieve notifications when alerts become active or end for a location, you need to provide a valid url endpoint where the StreamLabs service will send the notifications. The following methods wrap the corresponding StreamLabs api endpoints as descriped in the Subscribe to Location Alerts section in the docs

Create Subscription

// ...

const locationId = 'ae926a02...dbc8'
const endpoint = 'https://example-endpoint.com'

const subscription = await stream.location.subscribe(locationId, endpoint)

// ...

Confirm subscription

Once you recieve the confirmationToken via your endpoint, update the subscription to start recieving alerts.

// ...
const subscriptionId = '3bb2255b...2a48'
const confirmationToken = 'r3vHQ2NXpkK...uuyt'

const subscription = await stream.subscription.update(subscriptionId, confirmationToken)

// ...

Get all Location Subscriptions

// ...

const locationId = 'ae926a02...dbc8'

const subscriptions = await stream.location.subscriptions.get(locationId)

// ...

Get a Subscription

// ...

const subscriptionId = '3bb2255b...2a48'

const subscription = await stream.subscription.get(subscriptionId)

// ...

Get all Subscriptions

// ...

const subscriptions = await stream.subscriptions.get()

// ...

Delete a Subscription

// ...

const subscriptionId = '3bb2255b...2a48'

const subscription = await stream.subscription.delete(subscriptionId)

// ...

This method will throw an Exception if the delete fails else returns an empty body

Get a Location’s Water Usage Summary

// ...

const locationId = 'ae926a02...dbc8'

const waterUsageSummary = await stream.location.waterUsage.summary.get(locationId)

// ...

Get a Location’s Water Usage

At the very minimum you need to provide a startTime for the readings you want to retrieve.

// ...

const locationId = 'ae926a02...dbc8'

/**
 * All time params should be Date Objects or ISO Formatted date strings
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
 */
const options = {
  startTime: new Date(),
  endTime: new Date(), // optional
  groupBy,
  page,
  perPage
}

const waterUsage = await stream.location.waterUsage.get(locationId, options)

// ...