- Notifications
You must be signed in to change notification settings - Fork12
romgrk/node-todoist
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This module implements v9 of Todoist Sync API describedhere
npm install todoistor
yarn add todoistconstTodoist=require('todoist').v9consttodoist=Todoist(process.env.TODOIST_API_KEY);(async()=>{// READING DATA:// sync(): retrieves the latest data, incrementally.// the first call retrieves all data, but you can ask// for the specific data you want by passing// eg ['projects', 'items']awaittodoist.sync()// todoist.xxxxxx.get() functions are not async functions,// they return the data that was already fetched by .sync()constitems=todoist.items.get()// WRITING DATA:// the rest of the functions require arguments, refer to the offical// doc for detailsconstnewItem=awaittodoist.items.add({content:'new task!'})// all functions (except .get()) perform a sync before resolving,// therefore if you call .get() again you get the most up-to-date data})()
API token available here:https://todoist.com/prefs/integrations
The API is derived directly from the official documentation. It is transcribed below becausethe code is so simple to read it's better this way:
functionsync(resourceTypes=['all']){/* ... */}constprojects={get:()=>state.projects,add:createCommand<Types.ProjectAdd>('project','add'),update:createCommand<Types.ProjectUpdate>('project','update'),move:createCommand<Types.ProjectMove>('project','move'),delete:createCommand<Types.ProjectDelete>('project','delete'),archive:createCommand<Types.ProjectArchive>('project','archive'),unarchive:createCommand<Types.ProjectUnarchive>('project','unarchive'),reorder:createCommand<Types.ProjectReorder>('project','reorder'),}constitems={get:()=>state.items,add:createCommand<Types.ItemAdd>('item','add'),update:createCommand<Types.ItemUpdate>('item','update'),move:createCommand<Types.ItemMove>('item','move'),reorder:createCommand<Types.ItemReorder>('item','reorder'),delete:createCommand<Types.ItemDelete>('item','delete'),close:createCommand<Types.ItemClose>('item','close'),complete:createCommand<Types.ItemComplete>('item','complete'),uncomplete:createCommand<Types.ItemUncomplete>('item','uncomplete'),archive:createCommand<Types.ItemArchive>('item','archive'),unarchive:createCommand<Types.ItemUnarchive>('item','unarchive'),updateDayOrders:createCommand<Types.ItemUpdateDayOrders>('item','update_day_orders'),updateDateCompleted:createCommand<Types.ItemUpdateDateComplete>('item','update_date_complete'),}constlabels={get:()=>state.labels,add:createCommand<Types.LabelAdd>('label','add'),update:createCommand<Types.LabelUpdate>('label','update'),delete:createCommand<Types.LabelDelete>('label','delete'),updateOrders:createCommand<Types.LabelUpdateOrders>('label','update_orders'),}constnotes={get:()=>state.notes,add:createCommand<Types.NoteAdd>('note','add'),update:createCommand<Types.NoteUpdate>('note','update'),delete:createCommand<Types.NoteDelete>('note','delete'),}constprojectNotes={get:()=>state.project_notes,add:createCommand<Types.ProjectNoteAdd>('project_note','add'),update:createCommand<Types.ProjectNoteUpdate>('project_note','update'),delete:createCommand<Types.ProjectNoteDelete>('project_note','delete'),}constsections={get:()=>state.sections,add:createCommand<Types.SectionAdd>('section','add'),update:createCommand<Types.SectionUpdate>('section','update'),move:createCommand<Types.SectionMove>('section','move'),reorder:createCommand<Types.SectionReorder>('section','reorder'),delete:createCommand<Types.SectionDelete>('section','delete'),archive:createCommand<Types.SectionArchive>('section','archive'),unarchive:createCommand<Types.SectionUnarchive>('section','unarchive'),}constfilters={get:()=>state.filters,add:createCommand<Types.FilterAdd>('filter','add'),update:createCommand<Types.FilterUpdate>('filter','update'),delete:createCommand<Types.FilterDelete>('filter','delete'),updateOrders:createCommand<Types.FilterUpdateOrders>('filter','update_orders'),}constreminders={get:()=>state.reminders,add:createCommand<Types.ReminderAdd>('reminder','add'),update:createCommand<Types.ReminderUpdate>('reminder','update'),delete:createCommand<Types.ReminderDelete>('reminder','delete'),clearLocations:createCommand<Types.ReminderClearLocations>('reminder','clear_locations'),}constuser={get:()=>state.user,update:createCommand<Types.UserUpdate>('user','update'),updateGoals:createCommand<Types.UserUpdateGoals>('user','update_goals'),}constsettings={get:()=>state.user_settings,update:createCommand<Types.UserSettingsUpdate>('user_settings','update'),}constsharing={collaborators:()=>state.collaborators,shareProject:createCommand<Types.CollaboratorShareProject>('collaborator','share_project'),deleteCollaborator:createCommand<Types.CollaboratorDeleteCollaborator>('collaborator','delete_collaborator'),acceptInvitation:createCommand<Types.CollaboratorAcceptInvitation>('collaborator','accept_invitation'),rejectInvitation:createCommand<Types.CollaboratorRejectInvitation>('collaborator','reject_invitation'),deleteInvitation:createCommand<Types.CollaboratorDeleteInvitation>('collaborator','delete_invitation'),}constliveNotifications={setLastRead:createCommand<Types.LiveNotificationsSetLastRead>('live_notifications','set_last_read'),markAsRead:createCommand<Types.LiveNotificationsMarkRead>('live_notifications','mark_read'),markAllAsRead:createCommand<Types.LiveNotificationsMarkReadAll>('live_notifications','mark_read_all'),markAsUnread:createCommand<Types.LiveNotificationsMarkUnread>('live_notifications','mark_unread'),}constbusiness={// TODO: implement}constactivityLog={get:(options:any)=>request({url:`${options.endpoint}/activity/get`,query:options}),}constbackup={// TODO: implement}constemail={// TODO: implement}constapi={ activityLog, backup, business,colorsById:COLORS_BY_ID, commit, email, filters, items, labels, liveNotifications, notes, projects, projectNotes, reminders, sections, settings, sharing, state, sync, user,}
This module is not using the Sync API to it's full capacity. It is possible to issuemultiple commands in a single request, but this module doesn't.
For most cases, it doesn't matter. However if it does for you please file anissue:https://github.com/romgrk/node-todoist/issues
About
nodejs implementation of todoist sync API
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors9
Uh oh!
There was an error while loading.Please reload this page.