Commandline mktodo with detailed fields

Hello,

so, when I type something like this:

joplin mktodo whatever

I get a todo like this:

[{"id":"0123456789abcdef0123456789abcdef","title":"whatever","is_todo":1,"todo_completed":0,"todo_due":0,"parent_id":"123456789abcdef0123456789abcdef0","encryption_applied":0,"order":1663262277884,"markup_language":1,"is_conflict":0,"is_shared":0,"updated_time":1663262277885,"user_updated_time":1663262277885,"user_created_time":1663262277885,"type_":1}]

Can I create a todo from commandline with a due date applied? Alternatively, can I modify this existing todo from commandline to have a due date?

I'm using joplin 2.3.2 (prod, linux) (commandline, ubuntu Ubuntu 22.04.1 LTS up-to-date, snap package)

(also, do you have an IRC channel?)

Thank you for your reply in advance.

I don't think mktodo has any additional arguments beyond the name of the note. If you want to automate things like that then I suspect you really want to be using the data API instead

Worth noting that this is not the up to date version of the app which is v2.6.2, the maintainer of that package doesn't seem to have kept it updated (it is not an official release, the only official terminal release is via npm).

There is no irc channel but there is a discord server, however the forums are considerably more active.

Hopefully the maintainer will update it. Also can you please point me towards the data api documentation? Thank you in advance.

Or maybe even can you please provide an mktodo --json command which expects a JSON todo as its parameter (similarly to the one seen above)? Thank you in advance.

The data API documentation is here. To create and modify a todo, you should take a look at the note properties is_todo and todo_due.

If you don't mind using python, I could provide an example script.

Hello, thank you, I'd like to see that example python script.

This script will create a todo with a due date one minute in the future.

Remarks:

  1. It is possible to script it in shell, too. For me python is just more convenient.
  2. If you want to choose a notebook where the todo should be created, you would have to use the search endpoint.
  3. Somehow todo_due is ignored when specifying it at note creation. This might be a bug in joppy or the API. Edit: Due date is ignored when creating a todo via data API · Issue #6862 · laurent22/joplin · GitHub
import os
import time

from joppy.api import Api

# Get the token from the environment or hardcode it here.
# https://joplinapp.org/api/references/rest_api/#authorisation
api = Api(token=os.getenv("API_TOKEN"))

# Add a notebook.
notebook_id = api.add_notebook(title="Example notebook")

# Add a todo in the previously created notebook.
note_id = api.add_note(
    title="Example todo",
    body="Example content",
    parent_id=notebook_id,
    is_todo=1,
)

# Modify the due date.
api.modify_note(
    id_=note_id,
    todo_due=int((time.time() + 60) * 1000),
)

Ok, how do you do the same in shell?

There are two ways I can think of:

Use curl, like it's done in the API documentation examples. You would need to figure out how to handle the returned json (maybe this is an option). The pattern and arguments should be analog to the python script:

  1. Create a notebook or find the notebook where you want to store the todos
  2. Create the todo
  3. Set the due date

The second way would be to make the python script executable. This would still require python.

Thanks, I'll investigate

1 Like

do both of these solutions need the web clipper service?

Yes, all requests to the data API need the webclipper to be activated and the corresponding API token.

1 Like

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