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 🙏

© 2026 – Pkg Stats / Ryan Hefner

bothan-api

v0.0.2

Published

A node.js client library for Bothan - https://bothan.io

Readme

Build Status Code Climate Coverage Status NPM Version License

bothan.js

A node.js client for Bothan, a simple platform for storing and publishing metrics.

Installation

npm install bothan-api

Testing

npm test

Usage

First require the Bothan client:

bothan = require('bothan')

Then initialize a connection with your username, password and the url of your Bothan endpoint:

bothan = new Bothan({user: 'username', pass: 'password', endpoint: 'https://demo.bothan.io'})

You will then be able to interact with your Bothan API like so:

Get all metrics

Returns a list of available metrics as an array of objects

bothan.listMetrics(function(data) {
  console.log(data)
})

Find a metric

Latest value

Returns the latest value for a specified metric as an object

bothan.getMetric({'metric': 'simple-metric'}, function(data) {
  console.log(data)
})

For a specific DateTime

Returns the most recent value of a metric at the specified datetime.

bothan.getMetric({'metric': 'simple-metric', 'time': '2016-12-12T07:00:24.465+00:00'}, function(data) {
  console.log(data)
})

For a specific DateTime range

Returns all values of the metric between the specified times.

bothan.getMetric({'metric': 'simple-metric', 'from': '2016-12-01T07:00:22.851+00:00', 'to': '2016-12-05T07:00:22.459+00:00'}, function(data) {
  console.log(data)
})

Create a metric

The Bothan API supports four types of metric, all supported by the gem.

Create a simple metric

// Create a metric called 'my-new-metric' with a value of '12' at the current datetime
bothan.createMetric({name: 'my-new-metric', value: 123}, function(data) {
  console.log(data)
})
// Create a metric with a specific datetime
bothan.createMetric({name: 'my-new-metric', value: 123, time: '2016-12-23T00:00:00.000+00:00'}, function(data) {
  console.log(data)
})

Create a metric with a target

// Create a metric called 'my-new-metric' with a value of '1091000', an annual target of '2862000' and a ytd target of '1368000' at the current datetime
bothan.createTargetMetric({name: 'my-new-target-metric', actual: 1091000, annual_target: 2862000, ytd_target: 1368000}, function() {
  console.log(data)
})
// Create a metric with a target at a specific datetime
bothan.createTargetMetric({name: 'my-new-target-metric', actual: 1091000, annual_target: 2862000, ytd_target: 1368000, time: '2016-12-23T00:00:00.000+00:00'}, function() {
  console.log(data)
})
// Create a metric without a ytd target
bothan.createTargetMetric({name: 'my-new-target-metric', actual: 1091000, annual_target: 2862000}, function() {
  console.log(data)
})
// Create a metric without a ytd target at a specific datetime
bothan.createTargetMetric({name: 'my-new-target-metric', actual: 1091000, annual_target: 2862000, time: '2016-12-23T00:00:00.000+00:00'}, function() {
  console.log(data)
})

Create a metric with multiple values

// Create a metric called 'my-new-metric' with multiple values with the current datetime
bothan.createMultipleMetric({name: 'my-new-metric', values: {
  'value1': 123,
  'value2': 23213,
  'value4': 1235
}}, function(data) {
  console.log(data)
})

// Create a metric called 'my-new-metric' with multiple values with a specific datetime
bothan.createMultipleMetric({name: 'my-new-metric', values: {
  'value1': 123,
  'value2': 23213,
  'value4': 1235
}, time: '2016-12-23T00:00:00.000+00:00'}, function(data) {
  console.log(data)
})

Create a metric with geodata

// Create a geodata metric called 'my-new-metric' with the current datetime
bothan.createGeoMetric({name: 'my-new-metric', values: {
  'type' => 'Feature',
  'geometry' => {
    'type' => 'Point',
    'coordinates' => [-2.6156582783015017, 54.3497405310758]
  }
},
{
  'type' => 'Feature',
  'geometry' => {
    'type' => 'Point',
     'coordinates' => [-6.731370299641439, 55.856756177781186]
  }
}
}, function(data) {
  console.log(data)
})

// Create a geodata metric called 'my-new-metric' with a specific datetime
bothan.createGeoMetric({name: 'my-new-geometric', values: {
  'type' => 'Feature',
  'geometry' => {
    'type' => 'Point',
    'coordinates' => [-2.6156582783015017, 54.3497405310758]
  }
},
{
  'type' => 'Feature',
  'geometry' => {
    'type' => 'Point',
     'coordinates' => [-6.731370299641439, 55.856756177781186]
  }
}, time: '2016-12-23T00:00:00.000+00:00'}, function(data) {
  console.log(data)
})

Development

After checking out the repo, run npm install to install dependencies. Then, run npm test to run the tests.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/theodi/bothan.js. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.