Getting started

Installation

SuperAnnotate Python SDK is available on PyPI. Use the following command on your terminal to install our SDK.

pip install superannotate

The latest version supports Python 3.7 + and was tested under Linux and Windows platforms.

Authorization

The SDK functions work within the team scope of SuperAnnotate's platform, so a team-level authorization is required.

To authorize SDK in a team scope, follow these steps:

  1. Get the Python SDK authorization token from the Team Settings page.
  2. Run superannotatecli init in the terminal and plug the token to authorize SDK. This will create a configuration file with the token in a default location (~/.superannotate/config.json).
superannotatecli init
Input the team SDK token from https://app.superannotate.com/[your team id]/team/details
SA-PYTHON-SDK - INFO - Configuration file ~/.superannotate/config.json successfully created.

To authenticate SDK with a custom config file, create a custom JSON file with the key token and use it for authentication:

import json

token_path = "./config.json"
token = "<your_sdk_token>"

with open(token_path, "w") as tf:
    json.dump({"token": token}, tf)

To get started, import superannotate and SAClient:

import superannotate
from superannotate import SAClient

Class SAClient

Create the SAClient instance to authorize SDK in a team scope. If no argument is provided, the SA_TOKEN environmental variable will be automatically checked, or $HOME/.superannotate/config.json will be used.

# To instantiate SAClient using the team token:

team_1 = SAClient(
    token = "48c828b33e1a2a92fcdfccd54ecfebde1a1b787c741dd34935fe6c00430d80e78156c181c6e79759t=12759"
)

# To instantiate SAClient using the path to the config file that contains the team token:
team_1 = SAClient(config_path = "~/.superannotate/config.json")

# No arguments:

team_1 = SAClient()

To get the name of the team you've instantiated the instance for:

team_1.get_team_metadata()['name']

To create an SAClient instance for another team in parallel (using another config.json file/token):

team_2 = SAClient(config_path = "~/.superannotate/2_config.json")

To get the name of the other team you've instantiated an SAClient for:

team_2.get_team_metadata()['name']

Did this page help you?