Skip to content

Latest commit

 

History

History
85 lines (60 loc) · 2.84 KB

README.md

File metadata and controls

85 lines (60 loc) · 2.84 KB

beeminderjs

NodeJS wrapper for the Beeminder API. Created for integration with Complice, a productivity app that's more qualified-self than quantified-self.

BeeminderJS is designed for use within NodeJS apps, although it also works in a very basic rudimentary way from command-line. I'm open to people contributing new functions to either purpose!

Install to your node project

npm install --save beeminder

Usage as a library

As of 2.0.0, promises only. Errors may also be slightly different, due to using fetch instead of curlrequest.

Refer to the Beeminder API docs for information on goal creation parameters or what will be returned when calling these endpoints.

var beeminder = require('beeminder')
var bm = beeminder(auth_token)

bm.getUser(function (err, result) {
  console.log(err || result)
  // do something
})

bm.getGoal('goalslug', function (err, result) {...})

bm.createGoal('goalslug', params, function (err, result) {...})

bm.getDatapoints('goalslug', function (err, result) {...})

bm.createDatapoint('goalslug', {
  value: 1, // {type: Number, required: true},
  timestamp: new Date("2015-02-21").valueOf() // {type: Number, default: now},
  comment: 'updated readme',
  sendmail: true, // if you want the user to be emailed
  // requestid allows you to run command again without creating duplicate datapoints
  requestid: 'thisHasToBeAlphanumericWhichIsWhyThereAreNoSpaces',
}, function (err, result) {...})

bm.createGoal('goalslug', params).then(function () {
  return bm.createDatapoints('goalslug', [{...}])
}).then(function () {
  res.send('Created goal and added datapoints')  
}).catch(...)

Install as a command-line tool

sudo npm install --global beeminder

bm # run this once to ensure you're authenticated

Usage as a command-line tool

bm user
bm status # outputs a list of goals sorted by derail time
bm goal <goalslug>
bm datapoints <goalslug>
bm createdatapoint <goalslug> <value> [<optional comment, in quotes if it has a space>]
bm cd # same as createdatapoint

Example

I have the following in .bash_aliases, which allows me to post a user-visible improvement simultaneously to beeminder (m/complice-uvi) and twitter (@compluvi). Requires the twitter bash client t, available here (although barely still supported since it uses an old version of Ruby and an unavailable-for-new-apps Twitter API).

uvi () {
  bm cd complice-uvi 1 "$@"
  t update "$@"
}

# example
uvi "UVIs will be posted more frequently because I can now post them from command line :D"

todo

  • implement other endpoints (feel free to ask for them or to submit pull requests)