Unique key for deleting duplicate notes in API

Hello,

I’m trying to remove hundreds of duplicate notes in Joplin system.

I already have a way to find duplicates:

  • I export notes as individual files

  • I process them and detect duplicates

Now I need to delete them in the API, and I need to know what to use as the unique key.

  • Is the unique key in the file name?

  • Or Is it in the file somewhere itself?

  • Where can I find a unique key that will allow me to choose the exact note to delete in the API?

Thanks.

Make sure to create a full backup before.

Joplin's data API has a search endpoint to get the note ID. I'm not certain if this ID is what you want, since unique key sounds like you are operating on the database directly. But maybe it's the same.

Alternatively, depending on how you determine duplicates, you could use joppy for example. The script could look like:

  1. Iterate over all notes (including the ID): for note in get_all_notes(fields="title,id,body")
  2. Apply your algorithm to detect duplicates
  3. Delete the duplicates by ID: delete_note(note.id)

Hi, thanks for the reply!

I went through the Joppy and the search endpoint docs, and it looks like each note has a unique id that can be used for retrieval and deletion.

I’m thinking of pulling all notes with their IDs, saving them using the id as the filename, then detecting duplicates and removing them via the API.

Does that sound like a reasonable approach? And is there a recommended way to export notes with their IDs using Joppy or the API?

Thanks again!

Yes, that sounds reasonable. You could even avoid writing to the filesystem if your algorithm works in Python. Title, body and ID of the notes are all available in-memory as part of the note object (note.title, note.id and note.body).

You can iterate over the notes with their content using for note in get_all_notes(fields="title,id,body"). There are some examples at the readme: GitHub - marph91/joppy: Python interface for the Joplin client and server API · GitHub.

If you need to write them to the filesystem, you can use Python's pathlib module for example.