A node.js client for the Asana API
A node.js client for the 1.0 version of the Asana API.
- Thin Wrapper This client is a thin wrapper which means that the client makes little attempt to verify the validity of the arguments locally. All errors are reported by the server. We include custom Error types which will contain the response from the server.
- Promises Promises with bluebird seem like the most neutral way
to support node's various async paradigms. If you want promises, you get them
by default. If you want callbacks, bluebird promises support
nodeifywhich takes a callback as parameter. For generators and streams, co and highland also support promises respectively. Beyond that, other major libraries such as mongoose, mocha, and elastic search (which uses bluebird) also support promises.
Various examples are in the repository under
examples/, but some basic
concepts are illustrated here.
var Asana = require'asana';var util = require'util';// Using the API key for basic authentication. This is reasonable to get// started with, but Oauth is more secure and provides more features.var client = AsanaClientcreateuseBasicAuthprocessenvASANA_API_KEY;clientusersmethenvar userId = userid;// The user's "default" workspace is the first one in the list, though// any user can have multiple workspaces so you can't always assume this// is the one you want to work with.var workspaceId = userworkspaces0id;return clienttasksfindAllassignee: userIdworkspace: workspaceIdcompleted_since: 'now'opt_fields: 'id,name,assignee_status,completed';then// There may be more pages of data, we could stream or return a promise// to request those here - for now, let's just return the first page// of items.return responsedata;;filterreturn taskassignee_status === 'today' ||taskassignee_status === 'new';thenconsole.logutilinspectlistcolors: truedepth: null;;
Install with npm:
npm install asana --save
The code is thoroughly documented with JsDoc tags, and online documentation can be found on the wiki. Also, the Official Asana Documentation is a great resource since this is just a thin wrapper for the API.
Feel free to fork and submit pull requests for the code! Please follow the existing code as an example of style and make sure that all your code passes lint and tests. For a sanity check:
git clone firstname.lastname@example.org:Asana/node-asana.gitcd node-asananpm installnpm test