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

trimark-node

v1.1.0

Published

Node wrapper for the Trimark API

Downloads

2

Readme

Trimark Node

A small Node wrapper for the Trimark API.

Installation

NPM

$ npm install trimark-node

Yarn

$ yarn add trimark-node

Usage

You must have an API token supplied by Trimark in order to use the API.

import Trimark from 'trimark-node';

const client = Trimark("my-token");

client.getSites();                                             // Retrieve all the sites for the account
client.sites[0].getPoints();                                   // Retrieve all the sensor points for the site
client.sites[0].points[0].history({ timeFrame: 'Yesterday' }); // Retrieve all of the data points for the sensor and the given time frame

API

Trimark

(apiToken) -> { sites: Array<Site> | null, getSites: () -> void }

The main wrapper for the API, allows you to request all sites be fetched. After the sites are fetched client.sites will be populated with an array of all the sites.

Site

(
  getData: Function,           // A data getter that is passed down from the main wrapper
  site: TrimarkSiteInput       // The site as returned from the Trimark API
) -> {
  id: number,                  // The site ID
  name: string,                // The site name
  type: string,                // The type of site
  points: Array<Point> | null, // An array of points for the site, or null
  getPoints: () -> void        // Fetch all the points and populate the array
}

Point

(
  getData: Function,                                   // A data getter passed down from the Site object
  siteId: number,                                      // The site id that this point belongs to
  point: TrimarkPointInput                             // The point as returned from the Trimark API
) -> {
  siteId: number,                                      // The site id that this point belongs to
  id: number,                                          // The id for this sensor point
  uom: string,                                         // The unit of measure for the data points
  displayName:                                         // The display name for the sensor point
  history: (query: Query) -> Promise<Array<DataPoint>> // Fetch the sensor data for this point
}

DataPoint

(dataPoint: TrimarkDataPointInput) -> {
  intervalBegin: Object,  // The starting datetime for this data point, as a moment
  intervalEnd: Object,    // The ending datetime for this data point, as a moment
  averageValue: number,   // The average value for this data point
  minValue: number,       // The minimum value for this data point
  maxValue: number,       // The maximium value for this data point
  dataQuality: string,    // The data quality for this point
  interval: number,       // The interval of time this data point represents, in seconds
  pointId: number,        // The sensor point that this belongs to
  name: string,           // The name of the sensor point
  displayName: ?string,   // The display name for this sensor point
  uom: ?string,           // The unit of measure for this sensor point
  sumValue: ?number,      // The sum of the values for this sensor point
  rollupValue: ?number,   // The roll up value for this sensor point
  rollupUom: ?string,     // The unit of measure for the roll up value
  sampleTime: ?SampleTime // The intervals at which samples are taken
}

Query

{
  timeFrame: enum TimeFrame,
  sampleTime: ?enum SampleTime,
  startDateTime: ?string,
  endDateTime: ?string
}

The representation of the query object that can be sent when fetching historical data for a sensor point.

If a start and end date are given, those values will override anything passed in to the timeFrame option, effectively transforming it to Custom.

TimeFrame

An enum, one of:

'Today' | 'Yesterday' | 'Last3Days' | 'Last7Days' | 'MonthToDate' | 'LastMonth' | 'YearToDate' | 'LastYear' | 'Custom'

SampleTime

An enum, one of:

'Interval' | 'Hour' | 'Day' | 'Month' | 'Year'