node-todoist

An implementation of the Todoist API for Node

Usage no npm install needed!

<script type="module">
  import nodeTodoist from 'https://cdn.skypack.dev/node-todoist';
</script>

README

node-todoist Build Status

An implementation of the Todoist API for Node

Installation

npm install node-todoist

API Reference

Example

var todoist = require('node-todoist');

Members

todoist.login(params, [cb])

Logs into Todoist via email and password. Necessary to get token for authenticated requests

Params

  • params Object - Object literal containing email and password.
  • [cb] function - optional callback

Returns: Promise | callback - Returns a promise or invokes a callback
Example

// promise style
todoist.login({email: email, password: password})
    .then(function(user){
        console.log(user)
    },
    function(e) { console.error(e); });

// callback style
todoist.login({email: email, password: password}, function(err,user){
    if(err){
        console.error(err);
        return;
    }
    console.log(user);
});

todoist.request(endpoint, params, [cb])

Queries the specified todoist endpoint with the specified parameters. For additional, information about endpoints and options, see the Todoist API Documentation.

Params

  • endpoint str - The Todoist endpoint to be queried.
  • params Object - Object literal specifying the query parameters.
  • [cb] function - Optional callback parameter. Called with err and data.

Returns: Promise | callback - Returns a promise or invokes a callback
Example

var my_params = {
    name: "New Project",
    color: 5,
    indent: 3,
    }

// promise style
todoist.request('addProject', my_params)
    .then(function(user){
        console.log(user)
    },
    function(e) { console.error(e); });

// callback style
todoist.request('addProject', my_params), function(err,data){
    if(err){
        console.error(err);
        return;
    }
    console.log(data);

Debug

node-todoist uses debug for debugging. Simply include todoist in the list of modules in the DEBUG environment variable.

export DEBUG=todoist or DEBUG=todoist node my_app.js

Contributors

    57	Jason Tarasovic

License

The MIT License (MIT)

Copyright (c) 2014 Jason Tarasovic

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.