SDK Documentation

How to install and use Ango Hub's Python SDK.

We provide a Python SDK to interface programmatically with Ango Hub.

SDK Installation

How to Install the Ango SDK

To use the Ango SDK, you will need the latest imerit-ango Python package, which we publish on PyPI.

To download and add the package to your current Python environment, simply run

pip install imerit-ango

How to upgrade the Ango SDK

To upgrade the imerit-ango package to its latest version in your current Python environment run

pip install -U imerit-ango

Obtaining your API Key

To use the imerit-ango package, you will need an API key. To obtain your API key, from your account page, enter the API tab. From here, you can create and copy your API key. For more information, please visit the Get your API Key page.

Creating a new API key will revoke the existing one.

Obtaining Project and Task IDs

Each project and task in Ango Hub is assigned its own unique ID. You may need to use such IDs in the SDK.

Project IDs

To obtain a project's ID, open the project and look at your browser's address bar. The URL will be in the format:

https://imerit.ango.ai/projects/<project_id>

Copy the project ID from your address bar.

Task and Asset IDs

To obtain Task and Asset IDs, from the Task or the Assets tab, open the task you'd like to copy the ID of. Then, open the Task Info panel on the right and copy the ID you need.

You may use one of the Copy to Clipboard buttons to speed up the process.

Environmental Variables

Snippets in this page make the assumption that you have your API key and other variables set as environmental variables.

To set environmental variables, install the python-dotenv package from pip by running

pip install python-dotenv

in your Python environment.

Then, create a file called .env in your environment's root folder. The contents of this .env file will look like this:

API_KEY=00af1132-0558-4ec7-93e3-46826a455ac0
PROJECT_ID=1233453123dsfdf012

In your Python scripts, then, import the package by using

from dotenv import load_dotenv
import os

and load the environmental variables by running load_dotenv() before using the variables in your script.

You will then be able to access your environmental variables by using os.getenv("VAR_NAME"), like so:

API_KEY = os.getenv("API_KEY")

Project Level SDK Functions (v1.3.14)

imerit_ango.sdk.SDK.

add_members_to_project(project_id, members, role)

Add specific users to a project.

Parameters:

  • project_id: string

    • ID of the project where the attachment will be created. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • members: List[str]

    • A list of emails of the user(s) you wish to add to the project.

    • Example: ["user1@test.com", "user2@test.com"]

  • role: imerit_ango.models.enums.ProjectRoles

    • The role in which you would like to add the user(s) to the project.

    • Example: ProjectRoles.labeler

    • (Note: you must import the enum containing the roles using from imerit_ango.models.enums import ProjectRoles)

Returns:

No return.

Example:

from imerit_ango.sdk import SDK
from imerit_ango.models.enums import ProjectRoles
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

ango_sdk.add_members_to_project(
    project_id=project_id,
    members=["user1@example.com", "user2@example.com"],
    role=ProjectRoles.Labeler
)

assign_batches(project_id, asset_ids, batches)

Assign specific asset(s) to specific batches.

Parameters:

  • project_id: string

    • ID of the project where the attachment will be created. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • asset_ids: List[str]

    • List of asset IDs to assign to batches. Asset IDs can be obtained from the UI, or from get_assets.

    • Example: ['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']

  • batches: List[str]

    • List of batches to which assets will be assigned.

    • You can choose to pass either a list of batch names or a list of batch IDs. Batch names and batch IDs can be obtained with get_batches.

    • Example:

      • ['Batch-1', 'Batch-2'] or

      • ['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

asset_ids = ['<YOUR ASSET ID 1>', '<YOUR ASSET ID 2>']
batch_ids = ['<YOUR BATCH ID 1>', '<YOUR BATCH ID 2>']

ango_sdk.assign_batches(project_id, asset_ids, batch_ids)

Outputs:

{
  "status": "success",
  "data": {
    "assets": 2
  }
}

Where "assets" is the number of assets successfully assigned to the batch(es).

assign_task(project, tasks, stage, email)

Assign a task to a specific user with email.

Parameters:

  • project: string

    • ID of the project where the attachment will be created. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • tasks: list

    • A list of task IDs to be assigned. Task IDs can be obtained from the UI, and from get_tasks.

    • Example: ['0000000aa0a00a0000aaaa0a', '0000000bb0b00b0000bbbb0b']

  • stage_filter: string

    • ID of the stage on which the assignee will work.

    • Example: "206f2f63-ac2d-4458-92d8-b84fd7264db3" or, in the case of the default labeling stage, "Label".

  • email: string

    • Mail address with which the user is to be assigned the task to register.

    • Example: 'lorenzo@example.com'

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

task_id = '<YOUR TASK ID>'
email = '<example@example.com>'
ango_sdk.assign_task(project=project_id, tasks=[task_id], stage='Label', email=email)

See also

get_tasks

create_attachment(project_id, attachments)

Add attachments to assets in a project. More on attachments and uploading them here.

Parameters:

  • project_id: string

    • ID of the project where the attachment will be created. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • attachments: List[dict]

    • List of attachments to attach to existing assets. Attachments are dictionaries containing information about the asset the attachment will be attached to, the type of attachment, and the content of the attachment.

    • Example attachment parameter with 3 attachments being attached to 2 assets:

attachments = [
    {"externalId": "sample_image_1.png",
     "attachments": [
         {"type": "IMAGE", "value": "https://sample-attachment-image.jpg"},
         {"type": "TEXT", "value": "Some sample text."}
     ]
     },
    {"externalId": "sample_image_2.png",
     "attachments": [
         {"type": "VIDEO", "value": "https://sample-attachment-video.jpg"}
     ]
     }
]

Attachments can have one of the types "IMAGE", "TEXT", or "VIDEO".

For IMAGE and VIDEO, you will need to provide a link to the resource. JPG, PNG, and MP4 are supported.

For text, you will need to provide the text that will be attached.

For image and video attachments, you may provide links to assets in private buckets, provided that you've connected them to Ango Hub. More information on how to do so can be found in the Attachments page.

In AWS S3, if your attachment URL does not contain region information, your attachments may not be visible. When using S3, please ensure the region information is contained in the URL right after the bucket name, like so:

https://bucket-name.s3.eu-central-1.amazonaws.com/filename.JPG?storageId=111bb111389ff80015f2b914

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

attachments = [{"externalId": "sample_image_1.png",
                "attachments": [{"type": "IMAGE",
                                 "value": "https://sample-attachment-image.jpg"},
                                {"type": "TEXT",
                                 "value": "Some sample text."}]
               },
               {"externalId": "sample_image_2.png",
                "attachments": [{"type": "VIDEO",
                                 "value": "https://sample-attachment-video.jpg"}]
               }]

ango_sdk.create_attachment(project_id, attachments)

create_batch(project_id, batch_name)

Create batches in a specific project.

Parameters:

  • project_id: str

    • ID of the project where the batch will be created. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • batch_name: str

    • Name of the batch to be created.

    • Example: 'My Batch 1'

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

ango_sdk.create_batch(project_id, "My Batch Name")

create_issue(task_id, content, position)

Opens an issue to the specified task, with given content on the given position.

Parameters:

  • task_id: string

    • ID of the task to be assigned. Task IDs can be obtained from the UI and from get_tasks.

    • Example: '0000000aa0a00a0000aaaa0a'

  • content: string

    • Text content of the issue.

    • Example: 'The bounding box here should reach the edges.'

  • position: List[integer]

    • Position, in pixel, of where the issue should be placed on the image asset.

    • Example: [25, 15]

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
ango_sdk = SDK(api_key)

task_id = '<YOUR TASK ID>'
content = 'Hey! Check this annotation.'
position = [25, 15]

ango_sdk.create_issue(task_id, content, position)

See also

get_tasks

create_label_set(project_id, tools, classifications, relations)

Create and set the project's ontology.

As this method is more complex than others, we recommend also consulting the examples at the end of this section.

Parameters:

  • project_id: string

    • ID of the project where the label set will be created. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • tools: List[ToolCategory], optional

    • List of tools that will be added to the label set.

    • Example: [ToolCategory(Tool.Segmentation, title="SegmentationTool")]

  • classifications: List[ClassificationCategory], optional, default None

    • List of classifications that will be added to the label set.

    • Example: [ClassificationCategory(Classification.Single_dropdown, title = "Choice", options=[LabelOption("First"), LabelOption("Second")])]

  • relations: List[RelationCategory], optional, default None

    • List of relations that will be added to the label set.

    • Example: [RelationCategory(Relation.Single, title="SingleRelationTool")]

  • raw_category_schema: Dict, optional, default None

    • Instead of creating the label set (category schema) using the previous 'tools', 'classifications', and 'relations' parameters, you may pass here a dictionary representing the entire category schema.

    • See section below for an example.

To get an example of what can be passed as the raw_category_schema, there are two ways:

  • Using the SDK itself, get the category schema from another existing project. This will also allow you to programmatically copy the category schema between two projects, like so:

existing_proj = sdk.get_project(project_id="65cc88c1176c485ce1e49f28") # Get existing project information.

cat_schema = existing_proj.get("data").get("project").get("categorySchema") # Extract category schema info from existing project.

new_proj = sdk.create_project("New Project Title", "New Project Description") # Create new project.

sdk.create_label_set(project_id=new_proj.get("data").get("project").get("_id"), raw_category_schema=cat_schema) # Add new category schema to newly created project.

As an example, a raw_category_schema obtained from a project could be this:

{
  "tools": [
    {
      "title": "Vehicle",
      "tool": "bounding-box",
      "required": false,
      "schemaId": "c053da596995f93c2c71520",
      "ocrEnabled": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1"
    }
  ],
  "classifications": [
    {
      "title": "Color",
      "tool": "radio",
      "required": false,
      "schemaId": "75c02176796c17e7c657955",
      "frameSpecific": false,
      "classifications": [],
      "multiple": false,
      "options": [
        {
          "value": "Red",
          "schemaId": "95df97dc43d2e1dcc77d536"
        },
        {
          "value": "Yellow",
          "schemaId": "f477d05947e30259cc53538"
        },
        {
          "value": "Blue",
          "schemaId": "18a8212c7c48c2ee3464602"
        }
      ],
      "shortcutKey": "2"
    }
  ],
  "relations": []
}

Label Set Classes

ToolCategory: {Segmentation, Polyline, Polygon, Rotated_bounding_box, Ner, Point, Pdf}

ToolCategory Parameters:

  • tool: Tool

    • The tool type. ex.: Tool.Segmentation

  • title: string, default ""

    • The title of the tool.

  • required: bool, default None

    • Whether annotators are required to draw at least one instance of this tool.

  • schemaId: string, default None

    • Sets the tool's schemaId.

  • columnField: bool, default False

    • Whether this tool should be a table column.

  • color: string, default ""

    • The color assigned to this labeling tool, in the format "#FFFFFF"

  • shortcutKey: string, default ""

    • The shortcut to quickly select this tool, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"

  • classifications: List[ClassificationCategory], default []

    • List of nested classifications, if any

  • options: List[LabelOption], default []

    • The tool's answers (options.)

ClassificationCategory: {Multi_dropdown, Single_dropdown Tree_dropdown, Radio, Checkbox, Text, Instance}

ClassificationCategory Parameters:

  • classification: Classification

    • The classification type. ex.:Classification.Tree_dropdown

  • title: string, default ""

    • The title of the classification.

  • required: bool, default None

    • Whether annotators have to answer this classification or not.

  • schemaId: string, default None

    • Sets the classification's Schema ID.

  • columnField: bool, default False

    • Whether this classification should be a table column.

  • color: string, default ""

    • The color assigned to this labeling tool, in the format "#FFFFFF"

  • shortcutKey: string, default ""

    • The shortcut to quickly select this tool, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"

  • classifications: List, default [ClassificationCategory]

    • List of nested classifications, if any

  • options: List[LabelOption], default []

    • The classification's answers (options.)

  • treeOptions: List[TreeOption], default []

    • For trees, the tree's leaves/branches.

  • parentOptionId: string, default ""

    • The schema ID of the parent option. That is, the option that the labeler needs to select in order for this classification to appear. Enables conditional nesting.

  • richText: bool, default False

    • Set to True to enable the Rich Text editor for the selected text classification tool.

RelationCategory: {Single, Group}

RelationCategory Parameters:

  • relation: Relation

    • The classification type. ex.:Relation.Single

  • title: string, default ""

    • The title of the relation.

  • required: bool, default None

    • Whether annotators have to include at least one such relation in order to submit their annotation.

  • schemaId: string, default None

    • Sets the schemaId of the relation.

  • columnField: bool, default False

    • Whether this relation should be a table column.

  • color: string, default ""

    • The color assigned to this relation, in the format "#FFFFFF"

  • shortcutKey: string, default ""

    • The shortcut to quickly select this relation, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"

  • classifications: List[ClassificationCategory], default []

    • List of nested classifications, if any

  • options: List[LabelOption], default []

    • The relation's answers (options.)

LabelOption parameters:

  • value: string

    • The text of the answer (option.)

  • schemaId: string, default None

    • The schema ID of the option. Necessary for conditional nesting.

Returns:

  • output: dict

Examples:

Creating an ontology with:

  • A Single Dropdown classification, with two choices named "First" and "Second":

from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import LabelOption, ClassificationCategory, Classification
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')

ango_sdk = SDK(api_key)

category = ClassificationCategory(Classification.Single_dropdown, 
                                  title = "Choice", 
                                  options=[LabelOption("First"), LabelOption("Second")])

label_set = [category]

response = ango_sdk.create_label_set(project_id=project_id, classifications=label_set)
print(response)

Creating an ontology with:

from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, Classification, LabelOption, Tool, ToolCategory, RelationCategory, Relation
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')

ango_sdk = SDK(api_key)

dropdown = ClassificationCategory(Classification.Single_dropdown,
                                  title = "SingleDropdown",
                                  options = [LabelOption('First'), LabelOption('Second')])
classifications = [dropdown]

segmentation = ToolCategory(Tool.Segmentation, title="SegmentationTool")
tools = [segmentation]

relation = RelationCategory(Relation.Single, title="SingleRelationTool")
relations = [relation]

ango_sdk.create_label_set(project_id=project_id,
                          tools=tools,
                          classifications=classifications,
                          relations=relations)

Creating an ontology with:

  • A Single Dropdown classification called "Entity Type" with the choices "Vehicle" and "Person"

  • Another Single Dropdown classification nested inside the first unconditionally (that is, any choice in the first dropdown will open this second) named "Position" with the choices "On Road" and "Off Road".

from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ToolCategory, ClassificationCategory, RelationCategory, LabelOption, Classification, Tool, Relation
import json
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(API_KEY)

nestedClassInDropdown = ClassificationCategory(Classification.Single_dropdown,
                                               title="Position",
                                               options=[LabelOption('On Road'),
                                                        LabelOption('Off Road')]
                                               )

dropdown = ClassificationCategory(Classification.Single_dropdown,
                                  title="Entity Type",
                                  options=[LabelOption('Vehicle'),
                                           LabelOption('Person')],
                                  classifications=[nestedClassInDropdown],
                                  required=True
                                  )

classifications = [dropdown]

print(ango_sdk.create_label_set(
    project_id=PROJECT_ID,
    classifications=classifications)
)

Creating an ontology with:

  • A Tree Dropdown tool with:

    • A root

      • With a "tree0" branch

        • With a "subtree0" leaf

        • With a "subtree1" leaf

      • With a "tree1" leaf

from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, LabelOption, Classification, Tool, Relation, TreeOption
import json
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(API_KEY)

subTree0 = TreeOption(title="subtree0")
subTree1 = TreeOption(title="subtree1")
tree0 = TreeOption(title="tree0", children=[subTree0, subTree1])
tree1 = TreeOption(title="tree1")

treeTool = ClassificationCategory(
    classification=Classification.Tree_dropdown,
    title="Tree One",
    treeOptions=[tree0, tree1]
)

ango_sdk.create_label_set(
    project_id=PROJECT_ID,
    classifications=[treeTool]
)

Creating an ontology with:

  • A radio classification tool with two possible answers, "Radio Option 1" and "Radio Option 2"

  • A conditionally nested Text classification tool using the rich text editor, which only appears if the labeler clicks on "Radio Option 1" (here, parentOptionId links the text tool to the option which reveals it)

from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, LabelOption, Classification, Tool, Relation, TreeOption
import json
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(API_KEY)

radio1 = LabelOption(
    value="Radio Option 1",
    schemaId="radioOption1SchemaId"
)
radio2 = LabelOption(
    value="Radio Option 2"
)

conditionalText = ClassificationCategory(
    classification=Classification.Text,
    title="Text Tool",
    parentOptionId="radioOption1SchemaId",
    color="#333333",
    richText=True
)

radio = ClassificationCategory(
    classification=Classification.Radio,
    title="Radio Classification",
    options=[radio1, radio2],
    classifications=[conditionalText]
)

res = ango_sdk.create_label_set(
    project_id=CREATE_SCHEMA_PROJECT_ID,
    classifications=[radio]
)

Creating an ontology with:

  • A radio classification tool with the possible answers "Radio Answer 1" and "Radio Answer 2"

  • A Tree Dropdown classification tool which only appears if the annotator clicks on "Radio Answer 1"

    • The Tree Dropdown has a main root

      • With a branch called "Branch 1"

        • With leaves called "Leaf 1" and "Leaf 2"

      • With a leaf called "Leaf 3"

leaf1 = TreeOption(
    title="Leaf 1"
)

leaf2 = TreeOption(
    title="Leaf 2"
)
branch1 = TreeOption(
    title="Branch 1",
    children=[leaf1, leaf2]
)

leaf3 = TreeOption(
    title="Leaf 3"
)

treeTool = ClassificationCategory(
    classification=Classification.Tree_dropdown,
    title='tree',
    treeOptions=[branch1, leaf3],
    parentOptionId="radioOptionSchemaId"
)

radio1 = LabelOption(
    value="Radio Answer 1",
    schemaId="radioOptionSchemaId"
)

radio2 = LabelOption(
    value="Radio Answer 2"
)

radio = ClassificationCategory(
    classification=Classification.Radio,
    title='radio',
    classifications=[treeTool],
    options=[radio1, radio2]
)

res = ango_sdk.create_label_set(
    project_id="639879404e2aa4e134db0c48",
    classifications=[radio]
)

create_project(name, description)

Creates a new project.

Parameters:

  • name: string

    • The name of the project to be created. This field cannot be empty.

    • Example: 'Project One'

  • description: string, optional, default ""

    • Example: 'Vehicle Classification Project'

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
ango_sdk = SDK(api_key)

res = ango_sdk.create_project(
    name="Created from SDK",
    description="I created this from the SDK."
)

print(res)

Returns:

{
  "status": "success",
  "data": {
    "project": {
      "aiAssistance": {
        "cocoRelations": []
      },
      "description": "I created this from the SDK.",
      "categorySchema": {
        "tools": [],
        "classifications": [],
        "relations": []
      },
      "consensusCount": 1,
      "benchmark": false,
      "deleted": false,
      "reviewConf": {
        "filters": []
      },
      "batches": [],
      "_id": "PROJECT ID",
      "name": "Created from SDK",
      "user": "USER ID OF PROJECT CREATOR",
      "organization": "ORGANIZATION ID",
      "createdAt": "2022-12-13T13:28:34.479Z",
      "assignedTo": [],
      "tags": [],
      "__v": 0
    }
  }
}

export(project_id, assignees, completed_at, updated_at, batches)

Export annotated assets together with labels and metadata. Use assignee, completed_at, updated_at or batch filters to export specific parts of the dataset.

Parameters:

  • project_id: string

    • ID of the project which will be exported. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • assignees: List[string], optional, default None

    • You may filter your export by only obtaining tasks completed by certain users. Enter your User IDs here. User IDs can be obtained with get_project.

    • Example: ['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']

  • completed_at: List[datetime.datetime], optional, default None

    • You may obtain only tasks completed between two specific dates.

    • Example, to only export tasks completed from December 1st to today: [datetime.datetime.fromisoformat("2022-12-01"), datetime.datetime.now()]

  • updated_at: List[datetime.datetime], optional, default None

    • You may obtain only tasks updated between two specific dates.

    • Example, to only export tasks updated from December 1st to today: [datetime.datetime.fromisoformat("2022-12-01"), datetime.datetime.now()]

  • batches: List[string], optional, default None

    • You may choose to only export assets pertaining to one or more specific batches.

    • Example: ['0000000aa0a00a0000aaaa0a']

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

ango_sdk.export(project_id)

exportV3(project_id, batches, stage, format, type, zip_file_path, filters)

Export annotated assets together with labels and metadata. Use batch or stage filters to export specific parts of the dataset.

Parameters:

  • project_id: string

    • ID of the project which will be exported. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • batches: List[string], optional, default None

    • You may choose to only export assets pertaining to one or more specific batches.

    • Example: ['0000000aa0a00a0000aaaa0a']

  • stage: List[string], optional, default None

    • You may choose to only export assets pertaining to one or more specific stages.

    • Example: ['Complete']

  • format: string, default "json", {"json", "ndjson"}

    • Select the format of the export output

    • Example: "ndjson"

  • type: string, optional, default None, {"issue"}

    • You may choose to only export issues by passing type="issue".

  • zip_file_path: string, optional, default None

    • If included, the export will be directly downloaded as a .zip file instead of being returned as a Python dictionary. This prevents our server from having to unzip and dict-ify the export, reducing loading times.

    • Example: "/Users/lorenzo/Downloads/my_export.zip"

  • filters: Dict{string:string}

    • You may filter the export by including a filters dict here.

    • If you do not include it, by default, the export will not be filtered and it will contain all information.

    • Here is what you can include in the filters dict (picking true or false as necessary):

filters = {
    'sendEmail': 'false',
    'includeMetadata': 'false',
    'includeHistory': 'false',
    'includeSegmentationPoints': 'true',
}

Returns:

  • output: dict

get_assets(project_id, asset_id, external_id, page, limit, filters)

Get details of assets from a project.

Parameters:

  • project_id: string

    • ID of the project of which the assets will be obtained. Project IDs can be procured from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • asset_id: string, Optional, default None

  • external_id: string, Optional, default None

  • page: integer, default 1

  • limit: integer, default 10

  • filters: dict

    • By default, all assets will be returned. By including a dict filter here, you may filter the assets you receive.

    • Here is a list of possible filters you may pass in the filters dict:

{
    _id : str, # A specific Asset ID to get.
    externalId: str, # A specific externalId to get.
    isPreLabeled: bool,
    batches: ["<batch_id_1>", "<batch_id_2>"] # When including multiple batches, only the assets belonging to BOTH (all) batches will be returned. This is an "AND" operation.
    createdAt: {"gt": "<ISO_TIME_STR>"}, # gt: Greater Than (after), lt: Less Than (before), ISO_TIME_STR example: 2002-12-09T00:00:00.000Z
    createdAt: {"lt": "<ISO_TIME_STR>"}
}

Returns:

  • output: dict

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

sdk_response = ango_sdk.get_assets(project_id)

data_url = sdk_response['data']['assets'][0]['data']
external_id = sdk_response['data']['assets'][0]['externalId']
from imerit_ango.sdk import SDK
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

items_per_page = 100
max_limit = None

assets = []
page = 1
remaining_tasks = 1
while remaining_tasks > 0:
    response =  ango_sdk.get_assets(project_id, page=page, limit=items_per_page)
    assets.extend(response['data']['assets'])
    remaining_tasks = response["data"]["total"] - len(assets)
    page += 1
    if max_limit:
        if len(assets) >= max_limit:
            assets = assets[:max_limit]
            break

print(len(assets))

get_metrics(project_id, metric)

Get metrics from a project.

Parameters:

  • project_id: string

    • ID of the project of which the assets will be obtained. Project IDs can be procured from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • metric: imerit_ango.sdk.Metrics

    • The metric you wish to obtain, from:

      • imerit_ango.sdk.

        • LabelStageGroups

        • TimePerTask

        • AnnotationStatus

        • AnswerDistribution

        • ConsensusRanges

        • AssetSize

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

output = ango_sdk.get_metrics(project_id=project_id, metric=Metrics.TimePerTask)

get_batches(project_id)

Get details of all batches in a project.

Parameters:

  • project_id: string

    • ID of the project to download the batches of. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

output = ango_sdk.get_batches(project_id=project_id)

Outputs:

[
  {
    "_id": "<BATCH_ID>",
    "name": "Batch Name 1"
  },
  {
    "_id": "<BATCH_ID>",
    "name": "Batch Name 2"
  }
]

get_project(project_id)

Get details of a project.

Objects available within the response returned by this function:

response['data']['project']['<one of the below>']

aiAssistance, description, categorySchema, consensusCount, benchmark, deleted, reviewConf, batches, _id, name, user, organization, createdAt, assignedTo, tags, __v, role

Parameters:

  • project_id: string

    • ID of the project to download the details of. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

sdk_response = ango_sdk.get_project(project_id)

project_name = sdk_response['data']['project']['name']
project_description = sdk_response['data']['project']['description']
project_creation_time = sdk_response['data']['project']['createdAt']
project_ontology = sdk_response['data']['project']['categorySchema']

print(project_name)
print(project_description)
print(project_creation_time)
print(project_ontology)

Outputs:

<Project Name>
<Project Description>
2000-01-01T00:00:00.000Z
{'tools': [...], 'classifications': [...], 'relations': [...]}

get_storages()

Get all storages of the current organization.

Parameters:

  • None

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
ango_sdk = SDK(api_key)

sdk_response = ango_sdk.get_storages()
storagess_list = sdk_response['data']['storages']

Outputs:

{
  "status": "success",
  "data": {
    "storages": [
      {
        "id": "<STORAGE ID>",
        "name": "<STORAGE NAME>",
        "provider": "GCP",
        "createdAt": "2022-11-24T13:48:32.100Z",
        "organization": "<ORGANIZATION ID>"
      }
    ]
  }
}

get_task(task_id)

Get information on a task

Parameters:

  • task_id: string

    • ID of the task the information of which will be downloaded. Task IDs can be obtained from the UI and from get_tasks.

    • Example: '0000000aa0a00a0000aaaa0a'

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
ango_sdk = SDK(api_key)

sdk_response = ango_sdk.get_task('<YOUR TASK ID>')

data_url = sdk_response['data']['task']['asset']['data']
external_id = sdk_response['data']['task']['asset']['externalId']

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

    • ID of the project to download the tasks of. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

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

  • stages: 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:

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

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']
from imerit_ango.sdk import SDK
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

items_per_page = 100
annotation_status = None
max_limit = None

tasks = []
page = 1
remaining_tasks = 1
while remaining_tasks > 0:
    response =  ango_sdk.get_tasks(project_id, page=page, limit=items_per_page, status=annotation_status)
    tasks.extend(response['data']['tasks'])
    remaining_tasks = response["data"]["total"] - len(tasks)
    page += 1
    if max_limit:
        if len(tasks) >= max_limit:
            tasks = tasks[:max_limit]
            break

print(len(tasks))

get_task_history(id, task_id)

Get the stage history of a task.

Parameters:

  • id: string, optional, default None

    • Optionally, the ID of the stage history item.

    • For example, if you run this function on a task without passing id, assuming the task has been through 6 stages, you will receive a list with 6 objects. Each of these objects has its own _id value. If you pass this _id value as the id parameter, you can filter out all tak stage history items and only return the one with this specific ID.

    • Example: '0000000aa0a00a0000aaaa0a'

  • task_id: string

    • ID of the task to get the history of. Task IDs can be obtained from the UI, and from get_tasks.

    • Example: '0000000aa0a00a0000aaaa0a'

Returns:

  • output: dict

Sample output:

{
  "status": "success",
  "data": {
    "taskHistory": {
      "answer": {
        "tools": [
          {
            "bounding-box": {
              "x": 1094.0928805593353,
              "y": 929.222117890566,
              "height": 112.31541717796104,
              "width": 242.29578986936937
            },
            "objectId": "68174969c44e1ef63301642",
            "classifications": [],
            "schemaId": "a3f7ff90ae260c29132f063",
            "metadata": {
              "createdAt": "2023-05-04T08:14:14.642Z",
              "createdBy": "lorenzo@ango.ai",
              "createdIn": "Label"
            },
            "title": "Amount"
          }
        ],
        "classifications": [],
        "relations": []
      },
      "deleted": false,
      "rework": false,
      "batches": [],
      "isSkipped": false,
      "_id": "6464b15e4ea9720015801e07",
      "labelTaskId": "6453677fc47af30015be5a58",
      "createdAt": "2023-05-04T08:06:23.734Z",
      "project": "645240ed462db80015ce881f",
      "organization": "64461ed038dcad0015cc2049",
      "asset": "6453677fc47af30015be5a57",
      "stage": "77dc1c42-6fef-4745-b783-d6c4d99204e1",
      "duration": 1681,
      "updatedAt": "2023-05-17T10:50:06.211Z",
      "updatedBy": "lorenzo@ango.ai",
      "assignee": "lorenzo@ango.ai",
      "brushDataUrl": null,
      "__v": 0
    }
  }
}

import_labels(project_id, labels)

Import labels to the project. More details on importing existing labels to Hub here.

You can only import annotations for tasks in the Start stage.

Please ensure the assets you are trying to annotate as in the Start stage of your project before continuing.

Parameters:

  • project_id: string

    • ID of the project where to import labels. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • labels: List[dict]

    • List of labels to import. See more on our label format here: Ango Annotation Format and learn more about importing labels into Ango Hub here.

    • Example:

[
  {
    "externalId": "Test Pattern 844x844.png",
    "objects": [
      {
        "schemaId": "8f60cb0209a4d80f9add122",
        "title": "bbb",
        "bounding-box": {
          "width": 86,
          "height": 86,
          "x": 83,
          "y": 83
        }
      },
      {
        "schemaId": "8f60cb0209a4d80f9add122",
        "title": "bbb",
        "bounding-box": {
          "width": 167,
          "height": 167,
          "x": 338,
          "y": 338
        }
      },
      {
        "schemaId": "8f60cb0209a4d80f9add122",
        "title": "bbb",
        "bounding-box": {
          "width": 84,
          "height": 84,
          "x": 675,
          "y": 675
        }
      }
    ]
  }
]

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')

ango_sdk = SDK(api_key)

schema_id = '<Schema ID of Car Class>'
annotations = [{"externalId": "10001.png",
                "objects": [{"schemaId": schema_id,
                             "title": 'Car',
                             "bounding-box": {"x": 20, "y": 30, "width": 50, "height": 60}}]
               }]

ango_sdk.import_labels(project_id, annotations)

See also

export

list_projects(page, limit)

Lists projects from the current users' organization.

Projects are paginated. A maximum of 1000 projects can be obtained per page. See the second code example for more on how it works.

Parameters:

  • page: int, default 1

    • Current page.

    • Example: 1

  • limit: int, default 10, maximum 1000

    • Number of projects per page.

    • Example: 100

Returns:

  • output: dict

Example:

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

api_key = os.getenv('api_key')
ango_sdk = SDK(api_key)

sdk_response = ango_sdk.list_projects()
project_list = sdk_response['data']['projects']

project_list[0]
from imerit_ango.sdk import SDK
from dotenv import load_dotenv
import os

api_key = os.getenv('api_key')
ango_sdk = SDK(api_key)

items_per_page = 50
max_limit = None

project_list = []
page = 1
remaining_tasks = 1
while remaining_tasks > 0:
    response = ango_sdk.list_projects(page=page, limit=items_per_page)
    project_list.extend(response['data']['projects'])
    remaining_tasks = response["data"]["total"] - len(project_list)
    page += 1
    if max_limit:
        if len(project_list) >= max_limit:
            project_list = project_list[:max_limit]
            break

print(len(project_list))

Outputs:

{'_id': '000000000000000000000000',
 'name': 'Project Name',
 'description': 'Project Description',
 'organization': ‘000000000000000000000000',
 'createdAt': '2000-01-01T00:00:00.000Z'}

update_workflow_stages(project_id, stages)

Update the workflow of your project.

Parameters:

  • project_id: string

    • ID of the project where priority will be set. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • stages: List[dict], default []

    • The workflow of the project, in JSON format. For example:

      stages = [
          {
              "next": [
                  "Label"
              ],
              "id": "Start",
              "type": "Start",
              "name": "Start"
          },
          {
              "assignedTo": [],
              "next": [
                  "Complete"
              ],
              "pluginConfig": [],
              "id": "Label",
              "type": "Label",
              "name": "Label"
          },
          {
              "id": "Complete",
              "type": "Complete",
              "name": "Complete",
              "next": []
          }
      ]

To get an idea of what you can pass as input in Stages, you may create a workflow in a project, then run

ango.sdk.SDK.get_project(<YOUR_PROJECT_ID>).get("data").get("project").get("stages")

As the returned JSON, you'll get the JSON representation of the project's workflow, which you can use as skeleton to create your own workflow JSONs.

Returns:

  • output: dict

upload_files(project_id, file_paths, storage_id, batches)

Upload files to Ango Hub. A list of local file paths should be given as an input parameter.

Optionally, a custom externalID for the files may be given from within the file_paths parameter. (See examples below)

Parameters:

  • project_id: string

    • ID of the project where priority will be set. Project IDs can be obtained from the UI and from list_projects.

    • Example: '0000000aa0a00a0000aaaa0a'

  • file_paths: List[string]

    • List containing absolute paths to files and, optionally, their contextData.

    • Example:

[
    {
        'data': '/Users/lorenzo/Desktop/Gassino,_arrival_of_tramway_auto_x2.jpg',
        'metadata': {
            "width": 1500,
            "height": 1200
        },
        'contextData': {
                'key1': 'value1'
        }
    }
]
  • storage_id: string, Optional

    • This parameter has no function anymore and will be deprecated in the next version of the SDK.

  • batches: List[string], Optional

    • You may assign the files you are uploading to one or more batches that exist in your project by providing their IDs here. You may create new batches with create_batch and you can get a list of batches with get_batches.

    • Example: ['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']

Returns:

  • output: dict

Example:

Importing two local files:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

file_paths = ["data/my_image_1.png", "data/my_image_2.png"]
ango_sdk.upload_files(project_id, file_paths)

Importing a file with a custom external ID:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key)

file_paths = [
    {"data": "/Users/lorenzo/test.jpg", "externalId": "custom!"}
]
ango_sdk.upload_files(project_id, file_paths)

upload_files_cloud(project_id, assets, storage_id, batches)

Import files in cloud storage to Ango Hub. Check Importing Assets for more information.

Parameters:

  • project_id: string

    • The ID of the project where you'd like to add files.

    • Example: '0000000aa0a00a0000aaaa0a'

  • assets: List[string]

    • A list of asset dictionaries in the [{"data": <URL>, "externalId": "<external_id>"}] format.

    • Assets uploaded with this method can also contain attachments, batches, metadata, and contextData. For example:

public_file = [
    {
        "data": "https://angohub-public-assets.s3.eu-central-1.amazonaws.com/CzXTtJV.jpg",
        "externalId": "aws-public.png",
        "metadata": {
            "width": 1500,
            "height": 1800
        },
        "contextData": {
            "key1": "value1"
        },
        "batches": ["Batch 1", "Batch 2"]
        "attachments": [
            {'type': "IMAGE", 'value': "https://angohub-public-assets.s3.eu-central-1.amazonaws.com/CzXTtJV.jpg"},
            {'type': "TEXT", 'value': "An attachment."}]
    }
]

For image and video attachments, you may provide links to assets in private buckets, provided that you've connected them to Ango Hub. More information on how to do so can be found in the Attachments page.

For Markdown assets, you may directly include the Markdown file as plain text in the data field, like so:

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

project_id = "<YOUR PROJECT ID>"
api_key = "<YOUR API KEY>"
HOST = "<HOST>"


external_id = "100001.md"
batch_name = "Batch-1"

markdown_text = "
<div style="margin:10px;display:flex;">
	<div style="width:50%">
		<div style="font-size:13px;font-weight:500;display:flex;">
			<div style="width:100px;color:gray">Hello World!</div>
		</div>
	</div>
</div>"


sdk = SDK(api_key=api_key, host=HOST)

file_paths = []
file_paths.append({"data": markdown_text, "externalId": external_id, "batches": [batch_name]})

response = sdk.upload_files_cloud(project_id=project_id, assets=file_paths)

Batches you specify in the assets dictionary will override the batches you specify in the batches parameter of this function.

Returns:

  • output: dict

Examples:

Importing a file from a public bucket, and assigning it to a batch:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
batch_id_list = ['<YOUR BATCH ID>']
ango_sdk = SDK(api_key)

public_file = [
    {
        "data": "https://storage.googleapis.com/a-public-bucket/file.png",
        "externalId": "myExternalId.png"
    }
]

ango_sdk.upload_files_cloud(
    project_id=project_id,
    assets=public_file,
    batches=batch_id_list
)

Importing a file from a private bucket, and assigning it to multiple batches:

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

api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
batch_id_list = ['<BATCH ID 1>', '<BATCH ID 2>']
storage_id = '<YOUR_STORAGE_ID>' # Obtain with get_storages, mandatory when importing files from private buckets
ango_sdk = SDK(api_key)

private_file = [
    {
        "data": "https://storage.googleapis.com/a-private-bucket/file.png",
        "externalId": "myExternalId.png"
    }
]

ango_sdk.upload_files_cloud(
    project_id=project_id,
    assets=public_file,
    batches=batch_id_list,
    storage_id=storage_id
)

Organization Level SDK Functions (v1.3.10)

imerit_ango.sdk.SDK.

create_storage(storage_data)

Create storage

Parameters:

  • storage_data: Storage

    • Storage

      • name: string

      • provider: StorageProvider

      • public_key: string

      • private_key: string

      • credentials: string

    • StorageProvider

      • {AWS, GCP, AZURE}

Returns:

  • output: dict

Example:

from imerit_ango.sdk import SDK
from imerit_ango.models.storage import Storage
from imerit_ango.models.enums import StorageProvider
from dotenv import load_dotenv
import os

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

sdk_response = ango_sdk.create_storage(Storage(name="My Storage",
                                               provider=StorageProvider.AWS,
                                               public_key='<YOUR PUBLIC KEY>',
                                               private_key='<YOUR PRIVATE KEY>',
                                               region="eu-central-1",
                                               credentials='<YOUR CREDENTIALS>'))

delete_organization_invites(organization_id, invite_emails)

Delete organization invites

Parameters:

  • organization_id: string

  • invite_emails: List[string]

Returns:

  • output: dict

Example:

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

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

organization_id = '<YOUR ORGANIZATION ID>'
sdk_respose = ango_sdk.delete_organization_invites(organization_id=organization_id, 
                                                   invite_emails=["user@example.com"])

delete_organization_members(organization_id, member_ids)

Delete organization members

Parameters:

  • organization_id: string

  • member_ids: List[string]

Returns:

  • output: dict

Example:

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

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

organization_id = '<YOUR ORGANIZATION ID>'
ango_sdk.delete_organization_members(organization_id=organization_id, 
                                     member_ids=["user1@example.com", "user2@example.com"])

delete_storage(storage_id)

Delete storage

Parameters:

  • storage_id: string

Returns:

  • output: dict

Example:

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

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

storage_id = '<YOUR STORAGE ID>'

ango_sdk.delete_storage(storage_id=storage_id)

get_organization_invites(organization_id)

Get organization invites

Parameters:

  • organization_id: string

Returns:

  • output: dict

Example:

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

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

organization_id = '<YOUR ORGANIZATION ID>'
sdk_response = ango_sdk.get_organization_invites(organization_id=organization_id)
invites = sdk_response['data']['invites']

get_organization_members(organization_id)

Get organization members

Parameters:

  • organization_id: string

Returns:

  • output: dict

Example:

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

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

organization_id = '<YOUR ORGANIZATION ID>'
sdk_response = ango_sdk.get_organization_members(organization_id=organization_id)
members = sdk_response["data"]["users"]

invite_members_to_org(organization_id, invite_data)

Invite members to organization

Parameters:

  • organization_id: string

  • invite_data: Invitation

    • Invitation

      • organizationRole: OrganizationRoles

      • projectId: string

      • projectRole: ProjectRoles

    • OrganizationRoles

      • {Member, Admin}

    • ProjectRoles

      • {Manager, Labeler, Reviewer, Lead}

Returns:

  • output: dict

Example:

from imerit_ango.sdk import SDK
from imerit_ango.models.invite import Invitation
from imerit_ango.models.enums import OrganizationRoles, ProjectRoles
from dotenv import load_dotenv
import os

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
project_id = os.getenv('project_id')
ango_sdk = SDK(api_key, host=HOST)

organization_id = '<YOUR ORGANIZATION ID>'
ango_sdk.invite_members_to_org(organization_id=organization_id, 
                               invite_data=Invitation(to=["user@example.com"],
                                                      organizationRole=OrganizationRoles.Member,
                                                      projectId=project_id,
                                                      projectRole=ProjectRoles.Labeler))

update_organization_members_role(organization_id, role_updates))

Update organization members role

Parameters:

  • organization_id: string

  • role_updates: List[RoleUpdate]

    • RoleUpdate

      • email: string

      • organizationRole: OrganizationRoles

    • OrganizationRoles

      • {Member, Admin}

Returns:

  • output: dict

Example:

from imerit_ango.sdk import SDK
from imerit_ango.models.invite import RoleUpdate
from imerit_ango.models.enums import OrganizationRoles
from dotenv import load_dotenv
import os

HOST = '<YOUR HOST>'
api_key = os.getenv('api_key')
ango_sdk = SDK(api_key, host=HOST)

organization_id = '<YOUR ORGANIZATION ID>'
role_update_1 = RoleUpdate(email="user1@example.com", organizationRole=OrganizationRoles.Admin)
role_update_2 = RoleUpdate(email="user2@example.com", organizationRole=OrganizationRoles.Admin)

sdk_response = ango_sdk.update_organization_members_role(organization_id=organization_id,
                                                         role_updates=[role_update_1, role_update_2])

Last updated