Labelbox Python SDK

7.6.0 · active · verified Wed Apr 15

The Labelbox Python SDK (current version 7.6.0) provides a programmatic interface to interact with the Labelbox platform, enabling users to manage data, projects, labels, and model integrations. It allows for automating data import, export of labeled data, managing labeling projects, and integrating machine learning workflows. The library has a frequent release cadence, with multiple minor versions and bug fixes released throughout the year.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Labelbox Client using an API key stored as an environment variable and then retrieve a list of your projects. Ensure `LABELBOX_API_KEY` is set before running.

import os
from labelbox import Client, Project

# Authenticate with your Labelbox API key
# It is recommended to store your API key as an environment variable
# e.g., export LABELBOX_API_KEY="YOUR_API_KEY"
try:
    client = Client(os.environ.get('LABELBOX_API_KEY'))
    print("Successfully connected to Labelbox.")

    # Example: List your projects
    projects = list(client.get_projects())
    if projects:
        print(f"Found {len(projects)} projects:")
        for project in projects:
            print(f"- {project.name} (ID: {project.uid})")
    else:
        print("No projects found in your workspace.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure your LABELBOX_API_KEY environment variable is set correctly.")

view raw JSON →