Hey guys, I'm one of the friendly /r/joplinapp mods (hugelung). I've spent the last 3 days creating a brand new cli tool for Joplin in Go. It doesn't cover the whole API yet, but the foundation is pretty solid, and I figured I'd start talking about it + see what advice y'all have for me
The motivation is that while Joplin provides a really cool terminal application, this application is usually out of date with the Joplin Desktop/Mobile apps (i.e. using an older database format), and requires a full sync in order to use. This is a pretty bad experience when you just want to automate a few things using a terminal script — causing a bunch of waiting for sync to happen + using twice as much data on your computer
Meanwhile, Joplin provides a "data api" which is a REST server running on localhost. This is how the Joplin Webclipper communicates with the active Joplin Desktop session, and this API is super cool. You can do almost everything that is possible in plugins / full sync, and everything feels realtime. You make a note, and it's instantly in your Desktop app. As a bonus, this library can be used in Go programs instead of via the command line
Some of what the tool is currently capable of:
- Authenticate to Joplin desktop using a popup message that the desktop app makes. No hassling with API keys
- Configuration (and api keys) are automatically saved to
~/.joplin-butler/config.json
- Rough implementation of search for objects + handling the data pagination automatically
-
joplin-butler get
allows you to inspect all Joplin objects, like tags, resources, notes, folders -
joplin-butler create
allows you to make most of these objects, but mostly just notes with title/body -
joplin-butler delete
allows you to delete objects
A small example:
Create a note with title and markdown body:
> joplin-butler create note "My CLI Joplin Dream" -body "Begins today :D"
ID: 50fe5cf5dc6f4070a11c869cd4ec0138
Title: My CLI Joplin dream
ParentID: 1d4c4899bc7d4df4ad45cd575ac30043
CreatedTime: 1681088397617
UpdatedTime: 1681088397617
Source: joplin-desktop
---
Begins today :D
Delete a note:
> joplin-butler delete note/50fe5cf5dc6f4070a11c869cd4ec0138
Successfully deleted notes/50fe5cf5dc6f4070a11c869cd4ec0138
There's a fair bit remaining to do:
- Attaching/removing objects to other objects, like a tag to a note, or a resource to a note
- Allowing customization of which metadata is retrieved and displayed
- Editing object data selectively using the PUT api
CLI design mentality:
- Implemented similar to the verbs used by
kubectl
for controlling kubernetes resources - Fully generic concepts about manipulating database objects, preferring "create note " rather than "mknote" like Joplin terminal does it
- Structured data outputs so you can easily use unix tools to manipulate the data
- I can ultimately support the verbs that Joplin terminal does later, just for the convenience of being able to use the same ones, but I consider this low priority