Table of Contents

Getting started

Alex Cota Updated by Alex Cota


We created this Python SDK so you can access all the functionalities of the Labelbox API without having to write GraphQL queries. This documentation will guide you through installation, setup, and some common use cases.

See the Python SDK repo in Github.

We released v2.4 on January 30, 2020. Run pip install --upgrade labelbox to upgrade (please consult the Changelog before upgrading). The Python SDK supports Python versions 3.6 and 3.7.

Installation & authentication

Step 1 Create your API key

All users wishing to access the Python SDK must have an API key for authentication. For instructions on creating a key, see API keys.

Step 2 Install

Install Labelbox using pip.

user@machine:~$ pip install labelbox
Step 3 Authenticate

In the command line, pass your API key as an environment variable and open the Python interpreter.

user@machine:~$ export LABELBOX_API_KEY="<your_api_key>"
user@machine:~$ python3

Then, import and initialize the API Client.

from labelbox import Client
client = Client()

Passing in a custom endpoint is only applicable for on-premises use cases. If this applies to you, you may pass the API key and server endpoint explicitly when you initialize the Client object. Otherwise, refer to the step above.

from labelbox import Client
client = Client("<your_api_key_here>", "")

Python script

Here is a Python snippet you can also use to connect to the API. Run this as a python script and make sure to include your API key within quotations since the expected data type for the API key is a string.

from labelbox import Client

if __name__ == '__main__':
    API_KEY = "<your_api_key_here>"
    client = Client(API_KEY)
Step 4 Create a project

Refer to Creating your first project for an end-to-end example.

Was this page helpful?

Creating your first project