The official Python client library for interacting with the Asana API. It provides a simple interface to access Asana resources like tasks, projects, users, and workspaces. The current version is 5.2.4, and the library receives frequent updates, typically focusing on adding support for new API endpoints.
pip install asanaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Asana client using a Personal Access Token (PAT) and fetch the current user's details and a list of accessible workspaces. It handles token retrieval from environment variables for security and includes basic error handling.
Update client instantiation to `asana.Client.access_token('YOUR_PAT')` or `asana.Client.oauth(...)`. Replace old resource methods (`projects.find_all`) with their v4+ equivalents (`projects.get_projects`). Consult the official v4 migration guide if available, or the current documentation.To iterate through results: `for item in client.tasks.get_tasks(...)`. To get all results as a list (for smaller collections, use with caution for large ones): `list(client.tasks.get_tasks(...))` or pass `iterator_type=None` to the method, e.g., `client.tasks.get_tasks(workspace_gid, iterator_type=None)`.
When calling any `get_` method for resources, pass a list of desired fields to `opt_fields`. Example: `task = client.tasks.get_task(task_gid, opt_fields=['name', 'notes', 'assignee.name'])`. This also applies to collection fetching methods.
Ensure your Personal Access Token is correctly set. You can either replace `'YOUR_ASANA_PAT'` directly in your code with your actual token, or set the `ASANA_ACCESS_TOKEN` environment variable before running your application. For example, `client = asana.Client.access_token(os.environ['ASANA_ACCESS_TOKEN'])`.
Ensure the `ASANA_ACCESS_TOKEN` environment variable is set to your Asana Personal Access Token, or replace the placeholder token (e.g., 'YOUR_PAT') in your client instantiation code with your actual Asana Personal Access Token. For OAuth, ensure the OAuth flow is correctly implemented to obtain and use credentials.