Build a Laptop Battery Status Logger with the Notion API and Python — Notion Public API Guide

Seb Hulse
9 min readJul 9, 2021
Example of the finished product — the laptop battery status Notion database © Seb Hulse

Hi! So you’ve heard the big news? That’s right — Notion has finally released its long awaited public API into the wild in beta! That means we can build, automate and integrate all kinds of cool stuff to further boost the functionality that notion offers — namely, leveraging the potential of Notion databases.

This post walks through one example of just how easy it can be to automate the logging of data into a notion database and hints at ideas for what we could do with that data later on. We first dive into the code, then discuss processing the output to be a bit more visually appealing within the database and finish with setup/implementation details. Feel free to skip ahead to the Setup if you just want to get up and running!

Contents

  • Code
  • Notion Database Visual Processing
  • Setup

Specifically, for this example, we’ll write a Python3 script to gather current battery status data (percentage, estimated time remaining, plugged-in status and timestamp), and push it to our Notion database using the requests python package. Then, we set up a cronjob to automate running this script every 2 minutes to start building a database that looks something like the above…

--

--

Seb Hulse

I write about what I’m learning — usually with a technical focus. Let’s enlighten one another! sebhulse.com