Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

nodejs implementation of todoist sync API

NotificationsYou must be signed in to change notification settings

romgrk/node-todoist

Repository files navigation

npm version

This module implements v9 of Todoist Sync API describedhere

Installation

npm install todoist

or

yarn add todoist

Usage

constTodoist=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

API

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,}

Closing note on efficiency

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors9


[8]ページ先頭

©2009-2026 Movatter.jp