GithubHelp home page GithubHelp logo

michaeldeboey / node-updown Goto Github PK

View Code? Open in Web Editor NEW

This project forked from woubuc/node-updown

0.0 1.0 0.0 421 KB

Simple Node.js API wrapper for updown.io

Home Page: https://www.npmjs.com/package/node-updown

License: MIT License

TypeScript 90.99% JavaScript 9.01%

node-updown's Introduction

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.

node-updown's People

Contributors

dependabot[bot] avatar michaeldeboey avatar woubuc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.