Hello there,
I need to update deadlines of all my goals pretty frequently.
I did that by editing the timezone of my account, but that’s becoming inconvenient because the times are messed up on the iOS app (I receive notifications at the wrong time, so I had to disable them altogether).
But now, I decided to use the correct feature: deadlines!
Sadly, there is no way to edit them in bulk from the web app.
So, I created a script, that I am sharing here
#!/usr/bin/env node
// get it here: https://www.beeminder.com/api/v1/auth_token.json
const authentication = { "username": "sheik", "auth_token": "xxxxxxxxxxxxxxxxxxxx" }
/**
* deadline (number): Seconds by which your deadline differs from midnight.
* Negative is before midnight, positive is after midnight.
* Allowed range is -17*3600 to 6*3600 (7am to 6am).
*/
const newDeadline = 5 * 3600 // Example: set the deadline to 5am!
/**
* Goals to exclude from the processing
*/
const exclude = []
// Fetching goal list
const apiUrl = 'https://www.beeminder.com/api/v1'
const goalsResp = await fetch(apiUrl + '/users/' + authentication.username + '/goals.json' + '?auth_token=' + authentication.auth_token)
/**
* @type {{slug: string}[]}
*/
const goals = await goalsResp.json()
console.log("=== fetched goals list. ===")
console.log(goals.map(g => g.slug))
console.log("===========================")
console.log("")
for (const goal of goals) {
if (exclude.includes(goal.slug)) {
console.log("skipping " + goal.slug + " because excluded by user")
continue
}
console.log("editing deadline for " + goal.slug)
const resp = await fetch(apiUrl + '/users/' + authentication.username + '/goals/' + goal.slug + '.json' + '?auth_token=' + authentication.auth_token, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
deadline: newDeadline
})
})
console.log(resp.statusText)
console.log(await resp.text())
}
Usage tutorial
- Copy and paste this code in a file with a text editor. Save it as “beeminder_deadline_edit.mjs”
- Edit the value for the “authentication” variable and the “newDeadline” variable
- Install NodeJS version 21: Node.js — Download Node.js®
- Open a terminal instance (on Windows, Powershell, on Mac, open spotlight and type “terminal”
- Type "node " (the space is important) and then, drag and drop the file into the terminal, then tap “enter”
I’m a bit slow to answer, but I will eventually, so don’t hesitate to ask questions if you struggle using this script