I'm playing around with some autohotkey scripting to do a few things with Joplin and I was hoping to find away to output a listing of tags. what i was trying to do was just use curl to spit out a text file of all of the tags in my data. but evidently my skills on using curl need some work. can anyone give me a hand on using curl? another option would be a short python script to do the same, but curl is preferable.
thanks, i'm going thru the docs, 1 question is on the required token. does the whole token string need top be in the curl command or can i point to a text file that has the token?
conversely, any one interested in writing a short python script to do this? or point me to a good example?
Alternatively, if you are just after this for a one-off or occasional task and already have the right tools then you could just query the database directly.
Recommend taking a copy of the database first and running the queries on that for safety reasons rather than against the "live" db.
Simply running:
SELECT title
FROM tags
ORDER BY title ASC;
Will get you a list of tags or to bring back a list of tags actually bound to a note (to avoid "dead" tags with no associations).
SELECT DISTINCT tags.title
FROM tags
INNER JOIN note_tags ON tags.id = note_tags.tag_id
ORDER BY tags.title asc;
Or if you want to collate how many notes associate with each tag:
SELECT tags.title, COUNT(tags.title) AS count
FROM tags
INNER JOIN note_tags ON tags.id = note_tags.tag_id
GROUP BY tags.title
ORDER BY tags.title ASC;
thanks @Daeraxa, for what I am doing, I need the tags in a text file outside of joplin.
thanks @Marph, I didn't know of joppy so i'll take a look. you mentioned that the token could be stored in a text file. i'm assuming the 'os.getenv' statement will need to do a file read function?
If you want to read the token from a file and the results to a file, it could look like:
from joppy.api import Api
with open("joplin_api_token.txt") as infile:
token = infile.read()
api = Api(token=token)
all_tags = api.get_all_tags()
with open("all_tags.txt", "w") as outfile:
outfile.write("\n".join(tag["title"] for tag in all_tags))