cachet-api

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');
var cachet = new CachetAPI({
url: 'https://demo.cachethq.io',
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:
var componentId = 1;
cachet.getComponentById(componentId)
.then(function (component) {
console.log('Component', component);
}).catch(function (err) {
console.log('Fatal Error', err);
});
Publish a Metric Point
Use cachet.publishMetricPoint(point)
to publish a new metric point to an existing metric:
var metricPoint = {
id: 1,
value: 3.37,
timestamp: Math.round(new Date().getTime() / 1000)
};
cachet.publishMetricPoint(metricPoint)
.then(function (response) {
console.log('Metric point published at ' + response.data.created_at);
}).catch(function (err) {
console.log('Fatal Error', err);
});
Report an Incident
Use cachet.reportIncident(incident)
to report a new status incident:
var incident = {
name: 'Database connectivity issues',
message: 'We\'re investigating connectivity issues with the main DB.',
status: 'Investigating',
visible: true,
notify: true,
component_id: 1,
component_status: 'Partial Outage'
};
cachet.reportIncident(incident)
.then(function (response) {
console.log('New incident reported at ' + response.data.created_at);
}).catch(function (err) {
console.log('Fatal Error', err);
});
Delete an Incident
Use cachet.deleteIncidentById(id)
to delete an existing status incident:
cachet.deleteIncidentById(incidentId)
.then(function (response) {
console.log('Incident successfully deleted');
}).catch(function (err) {
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) {
console.log('Incidents successfully fetched', incidents);
}).catch(function (err) {
console.log('Fatal Error', err);
});
License
Apache 2.0