Giter VIP home page Giter VIP logo

trello's Introduction

Build Status

trello

A simple asynchronous client for Trello

This is a wrapper for some of the Trello HTTP API. Please feel free to add any other pieces you need! :)

Installation

npm install trello

Usage

Log in to Trello and visit trello.com/app-key to get a token and app key. These need to be supplied when you create the Trello object (see below).

Example

  var Trello = require("trello");
  var trello = new Trello("MY APPLICATION KEY", "MY USER TOKEN");

  trello.addCard('Clean car', 'Wax on, wax off', myListId,
      function (error, trelloCard) {
          if (error) {
              console.log('Could not add card:', error);
          }
          else {
              console.log('Added card:', trelloCard);
          }
      });

Callback or promise

API calls can either execute a callback or return a promise. To return a promise just omit the callback parameter.

  //Callback
  trello.getCardsOnList(listId, callback);

  //Promise
  var cardsPromise = trello.getCardsOnList(listId);
  cardsPromise.then((cards) => {
    //do stuff
  })

Requests to API endpoints, not supported by this lib yet

    // Get all registered tokens and webhooks
    // Url will look like: https://api.trello.com/1/members/me/tokens?webhooks=true&key=YOURKEY&token=YOURTOKEN
    trello.makeRequest('get', '/1/members/me/tokens', { webhooks: true })
      .then((res) => {
          console.log(res)
      });

Available functions

Add

  • addAttachmentToCard
  • addBoard
  • addCard
  • addCardWithExtraParams
  • addChecklistToCard
  • addCommentToCard
  • addCustomField
  • addDueDateToCard
  • addExistingChecklistToCard
  • addItemToChecklist
  • addLabelOnBoard
  • addLabelToCard
  • addListToBoard
  • addMemberToBoard
  • addMemberToCard
  • addOptionToCustomField
  • addStickerToCard
  • addWebhook
  • copyBoard
  • setCustomFieldOnCard

Delete

  • deleteCard
  • deleteLabel
  • deleteLabelFromCard
  • delMemberFromCard
  • deleteWebhook

Get

  • getActionsOnBoard
  • getBoardMembers
  • getBoards
  • getCard
  • getCardsForList
  • getCardsOnBoard
  • getCardsOnBoardWithExtraParams
  • getCardsOnList
  • getCardsOnListWithExtraParams
  • getCardStickers
  • getChecklistsOnCard
  • getCustomFieldsOnBoard
  • getLabelsForBoard
  • getListsOnBoard
  • getListsOnBoardByFilter
  • getMember
  • getMemberCards
  • getOrganization
  • getOrgBoards
  • getOrgMembers

Update

  • renameList
  • updateBoardPref
  • updateCard
  • updateCardDescription
  • updateCardList
  • updateCardName
  • updateCardPos
  • updateChecklist
  • updateLabel
  • updateLabelColor
  • updateLabelName

Everything that is not available as a function can be requested by calling makeRequest.

History

0.13.0

  • Add function getOrganization

0.12.0

  • Replaced restler with needle

0.11.0

  • Update optional fields
  • Add optional field queries
  • Add function addCustomField
  • Add function addOptionToCustomField
  • Add function setCustomFieldOnCard
  • Add function updateCardPos
  • Add function delMemberFromCard

0.10.0

  • Add copyBoard functionality
  • Add getCustomFieldsOnBoard
  • Add getActionsOnBoard

0.9.1

  • Added trailing slash to /boards/ call

0.9.0

  • New function getCardsOnBoardWithExtraParams
  • New function getCardsOnListWithExtraParams
  • New function addDueDateToCard

0.8.0

  • Rename list fixed
  • Handle API rate limit by retries
  • New function addCardWithExtraParams

0.7.0

  • Public visibility for makeRequest

0.6.0

  • added getMember
  • added getCardStickers
  • added addStickerToCard
  • added getOrgBoards
  • added getMemberCards
  • added updateBoardPref
  • added addMemberToBoard

0.5.1

  • added renameList
  • added addChecklistToCard
  • added getChecklistsOnCard
  • added addExistingChecklistToCard
  • added updateChecklist
  • added getOrgMembers
  • API methods now return the promise

0.5.0

  • Support of promises
  • Basic support of Labeling:
    • getLabelsForBoard
    • addLabelOnBoard
    • deleteLabel
    • addLabelToCard
    • deleteLabelFromCard

0.4.1

  • Updated dev dependencies

0.4.0

  • One-time listener
  • addAttachmentToCard added
  • Updated restler dependency
  • Node.js support >= 0.10.x / removed 0.6 and 0.8

0.3.0

  • Project trello_ex merged again with original project trello
  • Using 'restler' again

0.2.0

  • getBoards added

trello's People

Contributors

adamgaskins avatar alexanderegeberg avatar alxblog avatar cafca avatar chrisbarless avatar graemef avatar jan avatar jumasheff avatar jwktje avatar karlpokus avatar kblok avatar kpiwko avatar luiztiago avatar markov00 avatar mbeasley avatar mgaruccio avatar motionharvest avatar nickrisky avatar norbertax avatar norberteder avatar quincyreid avatar randallkent avatar seanmadden avatar sionleroux avatar tijm-wolters avatar trokhim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trello's Issues

Module installed from npm does not contain getMember function

The following code which is there in the source tree at https://github.com/norberteder/trello/blob/master/main.js line 163-165

Trello.prototype.getMember = function(memberId, callback) {
    return makeRequest(rest.get, this.uri + '/1/member/' + memberId, {query: this.createQuery()}, callback);
}

is not there in the main.js of the node module I installed using npm install trello.

dependency entry in package.json after npm install trello is

"trello": "^0.5.1",

Thus I am unable to get the member details.

Ability To Send All Cards & Lists To A Board

I am trying to make a script to basically clone a Trello board and if something happens to it I can just revert it with a simple command (using discord js as well) that will send all lists and cards on the original board (I am going to define the original board's id's in multiple variables.

So basically I am asking if I can get all the lists on the board and send the lists and cards in the exact same place to another board.

Thanks

Typings

It would be extremely useful if we could have JsDoc annotations or a .d.ts typings export for all of the Trello package's methods. Not only are they super useful, but they make it easier to document and write fluent quick code without moving tabs or checking docs for a method.

I'd be willing to write a PR starting this off if needed, as I've already written out the types for the methods I use in my typescript applications, but would need some contributions for other methods assuming there's support for this idea.

Thanks!

Support Move Card To List & Copy Board

Add so I can clone a board and define a name for it, and move card so I can send cards to and from boards where I can define what card & what board & what placement

Update link to generate token, app secret and app key

Hi!

Since this module is number 1 at npm for trello I thought I'd mention that the links to generate token, app secret and app key in the readme are dead. A logged in user can generate them at /app-key. If you don't have time to update - do you accept PRs?

Unknown issue with updateCard not moving card to list

I've got another issue, and rather than spending lots of time figuring it out, I thought I'd take a minute to mention what I'm experiencing in hopes that I'm just doing it wrong.

I am trying to move a card from to a list that i know the list id of.

trello.updateCard(myCard.id, myList.id).then((update) => { console.log("that should have done it"); });

My node app kicks out that should have done it but the card didn't move. I looked for clues inside of updateCard() in main.js.

Here it is:
`Trello.prototype.updateCard = function (cardId, field, value, callback) {
var query = this.createQuery();
query.value = value;

return makeRequest(rest.put, this.uri + '/1/cards/' + cardId + '/' + field, {query: query}, callback);

}; `

In comparing that to the Trello API I see that the Endpoint is 'https://api.trello.com/1/cards/myCard' and to move it, you specify an query object that includes a idList parameter like { idList: 'myListID' }

Which would indicate that updateCard wasn't meant to be used to move a card from list to list. So given this, how might I go about implementing a Trello.prototype.moveCard?

Docs

I can't seem to find any Docs, I'd love to use this module properly but there is no documentation to find out how something works

Allow to specify fields with each request

I'd like this kind of signature to be supported:

getCardById("id", { checklists: "all" })

This could be implemented in a backward compatible way, as a new argument right before the callback.

The createQuery could be extended to accept an object as argument, which it mixes with key and token.

Trello.prototype.createQuery = function (options = {}) {
    return { ...options, key: this.key, token: this.token};
};
Trello.prototype.getCard = function (boardId, cardId, fields, callback) {
    // Back compatible: If last argument is a callback, then no fields are given
    if (typeof fields === "function") {
        callback = fields
    }
    if(boardId === null)
        return makeRequest(rest.get, this.uri + '/1/cards/' + cardId, fields, callback);
    return makeRequest(rest.get, this.uri + '/1/boards/' + boardId + '/cards/' + cardId, fields, callback);
};

Does this make sense?

Add continuous release deployment

Right now releases are manual and there can be some lag between new code being merged and that code being available via npm. It would be nice if new pushes to master automatically generated a new release. It looks like Travis can support this, and I'd be happy to do the initial work to get things configured in the .travis.yml file as long as there's interest in getting the feature added/enabled.

Travis documentation on this - https://docs.travis-ci.com/user/deployment/releases/

Security vulnerability of qs dependency

According to Snyk the version of qs that is being used at the moment is not secure.

image

Hmm. Looks like "restler" is the culprit here. And that project has not seen a commit in 4 years.

There is an outstanding issue in the restler project addressing this: #89 (comment)

Dependency not found

Having an issue with this package's dependencies:

  ERROR  Failed to compile with 1 errors                             
  This dependency was not found:
  * fs in ./~/restler/lib/multipartform.js
  To install it, you can run: npm install --save fs

I have manually added fs as a dependency to my project, but that doensn't fix the issue.

Requests not working since changed to needle

Hi, I've been trying to use your project for making requests and noticed that none of the functions work (tried with addCard, addBoard, getCardsOnBoard, so it might be the same for the rest of them), however the tests pass.

So, making tests and comparing to a previous version, I realized that the method makeReqest calls completeCallback once the request method (put, post, delete ...) returns a ReadableStream event "complete".

fn(uri, options).once('complete', completeCallback);

But this only exists in restler:

complete: function(result, response) - emitted when the request has finished whether it was successful or not. Gets passed the response result and the response object as arguments. If some error has occurred, result is always instance of Error, otherwise it contains response data.

I looked at the documentation for needle, and found an almost equivalent event:

done (previously 'end') - Emitted when the request/response process has finished, either because all data was consumed or an error ocurred somewhere in between. Unlike a regular stream's end event, Needle's done will be fired either on success or on failure...

I tried just replacing it, but this are different events in core, so it doesn't even get triggered, and I think the params passed as arguments are different as well...

So I suggest either going back to restler or maybe find a way to fix this with needle.

"possible EventEmitter memory leak detected" even using promises

I am getting this "possible EventEmitter memory leak detected" when I try to create more than 10 cards at the same time.
This could be the expected behavior but the thing is that I am using promises so I am chaining the card creation in this way:

var promise;
var cardCreationPromise;
_.each(myData, function (ticket) {
                if(!promise) {
                    cardCreationPromise = Q.defer();
                    trello.addCard(ticket.summary, ticket.description, listId, cardCreationPromise.makeNodeResolver());
                    promise = cardCreationPromise.promise;
                } else {
                    promise = promise.then(function(e) {
                        cardCreationPromise = Q.defer();
                        trello.addCard(ticket.summary, ticket.description, listId, cardCreationPromise.makeNodeResolver());
                        return cardCreationPromise.promise;
                    });    
                }
            });

Typical chaining...

After some research I have learned that this "memory leak issue "is a common problem in Restler and in Node JS in general.
You can do your own research and see if you end up with the same solution as I. The main problem is that when we use the "on" event, the listener is still registered so we are "leaking" (It is not technically a leak) listeners even if we chain the calls. But if you use "once" instead of "on" we are calling to the next card creating after the listener is cleared, and we should clear the "error" listener too:

function makeRequest(fn, uri, options, callback) {
    var request = fn(uri, options);
    request.once('complete', function (result) {
        if (result instanceof Error) {
            callback(result);
        } else {
            callback(null, result);
        }
        request.removeAllListeners('error');
    });
}

These two changes fix the issue in my scenario.

new process.EventEmitter deprecation

When installing this package with Node v16.1.0, I get 3 high severity vulnerabilities. If I try to run

npm audit fix --force

I get an error that process.EventEmitter is not a constructor.

Suggestion:
process.EventEmitter was deprecated in Node.js 6 and is removed in Node.js 7, use require('events') as a drop-in replacement.

Adding CopyList Function

Hey would be really cool if you could be able to copy a list (and all the cards in it) like you can on the website.

I want to make a backup system that checks for lists and for every list it copies the list (and all the cards) (coz then it saves comments) and then catches the ID and sends to the the backup board.

Custom fields

How would I go about changing custom fields on a card?

For example, let's say I want to:

  • set a checkbox to true
  • change a dropdown selection to "Passed"
  • change a custom text field's contents

Please help!

addAttachment

If an addAttachment is added I could start using this.

Create Board error

I just spent 2 hours trying to figure out why I couldn't create a board. I kept getting an odd error saying I didn't have permission to access the API... despite having an auth token with the proper read/write permissions.

I referenced the Trello API and noticed that the Docs use this api call "http://api.trello.com/1/boards/" and on on line 95 of main.js you are missing the trailing slash. https://github.com/norberteder/trello/blob/master/main.js#L95

I popped into node_modules and made the edit and the issue i was having vanished. First try, new board created itself no problem.

GetCardID, GetListID, GetBoardID

Is there a way you can add these methods onto the trello API? Or at least provide code for us to do it. Here are the parameters for it:
getCardID(cardName, listID)
getListID(listName, boardID)
getBoardID(boardName)

setCardPos

It would be nice if you guys added a function to set the card pos.

restler uses octal literals

The underlying restler package doesn't appear to have been updated in 4-5 years. It uses octal literals. the problem is when running something with use_strict mode on, this causes failures. Any chance restler could be replaced with a maintained package?

set data in global variable

I love this package but i can't save data into var like this

var id ="";
api.getBoards('Shinkoz').then(boardName => {
id = boardName[0].id
}

is there a method for this?

Typesafety in API

I'd like to add type safety to the package.

I have already started working on it, it would benefit the project by adding type safety and allowing developers to use the package in Typescript.

If you'd like me to continue contributing, let me know.

High Severity Vulnerabilities

Hello!
I was looking to use your library for interacting with trello but when I went to install with npm, I'm seeing this warning in the console:

3 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

When I try to run that second command it puts your package all the way back to 0.3.0! And that version unfortunately doesn't have the features that I was hoping to use. Might be a good idea for you all to audit your dependencies and figure out what's giving you those vulnerabilities.

How to use getCardsOnBoardWithExtraParams?

Hello,
i'm trying to use getCardsOnBoardWithExtraParams, but i don't know what i'm doing wrong.
I want to return only cards with due date equals false.

let params = { dueComplete: false }
let boardId = "......"
 trello.getCardsOnBoardWithExtraParams(boardId, params)
 .then(boards => {
// My implementation
})

Can anyone help me?
Thanks!

custom parameters

As far as I can see it's not possible to use e.g. pagination (before) or other parameters when getting cards on a list? Unless I missed something, it would be nice to be able to use all Trello API params

makeRequest should be made public

to easily use API endpoints not supported yet by the lib.

The makeRequest would mix in the key and token query params to whatever the user hands in as ? query

(bug): I cant get Lists

I'm trying to run this scripts under Node v6 and v7:

const Trello = require("trello_ex")
const trello = new Trello(APP_KEY, USER_TOKEN)

trello.getListsOnBoardByFilter(BOARD_ID, "open", (err, lists) => {
    if (err) console.error(err)
    
    console.log(lists)
})

And the STDOUT is just:

"[STATUS] RestClient request send, U…trello.com/1/boards/BOARD_ID/lists"
"[STATUS] RestClient request send, Method: GET"
Error: [object Object]

I'm trying to debug it and found where the problem exists but its not clear enough. I'm trying to use this package because of https://github.com/devtyr/trello-burndown

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.