The Python SDK allows you to access all of the functionalities of the Labelbox API without having to use GraphQL.

Requirements

  • Make sure pip is installed.

  • Create your API key in the Account section in your Labelbox account.

  • Save your API key somewhere as it will be hidden afterward.

Install/upgrade

To install, run pip install labelbox in your command line.

To upgrade, consult the changelog and run pip install --upgrade labelbox. See the Python SDK in Github.

Authentication

There are 3 ways to set up authentication with Labelbox.

Option 1

Pass your API key as an environment variable in the command line.

[email protected]:~$ export LABELBOX_API_KEY="<your_api_key>"
[email protected]:~$ python3

Then, import and initialize the API Client.

from labelbox import Client
client = Client()

Option 2

Pass a custom endpoint. This 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 Option 1.

from labelbox import Client

client = Client("<your_api_key_here>", "https://app.your-domain.com/api/graphql")

Option 3

Run this Python script and pass your API key as a string.

from labelbox import Client

if __name__ == '__main__':
    API_KEY = "<your_api_key_here>"
    client = Client(API_KEY)