Tracking a Notion Journal w/ new API

The new Notion API has finally arrived, opening so many new possibilities. I’ve personally always wanted to be able to have a Notion calendar database of journal entries for each day and beemind the word count and now it’s possible!

To do this, I just made a script that will take the total number of words of all pages of a notion database and send that number to a Beeminder goal. It’s a fairly simple use of the two APIs but I’m just excited that it’s possible. I assume others have probably discovered better ways to do the same, but here’s my method for anyone interested:

I’ve made two versions of the code:

  1. An iOS version run with a Siri Shortcut and Scriptable.

    • Requires Scriptable app.
    • Scriptable script source code found here.
    • Shortcut found here (requires allowing untrusted shortcuts in “Settings>Shortcuts” on iOS).
    • Make sure the shortcut triggers the correct Scriptable script.
  2. A NodeJS version

They both require:

  • A Notion integration and database shared with that integration (instructions found here).
  • The ID of the Notion database you want to track (instructions found here as well).
  • Your Notion API Key (Internal Integration Token) (found in the integration information).
  • Beeminder auth_token, goal name (odometer type), username.

An automation could be made to run the code every so often and update the word count.

I’d appreciate any feedback and can answer questions from anyone who might want to try it out.

5 Likes

does this apply to pages within pages?

1 Like

Not at the moment. I’m figuring out a way to make that work. I actually realized that putting a page within a page broke the code…should’ve noticed that before. It’s fixed now thanks to your question.

2 Likes

The code has also now been updated to work with all forms of text to get a more accurate count.

1 Like