Asana, the python wrapper for the asana api

Basic usage:

from asana import asana
asana_api = asana.AsanaAPI('YourAsanaAPIKey', debug=True)

# see your workspaces
myspaces = asana_api.list_workspaces()  #Result: [{u'id': 123456789, u'name': u'asanapy'}]

# create a new project
asana_api.create_project('test project', myspaces[0]['id'])

# create a new task
asana_api.create_task('yetanotherapitest', myspaces[0]['id'], assignee_status='later', notes='some notes')

# add a story to task
asana_api.add_story(mytask, 'omgwtfbbq')

AsanaAPI()

class asana.asana.AsanaAPI(apikey, debug=False)

Bases: object

Basic wrapper for the Asana api. For further information on the API itself see: http://developer.asana.com/documentation/

add_parent(task_id, parent_id)

Set the parent for an existing task.

Parameters:
  • task_id – id# of a task
  • parent_id – id# of a parent task
add_project_task(task_id, project_id)

Add project task

Parameters:
  • task_id – id# of task
  • project_id – id# of project
add_story(task_id, text)

Add a story to task

Parameters:
  • task_id – id# of task
  • text – story contents
add_tag_task(task_id, tag_id)

Tag a task

Parameters:
  • task_id – id# of task
  • tag_id – id# of tag to add
create_project(name, workspace, team=None, notes=None, archived=None)

Create a new project

Parameters:
  • name – Name of project
  • workspace – Workspace for task
  • team – Optional id/name of the team this project is shared with
  • notes – Optional notes to add
  • archived – Whether or not project is archived (defaults to False)
create_subtask(parent_id, name, completed=None, assignee=None, notes=None, followers=None, assignee_status=None, due_on=None)

Creates a task and sets it’s parent. There is one noticeable distinction between creating task and assigning it a parent and creating a subtask. Latter doesn’t get reflected in the project task list. Only in the parent task description. So using this method you can avoid polluting task list with subtasks.

Parameters:
  • parent_id – id# of a task that subtask will be assigned to
  • name – subtask name
  • assignee – Optional user id# of subtask assignee
  • notes – Optional subtask description
  • followers – Optional followers for subtask
  • assignee_status – Optional status for assignee
  • due_on – Due date in format YYYY-MM-DD
create_tag(tag, workspace)

Create tag

Parameters:
  • tag_name – name of the tag to be created
  • workspace – id# of workspace in which tag is to be created
create_task(name, workspace, assignee=None, assignee_status=None, completed=None, due_on=None, followers=None, notes=None, projects=None)

Create a new task

Parameters:
  • name – Name of task
  • workspace – Workspace for task
  • assignee – Optional assignee for task
  • assignee_status – status
  • completed – Whether this task is completed (defaults to False)
  • due_on – Optional due date for task
  • followers – Optional followers for task
  • notes – Optional notes to add to task
  • projects – Array of projects this task is associated with.
delete_project(project_id)

Delete project

Parameters:project_id – id# of project
get_attachment(attachment_id)

This method returns the full record for a single attachment.

Parameters:attachment_id – id# of an attachment
get_basic_auth()

Get basic auth creds :returns: the basic auth string

get_project(project_id)

Get project

Parameters:project_id – id# of project
get_project_tasks(project_id, include_archived=False)

Get project tasks

Parameters:
  • project_id – id# of project
  • include_archived – true to include archived tasks
get_story(story_id)

Get story

Parameters:story_id – id# of story
get_subtasks(task_id)

Get subtasks associated with a given task

Parameters:task_id – id# of task
get_tag_tasks(tag_id)

Get tasks for a tag

Parameters:tag_id – id# of task
get_tags(workspace)

Get available tags for workspace

Parameters:workspace – id# of workspace
get_task(task_id)

Get a task

Parameters:task_id – id# of task
get_task_tags(task_id)

List tags that are associated with a task.

Parameters:task_id – id# of task
handle_exception(r)

Handle exceptions

Parameters:
  • r – request object
  • api_target – API URI path for requests
  • data – payload
Returns:

1 if exception was 429 (rate limit exceeded), otherwise, -1

list_projects(workspace=None, archived=None)

“List all projects in a workspace

Parameters:
  • workspace – workspace whos projects you want to list
  • archived – default None, filter by archived status
list_stories(task_id)

List stories for task

Parameters:task_id – id# of task
list_tasks(workspace, assignee, include_archived=False, completed_since=None, modified_since=None)

List tasks

Parameters:
  • workspace – workspace id
  • assignee – assignee
  • include_archived – true to include archived tasks
list_users(workspace=None, filters=None)

List users

Parameters:
  • workspace – list users in given workspace
  • filters – Optional [] of filters you want to apply to listing
list_workspaces()

List workspaces

organization_teams(org_id)

Show all teams <http://developer.asana.com/documentation/#teams> you’re member of in an organization <https://asana.com/guide/workspaces/organizations>.

:param org_id organization id#

rm_project_task(task_id, project_id)

Remove a project from task

Parameters:
  • task_id – id# of task
  • project_id – id# of project
rm_tag_task(task_id, tag_id)

Remove a tag from a task.

Parameters:
  • task_id – id# of task
  • tag_id – id# of tag to remove
task_attachments(task_id)

Showing all attachments on a task.

Parameters:task_id – id# of a task
update_project(project_id, name=None, notes=None, archived=None)

Update project

Parameters:
  • project_id – id# of project
  • name – Update name
  • notes – Update notes
  • archived – Update archive status
update_task(task, name=None, assignee=None, assignee_status=None, completed=None, due_on=None, notes=None)

Update an existing task

Parameters:
  • task – task to update
  • name – Update task name
  • assignee – Update assignee
  • assignee_status – Update status
  • completed – Update whether the task is completed
  • due_on – Update due date
  • notes – Update notes
update_workspace(workspace_id, name)

Update workspace

Parameters:
  • workspace_id – id# of workspace
  • name – Update name
upload_attachment(task_id, file_name, stream)

This method uploads an attachment to a task.

Parameters:
  • task_id – id# of an a task
  • file_name – attachment’s file name
  • stream – open file handle
user_info(user_id='me')

Obtain user info on yourself or other users.

Parameters:user_id – target user or self (default)
exception asana.asana.AsanaException

Bases: exceptions.Exception

Wrap api specific errors

Indices and tables