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

cachet-api

v1.0.11

Published

An API client for Cachet, the open source status page system.

Downloads

1,532

Readme

cachet-api

npm version

A Node.js API client for Cachet.

Cachet is a beautiful and powerful open source status page system, a free replacement to services such as StatusPage.io, Status.io and others.

Usage

First, install the package using npm:

npm install cachet-api --save

Then, start using the package by importing and configuring it:

var CachetAPI = require('cachet-api');

// Fill in the parameters accordingly
var cachet = new CachetAPI({
    // Base URL of your installed Cachet status page
    url: 'https://demo.cachethq.io',
    // Cachet API key (provided within the admin dashboard)
    apiKey: 'a1b2c3d4e5f6g7h8i9'
});

Make sure to fill in your Cachet status page url as well as your Cachet admin account's apiKey, which you can find in the Cachet dashboard.

Get Component Info

Use cachet.getComponentById(id) to fetch details about an existing component:

// Prepare a component ID to fetch
var componentId = 1;

// Get component info by ID
cachet.getComponentById(componentId)
    .then(function (component) {
        // Log component info
        console.log('Component', component);
    }).catch(function (err) {
        // Log errors to console
        console.log('Fatal Error', err);
    });

Publish a Metric Point

Use cachet.publishMetricPoint(point) to publish a new metric point to an existing metric:

// Prepare a metric point to publish (so it shows up on the metric's graph)
var metricPoint = {
    // Metric ID
    id: 1,
    // Metric point value
    value: 3.37,
    // Metric point timestamp (optional, defaults to now)
    timestamp: Math.round(new Date().getTime() / 1000)
};

// Publish it so it shows up on the status page
cachet.publishMetricPoint(metricPoint)
    .then(function (response) {
        // Log API response
        console.log('Metric point published at ' + response.data.created_at);
    }).catch(function (err) {
        // Log errors to console
        console.log('Fatal Error', err);
    });

Report an Incident

Use cachet.reportIncident(incident) to report a new status incident:

// Prepare an incident to report
var incident = {
    // Incident name
    name: 'Database connectivity issues',
    // Incident description (supports markdown)
    message: 'We\'re investigating connectivity issues with the main DB.',
    // Incident status (https://docs.cachethq.io/docs/incident-statuses)
    status: 'Investigating',
    // Whether the incident will be visible to the public or only to logged in users
    visible: true,
    // Whether to send out e-mail notifications to subscribers regarding this incident
    notify: true,
    // Component ID affected by this incident (optional)
    component_id: 1,
    // Component status (required if component_id is specified) (https://docs.cachethq.io/docs/component-statuses)
    component_status: 'Partial Outage'
};

// Report it so it shows up on the status page
cachet.reportIncident(incident)
    .then(function (response) {
        // Log API response
        console.log('New incident reported at ' + response.data.created_at);
    }).catch(function (err) {
        // Log errors to console
        console.log('Fatal Error', err);
    });

Delete an Incident

Use cachet.deleteIncidentById(id) to delete an existing status incident:

cachet.deleteIncidentById(incidentId)
	.then(function (response) {
		// Log API response
		console.log('Incident successfully deleted');
	}).catch(function (err) {
		// Log errors to console
		console.log('Fatal Error', err);
	});

Get Incidents by Component ID

Use cachet.getIncidentsByComponentId(componentId) to fetch all incidents associated with the provided component:

cachet.getIncidentsByComponentId(componentId)
	.then(function (incidents) {
		// Log API response
		console.log('Incidents successfully fetched', incidents);
	}).catch(function (err) {
		// Log errors to console
		console.log('Fatal Error', err);
	});

License

Apache 2.0