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

node-updown

v1.0.2

Published

Transparent Node.JS wrapper for the updown.io API

Downloads

8

Readme

node-updown

npm David PRs Welcome MIT license

Transparent Node.js wrapper for the updown.io API

Uses cross-fetch so should work in browsers and in node.

yarn add node-updown

Usage

There are two ways to use the library:

Client

import { UpdownClient } from 'node-updown';

// Create the client with your API key (readonly or full access)
const client = new UpdownClient('API_KEY');

// Use one of the methods to interact with the API
let check = await client.getCheck('TOKEN');

This is the recommended way to use if you need to make lots of API calls, or if you have a long-running application (e.g. a server).

Functional

import { getCheck } from 'node-updown';

// Use the API function directly, by adding your API key
let check = await getCheck('API_KEY', 'TOKEN');

This is useful if you only need to make one or two API calls, or if you want to limit the size of your bundle by tree-shaking the unused functions.

API

In this documentation, we'll use the client instance. To use the functional API, simply add your API key as the first argument. So client.getCheck(token) becomes getCheck(apiKey, token).

The API is kept as transparent as possible, so all values and options should mirror the Updown API documentation closely. Consult the API docs to see the returned data for each call.

Tokens are always required, most other settings are optional unless listed otherwise. All functions operating on an entity will take the entity ID/token as a first parameter (or second, if you're using the functional API) and an options object containing the remaining parameters.

The library is entirely promise-based.

Time strings should be in one of the supported formats.

Get checks

client.getChecks();

Get check

client.getCheck(token);

Get downtimes

client.getDowntimes(token, { page });
  • page (number): the page to fetch, default 1

Get metrics

client.getMetrics(token, { from, to, group });
  • from (time): start time, default 1 month ago
  • to (time): end time, default now
  • group (string): group data by hour ('time') or by monitoring location ('host')

Add check

client.addCheck(params);

See the API docs for the full list of parameters

Update check

client.updateCheck(token, params);

See the API docs for the full list of parameters

Delete check

client.deleteCheck(token);

Get monitoring nodes

client.getNodes();

Note: this function does not require an API key

Get IP addresses of monitoring nodes

client.getIpv4Nodes();
client.getIpv6Nodes();

Note: these functions do not require an API key

Get webhooks

client.getWebhooks();

Add webhook

client.addWebhook({ url });
  • url (string): the URL of the webhook

Delete webhook

client.deleteWebhook(id);
  • id (string): ID of the webhook you want to delete

Issues

If you experience any bugs or errors, or if you have any questions about how to use this library, be sure to create an issue.

LICENSE

This package is licensed under the MIT license.