shnee / anydo-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any.do API (unofficial)

This API allows to list and add tasks and also get auth token

Installation

npm install anydo-api

Example

const Api = require('anydo-api');

const api = new Api('your_email', 'your_password');

const tasks = [
    {title: 'from api today'},
    {title: 'from api tomorrow', dueDate: 'tomorrow'},
    {title: 'from api upcoming', dueDate: 'upcoming'},
    {title: 'from api someday', dueDate: null},
];

// create then delete tasks
api.addTasks(tasks)
    .then(() => api.sync())
    .then(res => {
        const titlesToFind = tasks.map(t => t.title);
        const filteredList = res.models.task.items.filter(t => titlesToFind.includes(t.title));

        console.log(filteredList.length);

        filteredList.forEach(t => api.deleteTask({taskId: t.id}));
    });

Methods

api.login(options) ⇒ Promise

Get auth token

Param Type
options object
options.email string
options.password string

api.sync([options]) ⇒ Promise

Sync tasks If it is invoked without options, it just returns all undone and not deleted tasks

Param Type
[options] object
[options.updateSince] number
[options.includeDone] boolean
[options.includeDeleted] boolean
[options.models] object

api.setToken(token) ⇒ Promise

Set token for current API instance

Param Type
token object
token.token string

api.addTask(options) ⇒ Promise

Add new task

Param Type
options object
options.title string
[options.dueDate] number | string

api.addTasks(tasks) ⇒ Promise

Add several tasks at once

Param Type
tasks Array.<object>
tasks[].title string
[tasks[].dueDate] number | string

api.deleteTask(object) ⇒ Promise

Delete task

Param Type
object object
object.taskId string

CLI

Any.DO CLI

About

License:MIT License


Languages

Language:JavaScript 100.0%