Joplin api to detect update events

Hello, I have question regarding the detection of updates from a plugin. Ideally, I would like to track notes, notebooks and tag updates.

At first, I have used the joplin.workspace.api

We can divide between sync updates and user updates. User updates will happen through the editor so I can use onNoteChange to tell me the about addition and update of the current note.
But there is no mechanism to tell me about deletion. Not only onNoteChange do not trigger delete events,
but a user could delete a note that is not selected.

So the only solution left is to use the joplin.data.api and poll /events at intervals.
However the difficulty here is that changes are recorded from a certain points in time.
Each time the plugin starts, I could request all the most recent data, but I don't find a way to tell
Joplin to track events from a certain point in time (that I would need to collect from another response anyhow).
I can only replay all events stored in the changes table, or even abuse the plugin settings system to persist a cursor value. Even then, data would be replayed from this point only, and we will also have to check that the cursor is still valid.
And of course, we have to poll the state rather than getting notifications which introduce some arbitrary decisions on the plugin data refresh rate.

I would think many plugins would have similar need. Is there a workaround I have overlooked? Is anybody actively using this API? I have noticed it is quite recent since I had to update joplin to use it.
I would appreciate if anyone can share some insight on this.

In case somebody research this topic, here are answers to my own questions :

  • No subscription mechanism. You will need to poll data at intervals.

  • Polling relevant events : here is the important part of the doc I had first overlooked :

If no cursor property is provided, the API will respond with the latest change ID. That can be used to retrieve future events later on.

This let you associate a cursor value with the current date.

  • Tags updates are not published at the time, so yes they will need to be retrieved and computed independently. Same is true with notebooks.
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.