Help with Todoist API Parameters in Siri Shortcuts (Easy fix, but confused)

Hello, this should be quite easy, but can’t find any examples floating around. I am not a coder, but know Siri Shortcuts well enough. I plan on learning the API in much more detail, but can’t figure out how to add parameters to the request.

For example:
I am looking to query the Todoist API (rest or sync) to get tasks by a specific user-defined filter. I can get all the active tasks, but can’t figure out how to pass parameters as arguments to filter down those to a filter or any other criteria for that matter. Any help would be greatly appreciated.

Here is my base shortcut:

Alternatively:
I can get one of the predefined filters by just appending tasks?filter=Today to the API URL, but I can’t for one of my own filters?

I do have Scriptable or Pyto, if using JavaScript or Python would be more effective, but I prefer the native Shortcuts actions.
Thank you in advance.

Hello Mark,

I have had a look at the documentation for getting tasks using a filter and as far as I can see you can’t filter by user defined filters. I am not a Todoist premium user so can’t create any to test with but would assume that they are just a collection of built-in filters.

There are other limitations too, this is from their documentation:

When fetching a list of tasks, the API will do so in the following order: - filter (with or without lang ) - ids - label_id / project_id
So if you include a filter and ids, then only the filter will be used, if you include ids and project_id, only ids is used, and so on.

Unfortunately you will need to process the list of returned tasks using just one filter, the project ID is a good one, then loop through that list and filter out what you want to see.

Another example might be all the tasks that you are assigned to and then post process all of those that are due today, or that were due yesterday. Or a list of overdue tasks and then process those for the users that you need to send a reminder to.

Regards Alan

1 Like

Thank you for your response. So I must be misreading this section of the Rest API at least:

.

The part you are referencing above is right below that:

I suppose the big pain-point too is that I don’t know how to pass any of these parameters in shortcuts. Do you know how? My current shortcut above just uses get and just passes the authentication token, but I don’t know how to add any of the parameters to limit the request.

Thanks again.

Hello Mark,

You had already solved the issue of passing in the values, they are added to the end of the GET call, so you would add ?filter=Today to get a list of the tasks that are for today.

The any supported filter you have highlighted gives examples of the filters that you can apply. I have played around with this and it looks like you can combine filters

tasks?filter=overdue&filter=%23Work

Remember that you will need to url encode spaces as %20 and the # hash is encoded as %23. This should enable you to get back a filtered list using several filters.

As for passing these parameters in Shortcuts, they are just a string that you can add to the end of the url that you are calling.

Or do you mean how to pass a parameter when calling your shortcut from another?

Regards Alan

Hi Mark,

Do you have an example of what you are filtering for?

Regards Alan

Ok. That makes sense. I can work that out. my next question would be if i can filter for tags too. I will experiment. Thank you. Basically I am building a morning routine which pulls my tasks and formats them in a nice little list to where I don’t need to go into Todoist to see.

I’m not sure what tags are, I can see labels and priorities which are associated with tasks. You would need to get the list of tasks based on the filtering that you can apply eg for Today and then loop though those looking for the priority and label_ids.

You can get a list of labels with a call to https://api.todoist.com/rest/v1/labels, that will return an array containing the id and name, you can use this as part of a lookup from a task so you can display the name instead of the id. It looks like a task can contain multiple labels, you will need to give this some thought for the display, although a label can be marked as a favourite which you could make prominent.

Ooops. My mind was somewhere else when I wrote that. Yes I meant labels. Thanks again.