Home / GitHub Page

Is there a way to write directly to the Joplin note store?


#1

I am a new Joplin user and simply thrilled by the application. Thank you for all the hard work and great design!

I have a question, though. I have around 4,000 plus notes in a custom text format (mostly Markdown) that I used with a self-coded set of scripts. I’d like to import these into Joplin but in a way that preserves their tags (which won’t happen with the direct Markdown import).

I could script that pretty easily if I was able to access the API, but I can’t, as I use a 32 bit Linux system and I am neither able to use the AppImage nor build the desktop app on my own as yet. Without the desktop app, I cannot turn on the service.

The other option is to use the command line options with the terminal app, but those turn out to be very slow on my system. Importing 4,000 notes would take around four hours just for these operations alone.

So is there a way I could write a script that wuold just directly to Joplin’s note store? If there is a documented file format, for instance? Then I could resolve this issue, and for future tasks the slow command line tools would suffice.


#2

One way to do this is to set up synchronisation with an ownCloud server. Then you’ll find all your notes in a folder on the server, and it is quite trivial to mechanically add new notes to this folder so they will be automatically picked up by other clients that synchronise with this server.

See https://github.com/sciurius/Joplin-Tools, in particular the addnote_cloud.pl script.

OTOH, four hours for a one-time import? Just go for it…


#3

Actually, I miscalculated - since each note would require three operations (mknote, set and tag), a one time import would take twelve hours, not four. Even that’s feasible I guess but if something goes wrong…

The OwnCloud idea makes sense but that wouldn’t preserve tags, would it?


#4

You have to transform the custom formatted notes into joplin format so I assume you can include the tags. They’re just special formatted .md files.


#5

Yes that would be great! But I guess that’s what I’d like to know - is there a spec for the Joplin formatted .md files? (I guess that would be the JEX format?)

Apologies if this is a really noob question - I just couldn’t find one.

If that exists then I can do what you suggest - format the notes as per the spec and add them to a folder that I then sync through an online service.


#6

The addnote_cloud script I pointed to earlier contains cases for all the known types of .md files (note, folder, resource, tag, etc.) This should be a good start.


#7

Thank you! I should have checked that out already. Will do.


#8

Have you experimented to play with the sqlite database it is using behind? you could access it by any db tool supporting sqlite.


#9

Thank you scirurius! I actually just used your script directly, and was able to generate a folder that is now loaded in Joplin via Joplin. Your script is brilliant, worked like a charm :).


#10

you can use the API and I made the port of it in python here.
avoid to write directly into the database, you could miss link between note/page/tags


#11

Some api-related sections, extracted from addnote.pl:

# Run Joplin and copy the token from the Web Clipper options page.
my $token = "YOUR TOKEN GOES HERE";

my $content = { parent_id  => $parent,
		        title      => $title,
		        defined($file) ? ( source_url => $file ) : (),
		        author     => $author,
	          };

my $res = $ua->get("$host:$_/ping");

my $res = $ua->get("$host:$port/folders?token=$token");

my $res = $ua->post( "$host:$port/notes?token=$token",
		     Content => $pp->encode($content) );


Not sure if it would be prone to dirty records due to data inconsistency or incorrect operations.