Giter Site home page Giter Site logo

cooolbabu / clickup.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from comfortablycoding/clickup.js

0.0 0.0 0.0 1.18 MB

A Node.js wrapper for the Clickup API

Home Page: https://clickup-js.netlify.app/

License: MIT License

JavaScript 100.00%

clickup.js's Introduction

clickup.js

A Node.js wrapper for the Clickup API.

Downloads Install size Package version

Install

npm install clickup.js

or

yarn add clickup.js

Usage

Before you can use this library you will need to first authenticate with the Clickup API and obtain an Access Token. You can read how to do so at the Clickup API docs.

In your project, initialize an instance of clickup.js:

const { Clickup } = require('clickup.js');
const token = '...'; // API access token
const clickup = new Clickup(token);

Once you've created an instance, you can use it to access all the features provided by the wrapper, the following example fetches a task by id and displays the response to the console:

(async () => {
 try {
  // get a specific task
  const { body } = await clickup.tasks.get('9hz');
  console.log(body);
 } catch (error) {
  if (error.response) {
   // The request was made and the server responded with a status code
   // that falls out of the range of 2xx
   console.log(error.response.body);
   console.log(error.response.statusCode);
   console.log(error.response.headers);
  } else if (error.request) {
   // The request was made but no response was received
   console.log(error.request);
  } else {
   // Something happened in setting up the request that triggered an Error
   console.log('Error', error.message);
  }
  console.log(error.options);
 }
})();

Note: Due to the HTTP request library being used each error contains an options property which are the options Got used to create a request - just to make debugging easier. Additionally, the errors may have request and response properties depending on which phase of the request failed. Read more about HTTP request library Got.

Important Note

The library is structured to match classes with their respective routes, NOT how they are sectioned in the Clickup API docs. For example adding a guest to a task is under the Tasks class instead of the Guests class as its route is via task and not guest. Due to this a request to add a guest to a task will look like so:

(async () => {
 try {
  // guest data
  const guestData = {
   permission_level: 'read',
  };
  // add guest to task
  const { body } = await clickup.tasks.addGuest('c04', 403, guestData);
  console.log(body);
 } catch (error) {
  if (error.response) {
   // The request was made and the server responded with a status code
   // that falls out of the range of 2xx
   console.log(error.response.body);
   console.log(error.response.statusCode);
   console.log(error.response.headers);
  } else if (error.request) {
   // The request was made but no response was received
   console.log(error.request);
  } else {
   // Something happened in setting up the request that triggered an Error
   console.log('Error', error.message);
  }
  console.log(error.options);
 }
})();

Documentation

You can read the library documentation at the clickup.js docs

Features

The available features are:

  • Authorization
  • Checklists
  • Comments
  • Folders
  • Goals
  • KeyResults
  • Lists
  • Spaces
  • Tasks
  • Teams
  • Views
  • Webhooks

Disclaimer

The clickup.js package is unofficial and therefor not endorsed or affiliated with ClickUp or it's subsidiaries.

clickup.js's People

Contributors

comfortablycoding avatar adamj88 avatar edsol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.