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

teksavvy-js

v1.0.0

Published

A wrapper for the Teksavvy ISP API.

Downloads

7

Readme

teksavvy-js

A JS wrapper for the Teksavvy API

Why?

Teksavvy is one of the few ISPs offering a public API that can be used to query usage data. However, no official documentation seems to exist online for it, making the use of the API a bit of a pain. This API wrapper seeks to solve the issue of having to chase scarce and user-contributed API documentation to build software on top of the Teksavvy API.

The main source of truth on the API at the moment is this short document found on DSLReport.

Getting started

To use this wrapper, you will need to generate an API key for your Teksavvy account. This can be done through the customer portal.

Wrapper setup

constructor(apiKey [, options = {}])

The apiKey needs to be supplied, omitting it will raise a MissingAPIKeyError and prevent any requests from being sent.

The options are described below:

|Option|Type|Default|Description| |---|---|---|---| |rateLimit|Integer|30|The number of requests per minute allowed by the wrapper. Set to 0 to disable rate limiting|

Usage

The API methods will return Promises that can be handled however you want using the then and catch functions.

API methods

usageRecords([operators = {}])

See the Query Operators section for details on how to use the operators parameter.

Output format

{
  date: ...,
  download: {
    onPeak: ...,
    offPeak: ...,
  },
  upload: {
    onPeak: ...,
    offPeak: ...,
  },
}

|Key|Type|Description| |---|---|---| |date|datetime|Date corresponding to the usage reading| |download|-|Download usage information| |onPeak|decimal|Bandwidth used in peak hours (in GB)| |offPeak|decimal|Bandwidth used off peak hours (in GB)| |upload|-|Upload usage information| |onPeak|decimal|See prev.| |offPeak|decimal|See prev.|

usageSummaries([operators = {}])

See the Query Operators section for details on how to use the operators parameter.

{
  start: ...,
  end: ...,
  isCurrent: ...,
  download: {
    onPeak: ...,
    offPeak: ...,
  },
  upload: {
    onPeak: ...,
    offPeak: ...,
  },
}

|Key|Type|Description| |---|---|---| |start|datetime|Start of the usage reading period| |end|datetime|End of the usage reading period| |isCurrent|boolean|Flags the current usage period| |download|-|Download usage information| |onPeak|decimal|Bandwidth used in peak hours (in GB)| |offPeak|decimal|Bandwidth used off peak hours (in GB)| |upload|-|Upload usage information| |onPeak|decimal|See prev.| |offPeak|decimal|See prev.|

Rate limiting

The API wrapper includes a rate limiting feature which can be set using the rateLimit option. The rate limit is based on the number of requests per minute allowed to go through.

Any request that would exceed the preset per-minute request limit will throw a RateLimitExceededError and will not be sent nor queued.

By default, the rate limit is set to 30, as it is the limit set by the Teksavvy API documentation.

Query operators

The wrapper supports OData query operators that are accepted by the Teksavvy API. You can use them by passing an object to the usageSummaries and usageRecords functions.

|Key|Corresponding OData operator|Description|Valid values| |---|---|---|---| |top|$top|Queries the first N values of the set|Integers > 0| |skip|$skip|Skips the first N values of the set, query starts at the N+1th|Integers > 0| |count|$inlinecount|Adds a count of the returned items to the response|Boolean| |select|$select|Not supported yet|-| |orderby|$orderby|Basic support*|-| |filter|$filter|(very) alpha support|Array of query objects| |-|$expand|Unsupported by Teksavvy|-| |-|$any|Unsupported by Teksavvy|-| |-|$all|Unsupported by Teksavvy|-|

$orderby support

Teksavvy doesn't seem to allow the use of $orderby with any useful keys, the wrapper allows the requests to be sent anyway while the situation is figured out.

Filter query objects

The current format of filter query parameters is an array of objects containing a key corresponding to one of the elements of the formatted result object, a reference value and a comparison operator compare.

[
  {
    key: ...,
    value: ...,
    compare: ...,
  },
  ...
]