Instantly share code, notes, and snippets.

Embed
What would you like to do?
Todoist API Add Project from upcoming technovangelist video
import sys
from todoist.api import TodoistAPI
apikey = 'YOURAPIKEY'
projectbasename = 'PROJECTNAME'
templatepath = 'FULLPATHTOYOURCSVFILE'
query = sys.argv[1]
api = TodoistAPI(apikey)
projectname = "%s - %s" % (projectbasename, query)
newproject = api.projects.add(projectname)
api.commit()
projectId = newproject['id']
api.templates.import_into_project(projectId, templatepath)
api.sync()
projectitems = api.projects.get_data(projectId)['items']
for thisitem in projectitems:
thisid = thisitem['id']
content = thisitem['content']
newcontent = "%s - %s" % (content, query)
try:
item = api.items.get_by_id(thisitem['id'])
item.update(content=newcontent)
api.commit()
except Exception as err:
print(err)
api.sync()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment