Supervisely Python SDK

6.73.556 · active · verified Sun Apr 12

Supervisely SDK for Python (pypi-slug: supervisely) provides Python wrappers to programmatically interact with the Supervisely computer vision platform. It simplifies tasks like data management, annotation, model training, and deployment. The library is actively maintained with very frequent releases, often daily or weekly, reflecting continuous development and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish an API connection to the Supervisely platform using recommended authentication practices via environment variables and verifies the connection by listing available teams. For production, always use environment variables for secrets.

import os
import supervisely as sly

# It is highly recommended to set SERVER_ADDRESS and API_TOKEN as environment variables.
# For Community Edition, SERVER_ADDRESS is typically 'https://app.supervisely.com'
# For Enterprise Edition, use your custom instance address.
SERVER_ADDRESS = os.environ.get('SERVER_ADDRESS', 'https://app.supervisely.com')
API_TOKEN = os.environ.get('API_TOKEN', 'YOUR_SUPERVISELY_API_TOKEN_HERE') # Replace with your actual token or ensure env var is set

# Initialize API client from environment variables (recommended)
# For local development, you might use a .env file loaded with dotenv.
# See: https://developer.supervisely.com/getting-started/basics-of-authentication
try:
    api = sly.Api(server_address=SERVER_ADDRESS, token=API_TOKEN)
    
    # Test authentication by fetching teams
    my_teams = api.team.get_list()
    print(f"Successfully connected to Supervisely. You are a member of {len(my_teams)} team(s).")
    
    if my_teams:
        team = my_teams[0]
        print(f"First team: {team.name} (ID: {team.id})")
        workspaces = api.workspace.get_list(team.id)
        if workspaces:
            print(f"First workspace in team '{team.name}': {workspaces[0].name} (ID: {workspaces[0].id})")
        else:
            print(f"No workspaces found in team '{team.name}'.")
    else:
        print("No teams found for the provided API token. Please check your credentials and permissions.")

except Exception as e:
    print(f"Error connecting to Supervisely API: {e}")
    print("Please ensure SERVER_ADDRESS and API_TOKEN environment variables are correctly set.")

view raw JSON →