JavaScript

Installation

For use in the Node server-side JavaScript runtime, you can install with npm:

npm install asana

Browser

You may also use our library directly in the browser (i.e., rather than in a Node environment). Visit the Releases page to download the latest full or minified JS bundle, then include the following script in your web page:

<script src="asana-min.js"></script>

Hello world

In this brief tutorial, we'll build a GET request to /users/me using the Node client library.

To get started, be sure that you have installed the library (npm install asana). You may also follow the detailed installation instructions on the GitHub page for the Node client library. Then, once the library is installed:

  1. Copy the example code below:
// Import the library
var asana = require('asana');

// Note: Replace this value with your own personal access token
var personalAccessToken = '0/123456789....';

// Construct an Asana client
var client = asana.Client.create().useAccessToken(personalAccessToken);

// Get your user info
client.users.me()
  .then(function(me) {
    // Print out your information
    console.log('Hello world! ' + 'My name is ' + me.name + '!');
});
  1. Open a text editor and save this code in a file (i.e., a descriptive file name such as hello_world.js).

  2. Run this script in your console by passing it as an argument to the Node interpreter: node hello_world.js. You must execute this command in the same directory as the file.

  3. You should see the response outputted to the console.

You can see a variant of this script, and other useful Asana API scripts, in our open-source devrel-examples.


GitHub

You can access the library's source code on GitHub.

All of the built-in functions can be found in the /gen folder of the client library.