CachetAPI

CachetAPI




new CachetAPI(options) → {CachetAPI}

Create a new CachetAPI

Parameters:
Name Type Description
options Object

Options about the CachetAPI Instance

Properties
Name Type Attributes Description
url String

The URL of the CachetAPI Instance

apiToken String <optional>

The API Token for the CachetAPI Instance

Source:
Example
import CachetAPI from 'cachetapi'

let cachet_api = new CachetAPI({
	url: "https://demo.cachethq.io/api",
	apiToken: "9yMHsdioQosnyVK4iCVR"
})
Returns:
Type:
CachetAPI

Methods




(async) addComponent(component) → {Promise.<Component>}

Add a new Component

Parameters:
Name Type Description
component Component

The Component you wish to add

Source:
Examples

Async/Await

let component = await cachet_api.addComponent({
	name: "My Component",
	description: "My Description",
	status: 0
})
// component = Component

Promise

cachet_api.addComponent({
	name: "My Component",
	description: "My Description",
	status: 0
}).then((component) => {
	// component = Component
}).catch((error) => { })
Returns:

Returns a component

Type:
Promise.<Component>



(async) addComponentGroup(group) → {Promise.<ComponentGroup>}

Add a new Component Group

Parameters:
Name Type Description
group ComponentGroup

The Component Group you wish to add

Source:
Examples

Async/Await

let component_group = await cachet_api.addComponentGroup({
	name: "My Component Group"
})
// component_group = ComponentGroup

Promise

cachet_api.addComponentGroup({
	name: "My Component Group"
}).then((component_group) => {
	// component_group = ComponentGroup
}).catch((error) => { })
Returns:

Returns a Component Group

Type:
Promise.<ComponentGroup>



(async) addIncident(incident) → {Promise.<Incident>}

Add a new Incident

Parameters:
Name Type Description
incident Incident

The Incident you wish to add

Source:
Examples

Async/Await

let incident = await cachet_api.addIncident({
	name: "My Incident",
	message: "My Incident message",
	status: 0,
	visible: 1
})
// incident = Incident

Promise

cachet_api.addIncident({
	name: "My Incident",
	message: "My Incident message",
	status: 0,
	visible: 1
}).then((incident) => {
	// incident = Incident
}).catch((error) => { })
Returns:

Returns an Incident

Type:
Promise.<Incident>



(async) addIncidentUpdate(incident_id, update) → {Promise.<IncidentUpdate>}

Add a new Incident Update

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident you wish to add an Incident Updates to

update IncidentUpdate

The Incident Update you wish to add

Source:
Examples

Async/Await

let incident_update = await cachet_api.addIncidentUpdate(0, {
	message: "My Update",
	status: 2
})
// incident_update = IncidentUpdate

Promise

cachet_api.addIncidentUpdate(0, {
	message: "My Update",
	status: 2
}).then((incident_update) => {
	// incident_update = IncidentUpdate
}).catch((error) => { })
Returns:

Returns an IncidentUpdate

Type:
Promise.<IncidentUpdate>



(async) addMetric(metric) → {Promise.<Metric>}

Add a new Metric

Parameters:
Name Type Description
metric Metric

The Metric you wish to add

Source:
Examples

Async/Await

let metric = await cachet_api.addMetric({
	name: "My Metric",
	suffix: "F",
	description: "My Metric Description",
	default_value: 1
})
// metric = Metric

Promise

cachet_api.addMetric({
	name: "My Metric",
	suffix: "F",
	description: "My Metric Description",
	default_value: 1
}).then((metric) => {
	// metric = Metric
}).catch((error) => { })
Returns:

Returns a Metric

Type:
Promise.<Metric>



(async) addMetricPoint(metric_id, point) → {Promise.<MetricPoint>}

Add a new Component

Parameters:
Name Type Description
metric_id Integer

The ID of the Metric you wish to add a Metric Point to

point MetricPoint

The Metric Point you wish to add

Source:
Examples

Async/Await

let metric_point = await cachet_api.addMetricPoint({
	value: 0.75
})
// metric_point = MetricPoint

Promise

cachet_api.addMetricPoint({
	value: 0.75
}).then((metric_point) => {
	// metric_point = MetricPoint
}).catch((error) => { })
Returns:

Returns a MetricPoint

Type:
Promise.<MetricPoint>



(async) addSubscriber(subscriber) → {Promise.<Subscriber>}

Add a new Subscriber

Parameters:
Name Type Description
subscriber Subscriber

The Subscriber you wish to add

Source:
Examples

Async/Await

let subscriber = await cachet_api.addSubscriber({
	email: "email@example.com"
})
// subscriber = Subscriber

Promise

cachet_api.addSubscriber({
	email: "email@example.com"
}).then((subscriber) => {
	// subscriber = Subscriber
}).catch((error) => { })
Returns:

Returns a Subscriber

Type:
Promise.<Subscriber>



(async) deleteComponent(component_id) → {Promise.<Boolean>}

Delete a Component

Parameters:
Name Type Description
component_id Integer

The ID of the Component you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteComponent(0)
// success = true

Promise

cachet_api.deleteComponent(0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if component deletion was successful

Type:
Promise.<Boolean>



(async) deleteComponentGroup(group_id) → {Promise.<Boolean>}

Delete a ComponentGroup

Parameters:
Name Type Description
group_id Integer

The ID of the Component Group you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteComponentGroup(0)
// success = true

Promise

cachet_api.deleteComponentGroup(0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if Component Group deletion was successful

Type:
Promise.<Boolean>



(async) deleteIncident(incident_id) → {Promise.<Boolean>}

Delete an Incident

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteIncident(0)
// success = true

Promise

cachet_api.deleteIncident(0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if the Incident deletion was successful

Type:
Promise.<Boolean>



(async) deleteIncidentUpdate(incident_id, update_id) → {Promise.<Boolean>}

Delete an Incident Update

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident that you wish to delete an Incident Updates from

update_id Integer

The ID of the Incident Update you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteIncidentUpdate(0, 0)
// success = true

Promise

cachet_api.deleteIncidentUpdate(0, 0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if Incident Update deletion was successful

Type:
Promise.<Boolean>



(async) deleteMetric(metric_id) → {Promise.<Boolean>}

Delete a Metric

Parameters:
Name Type Description
metric_id Integer

The ID of the Metric you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteMetric(0)
// success = true

Promise

cachet_api.deleteMetric(0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if Metric deletion was successful

Type:
Promise.<Boolean>



(async) deleteMetricPoint(metric_id, point_id) → {Promise.<Boolean>}

Delete a Metric Point

Parameters:
Name Type Description
metric_id Integer

The ID of the Metric you wish to delete a Metric Point from

point_id Integer

The ID of the Metric Point you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteMetricPoint(0, 0)
// success = true

Promise

cachet_api.deleteMetricPoint(0, 0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if Metric Point deletion was successful

Type:
Promise.<Boolean>



(async) deleteSubscriber(subscriber_id) → {Promise.<Boolean>}

Delete a Subscriber

Parameters:
Name Type Description
subscriber_id Integer

The ID of the Subscriber you wish to delete

Source:
Examples

Async/Await

let success = await cachet_api.deleteSubscriber(0)
// success = true

Promise

cachet_api.deleteSubscriber(0).then((success) => {
	// success = true
}).catch((error) => { })
Returns:

Returns true if Subscriber deletion was successful

Type:
Promise.<Boolean>



(async) getComponent(component_id) → {Promise.<Component>}

Get a Component

Parameters:
Name Type Description
component_id Integer

The ID of the Component you wish to get

Source:
Examples

Async/Await

let component = await cachet_api.getComponent(0)
// component = Component

Promise

cachet_api.getComponent(0).then((component) => {
	// component = Component
}).catch((error) => { })
Returns:

Returns a component

Type:
Promise.<Component>



(async) getComponentGroup(group_id) → {Promise.<ComponentGroup>}

Get a Component Group

Parameters:
Name Type Description
group_id Integer

The ID of the Component Group you wish to get

Source:
Examples

Async/Await

let component_group = await cachet_api.getComponentGroup(0)
// component_group = ComponentGroup

Promise

cachet_api.getComponentGroup(0).then((component_group) => {
	// component_group = ComponentGroup
}).catch((error) => { })
Returns:

Returns a Component Group

Type:
Promise.<ComponentGroup>



(async) getComponentGroups(with_metaopt) → {Promise.<Array.<ComponentGroup>>}

Get all the Component Groups

Parameters:
Name Type Attributes Default Description
with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let component_groups = await cachet_api.getComponentGroups()
// component_groups = [ComponentGroup, ComponentGroup, ComponentGroup]

Promise

cachet_api.getComponentGroups().then((component_groups) => {
	// component_groups = [ComponentGroup, ComponentGroup, ComponentGroup]
}).catch((error) => { })
Returns:

Returns an Array of Component Groups

Type:
Promise.<Array.<ComponentGroup>>



(async) getComponents(with_metaopt) → {Promise.<Array.<Component>>}

Get all the Components

Parameters:
Name Type Attributes Default Description
with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let components = await cachet_api.getComponents()
// components = [Component, Component, Component]

Promise

cachet_api.getComponents().then((components) => {
	// components = [Component, Component, Component]
}).catch((error) => { })
Returns:

Returns an Array of Components

Type:
Promise.<Array.<Component>>



(async) getIncident(incident_id) → {Promise.<Incident>}

Get an Incident

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident you wish to get

Source:
Examples

Async/Await

let incident = await cachet_api.getIncident(0)
// incident = Incident

Promise

cachet_api.getIncident(0).then((incident) => {
	// incident = Incident
}).catch((error) => { })
Returns:

Returns an Incident

Type:
Promise.<Incident>



(async) getIncidents(with_metaopt) → {Promise.<Array.<Incident>>}

Get all the Incidents

Parameters:
Name Type Attributes Default Description
with_meta Boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let incident = await cachet_api.getIncidents()
// incident = [Incident, Incident, Incident]

Promise

cachet_api.getIncidents().then((incident) => {
	// incident = [Incident, Incident, Incident]
}).catch((error) => { })
Returns:

Returns an Array of Incidents

Type:
Promise.<Array.<Incident>>



(async) getIncidentUpdate(incident_id, update_id) → {Promise.<IncidentUpdate>}

Get an Incident Update

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident you wish to get the specific Incident Update from

update_id Integer

The ID of the Incident Update you wish to get

Source:
Examples

Async/Await

let incident_update = await cachet_api.getIncidentUpdate(0, 0)
// incident_update = IncidentUpdate

Promise

cachet_api.getIncidentUpdate(0, 0).then((incident_update) => {
	// incident_update = IncidentUpdate
}).catch((error) => { })
Returns:

Returns an Incident Update

Type:
Promise.<IncidentUpdate>



(async) getIncidentUpdates(incident_id, with_metaopt) → {Promise.<Array.<IncidentUpdate>>}

Get all the IncidentUpdates for a specific Incident

Parameters:
Name Type Attributes Default Description
incident_id Integer

The ID of the Incident you wish to get Incident Updates for

with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let incident_updates = await cachet_api.getIncidentUpdates()
// incident_updates = [IncidentUpdate, IncidentUpdate, IncidentUpdate]

Promise

cachet_api.getIncidentUpdates().then((incident_updates) => {
	// incident_updates = [IncidentUpdate, IncidentUpdate, IncidentUpdate]
}).catch((error) => { })
Returns:

Returns an Array of IncidentUpdates

Type:
Promise.<Array.<IncidentUpdate>>



(async) getMetric(metric_id) → {Promise.<Metric>}

Get a Metric

Parameters:
Name Type Description
metric_id Integer

The ID of the Metric you wish to get

Source:
Examples

Async/Await

let metric = await cachet_api.getMetric(0)
// metric = Metric

Promise

cachet_api.getMetric(0).then((metric) => {
	// metric = Metric
}).catch((error) => { })
Returns:

Returns a Metric

Type:
Promise.<Metric>



(async) getMetricPoints(metric_id, with_metaopt) → {Promise.<Array.<MetricPoint>>}

Get all the Metric Points

Parameters:
Name Type Attributes Default Description
metric_id Integer

The ID of the Metric you wish to get Metric Points from

with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let metric_point = await cachet_api.getMetricPoints(0)
// metric_point = [MetricPoint, MetricPoint, MetricPoint]

Promise

cachet_api.getMetricPoints(0).then((metric_point) => {
	// metric_point = [MetricPoint, MetricPoint, MetricPoint]
}).catch((error) => { })
Returns:

Returns an Array of Components

Type:
Promise.<Array.<MetricPoint>>



(async) getMetrics(with_metaopt) → {Promise.<Array.<Metric>>}

Get all the Metrics

Parameters:
Name Type Attributes Default Description
with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let metrics = await cachet_api.getMetrics()
// metrics = [Metric, Metric, Metric]

Promise

cachet_api.getMetrics().then((metrics) => {
	// metrics = [Metric, Metric, Metric]
}).catch((error) => { })
Returns:

Returns an Array of Metrics

Type:
Promise.<Array.<Metric>>



(async) getSubscribers(with_metaopt) → {Promise.<Array.<Subscriber>>}

Get all the Subscribers

Parameters:
Name Type Attributes Default Description
with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let subscribers = await cachet_api.getSubscribers()
// subscribers = [Subscriber, Subscriber, Subscriber]

Promise

cachet_api.getSubscribers().then((subscribers) => {
	// subscribers = [Subscriber, Subscriber, Subscriber]
}).catch((error) => { })
Returns:

Returns an Array of Subscribers

Type:
Promise.<Array.<Subscriber>>



(async) getVersion(with_metaopt) → {String|Object}

Get the version of the CachetAPI server

Parameters:
Name Type Attributes Default Description
with_meta boolean <optional>
false

Set this to true if you would like the original response with meta info (paginated info)

Source:
Examples

Async/Await

let version = await cachet_api.getVersion()
// version = "2.4.0-dev"

Promise

cachet_api.getVersion().then((version) => {
	// version = "2.4.0-dev"
}).catch((error) => { })
Returns:

Returns the current version as a string OR an Object if with_meta is true

Type:
String | Object



(async) ping() → {Promise.<String>}

Ping the CachetAPI server and get back a response

Source:
Examples

Async/Await

let response = await cachet_api.ping()
// response = "Pong!"

Promise

cachet_api.ping().then((response) => {
	// response = "Pong!"
}).catch((error) => { })
Returns:

Responds with "Pong!" when online

Type:
Promise.<String>



(async) updateComponent(component_id, component) → {Promise.<Component>}

Update a Component

Parameters:
Name Type Description
component_id Integer

The ID of the Component you wish to update

component Component

The updated Component info

Source:
Examples

Async/Await

let component = await cachet_api.updateComponent(0, {
	name: "My Updated Component",
	status: 1
})
// component = Component

Promise

cachet_api.updateComponent(0, {
	name: "My Updated Component",
	status: 1
}).then((component) => {
	// component = Component
}).catch((error) => { })
Returns:

Returns a component

Type:
Promise.<Component>



(async) updateComponentGroup(group_id, group) → {Promise.<ComponentGroup>}

Update a Component Group

Parameters:
Name Type Description
group_id Integer

The ID of the Component Group you wish to update

group ComponentGroup

The updated Component Group info

Source:
Examples

Async/Await

let component_group = await cachet_api.updateComponentGroup(0, {
	name: "My Updated Component Group"
})
// component_group = ComponentGroup

Promise

cachet_api.updateComponentGroup(0, {
	name: "My Updated Component Group"
}).then((component_group) => {
	// component_group = ComponentGroup
}).catch((error) => { })
Returns:

Returns a component

Type:
Promise.<ComponentGroup>



(async) updateIncident(incident_id, incident) → {Promise.<Incident>}

Update an Incident

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident you wish to update

incident Incident

The updated Incident info

Source:
Examples

Async/Await

let incident = await cachet_api.updateIncident(0, {
	name: "My Updated Incident",
	status: 1
})
// incident = Incident

Promise

cachet_api.updateIncident(0, {
	name: "My Updated Incident",
	status: 1
}).then((incident) => {
	// incident = Incident
}).catch((error) => { })
Returns:

Returns an Incident

Type:
Promise.<Incident>



(async) updateIncidentUpdate(incident_id, update_id, update) → {Promise.<IncidentUpdate>}

Update an Incident Update

Parameters:
Name Type Description
incident_id Integer

The ID of the Incident that you wish to update an Incident Updates on

update_id Integer

The ID of the Incident Update you wish to update

update IncidentUpdate

The updated IncidentUpdate

Source:
Examples

Async/Await

let incident_update = await cachet_api.updateIncidentUpdate(0, 0, {
	message: "My Updated Message",
	status: 4
})
// incident_update = IncidentUpdate

Promise

cachet_api.updateIncidentUpdate(0, 0, {
	message: "My Updated Message",
	status: 4
}).then((incident_update) => {
	// incident_update = IncidentUpdate
}).catch((error) => { })
Returns:

Returns a component

Type:
Promise.<IncidentUpdate>