Encord Python SDK

0.1.192 · active · verified Thu Apr 16

Encord is an end-to-end platform for AI-assisted annotation, quality control, and data management for computer vision and multimodal AI. The Encord Python SDK client allows programmatic interaction with the Encord API to create automated pipelines and integrate Encord functionalities directly into existing MLOps workflows. The library is currently at version 0.1.192 and is actively maintained with frequent updates, including multiple releases within the last month.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the Encord client using an SSH private key from environment variables (supporting both EMEA and US deployments) and then lists the first 5 accessible datasets. A private key must be generated from the Encord web app and set as an environment variable (ENCORD_KEY or ENCORD_US_KEY).

import os
from encord.user_client import EncordUserClient

# For EMEA clients, use 'ENCORD_KEY'. For US clients, use 'ENCORD_US_KEY'.
# Replace with your actual private key content or set the environment variable.
# Example: export ENCORD_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
private_key = os.environ.get('ENCORD_KEY', os.environ.get('ENCORD_US_KEY', ''))

if not private_key:
    print("Error: Encord private key not found in environment variables (ENCORD_KEY or ENCORD_US_KEY).")
    print("Please set the environment variable or replace the placeholder in the code.")
else:
    try:
        user_client = EncordUserClient.create_with_ssh_private_key(private_key)
        print("Successfully authenticated with Encord.")

        # Example: List up to 5 datasets accessible by the user
        datasets = user_client.list_datasets(page_size=5)
        if datasets:
            print("\nFirst 5 datasets:")
            for ds in datasets:
                print(f"  - {ds.title} (ID: {ds.dataset_hash})")
        else:
            print("No datasets found.")

    except Exception as e:
        print(f"Authentication or API call failed: {e}")

view raw JSON →