get_tasks

imerit_ango.sdk.SDK.

get_tasks(project_id, page, limit, status, stage, batches)

Get tasks of a project.

Tasks in projects are paginated. A maximum of 1000 items per page can be obtained. See the code snippets below for an example of how to download all tasks from a project by flipping through the pages.

Parameters

  • project_id: string

  • page: integer, default 1

    • Current page.

    • Example: 1

  • limit: integer, default 10

    • Page size. Default 10, maximum 1000.

    • Example: 100

  • status: string, default None, {None, "TODO", "Completed"}

    • Filter tasks by status.

    • Example: 'Completed'

  • stage: string, default None

    • Pass a stage ID to filter tasks by stage. You can obtain a stage's ID by running get_export(project_id)on the project where you'd like to get the stage IDs.

    • Example: 'Label' or "1a1a2d88-ddad-457a-aac8-fe50a3a65272"

  • batches: list[str], default None

    • Filter tasks by batch (e.g., only get tasks belonging to the batch specified)

    • Example ['batch_1', 'batch_2']

Returns:

  • output: dict

Example

Retrieve the first ten tasks from the project:

import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

sdk_response = ango_sdk.get_tasks(project_id, page=1, limit=10, status=None)

data_url = sdk_response['data']['tasks'][0]['asset']['data']
external_id = sdk_response['data']['tasks'][0]['asset']['externalId']

Retrieve all tasks from the project:

import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

page = 1
num_tasks = 1
task_list = []
while len(task_list) < num_tasks:
    response = ango_sdk.get_tasks(project_id=project_id, page=page, limit=50)
    tasks = response.get('data', {}).get('tasks', [])
    num_tasks = response.get('data', {}).get('total', 0)

    task_list.extend(tasks)
    page += 1

print("The number of retrieved tasks is: " + str(len(task_list)))

Last updated