Simple CLI for Joplin

I'm interested in writing a very simple CLI that would send notes or todos directly to my Joplin Server.

I know that I could install the Joplin terminal application and use that CLI, but it seem really "heavy weight" with all of the curses and NPM code just to send a few HTTP messages to the server.

Has anyone looked at this? I can't seem to find any documentation for the server API (perhaps its in the code)...

Do I need to tear into the joplin terminal code?



Welcome ! There are some existing tools that wrap around the Joplin API to provide CLI functionality. Have a look at Joplin-Tools or joppy. You may have to set up some python scripts / aliases but it covers all basic use cases you may have.

Cheers !

1 Like

Those tools won't help @gmulligan, because they communicate with an instance of Joplin client, not with Joplin Server.

yes - exactly. I spoke to Laurent and it seems that he is not planning to expose the server API, cause directly interacting with the server is not a standard workflow - in his mind... and I sort of get it.

I still think the idea could work.... (flow) generate note with emacs, vim, whatever, save to file, make calls to server (authenticate, add note, ...); then when joplin app or joplin terminal syncs the new note would be there.

I think I can do something similar by running the joplin terminal in a podman container and making the data API calls to have it interact with the Joplin server. I have parts of this working, but I'm having a problem understand the /search API. It doesn't seem to work as expected.

Good to know. Thanks for sharing gmulligan.

For what it is worth, I'm writing something similar and opting to go with a debian VM w/ X11. I'd prefer to go headless but I've not had much luck with finding an approach that way that works. With this approach I have access to the webclipper API.

The last thing I'm struggling with here is triggering a sync. I set the interval to 5 minutes, but it would be nice if I could trigger synchronization programatically to make it more automatic. Any ideas on how to do this? I don't see it documented in the data API. I see a SyncStartEvent in the plugin API, maybe that is callable? This feature didn't exist as of June 2020 and I'm not sure if that has changed since then.
I'd prefer not to use xclicker or something like that but that's where I'm leaning right now (either that or looking through the codebase to see if there's anything undocumented) Please let me know if anyone has some thoughts. Happy to share the usecase if anyone is interested also.

I did get this working!

I have a bash script that starts emacs (of course you can do anything to create your joplin item).
When emacs finishes the script checks to make sure the filelen is > 0 and then calls socat to push the file to a "joplincli" server that is listening on my joplin cloud server

My joplin cloud server is a cloud linux VM. I'm running joplin using podman (so much better than docker :slight_smile: )
I also run another podman image that has the joplin cli with some other tools such as socat, jq, cron and curl. This image has a bash script that listens on a port for a connection from the socat.
This is necessary since the actual API to the joplin server is not "exposed", but the api to the cli is.

The script first "syncs" with the server...
reads the item/data from the socket connection...
does some cli commands to find out if the item already exists (in which case it will append it) or not (in which case it creates a new entry) and if it is a note or todo item.
Then it calls curl to PUT the item on the joplin cli which in turn calls the actual (unexposed) joplin server api to add the item.

yes I know that I could just run the joplin cli with npm and everything else on my local computer, but I don't want to... so I'm running all the same stuff on the cloud joplin server -- it is then all sort of self-contained.

This has been working for me for a couple months.

If anyone is really interested I can create a git repo with all of the necessary files and commands.

oh yes please.

i spent a week until i found out that server api is not available and that is a dealbreaker for my workflow.

idk what are security reasons are in question here. it is a self hosted instance after all.