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", "Reviewed"}

    • 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)

items_per_page = 100
max_limit = None

tasks = []
page = 1
remaining_tasks = 1
while remaining_tasks > 0:
    response = ango_sdk.get_tasks(project_id=project_id, page=page, limit=items_per_page)
    tasks.extend(response['data']['tasks'])
    remaining_tasks = response['data']['total'] - len(tasks)

    if max_limit and len(tasks) >= max_limit:
        tasks = tasks[:max_limit]
        break
    
    page += 1

print(len(tasks))

Last updated