Just wrote some App Script code to import my Beeminder goals into a spreadsheet. To use:
- Open a sheet in a Google Sheets spreadsheet you want to overwrite (it will overwrite!).
- Click “Tools > Script editor”
- Paste in the below code.
- On line 3 replace placeholders with your username and auth token.
- Click the run button in the toolbar.
- If asked, grant the requested permissions. The permissions requested allow the script to query Beeminder’s API and write to your spreadsheet.
That’s it!
function importGoals() {
Logger.log('hello world')
var response = UrlFetchApp.fetch('https://www.beeminder.com/api/v1/users/YOUR_USER_HERE/goals.json?auth_token=YOUR_TOKEN_HERE')
//Logger.log(response)
var goals = JSON.parse(response)
var headers = Object.keys(goals[0])
var data = [headers]
goals.forEach(function(g) {
//Logger.log(g.slug)
data.push(Object.values(g))
})
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange(1,1,data.length,headers.length)
//Logger.log(data)
range.setValues(data)
}