Transparent Node.js wrapper for the updown.io API
Uses cross-fetch
so should work in browsers and in node.
yarn add node-updown
There are two ways to use the library:
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).
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.
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.
client.getChecks();
client.getCheck(token);
client.getDowntimes(token, { page });
page
(number): the page to fetch, default 1
client.getMetrics(token, { from, to, group });
from
(time): start time, default 1 month agoto
(time): end time, default nowgroup
(string): group data by hour ('time'
) or by monitoring location ('host'
)
client.addCheck(params);
See the API docs for the full list of parameters
client.updateCheck(token, params);
See the API docs for the full list of parameters
client.deleteCheck(token);
client.getNodes();
Note: this function does not require an API key
client.getIpv4Nodes();
client.getIpv6Nodes();
Note: these functions do not require an API key
client.getWebhooks();
client.addWebhook({ url });
url
(string): the URL of the webhook
client.deleteWebhook(id);
id
(string): ID of the webhook you want to delete
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.
This package is licensed under the MIT license.