Box Python Generated SDK

1.17.0 · deprecated · verified Mon Apr 13

The `box-sdk-gen` library is the official Box Python SDK, designed for rapid API updates and comprehensive coverage of the Box API. However, as of September 17, 2025, this standalone package will no longer receive updates, bug fixes, or new features. Its functionalities have been consolidated into the `boxsdk` package (version 10.0.0 and higher), which now contains the `box_sdk_gen` module. Users are strongly advised to migrate to `boxsdk>=10` for continued support and access to the latest features. The current version is 1.17.0, and the consolidated `boxsdk` maintains a regular release cadence for minor/patch versions every 2-3 months.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate using a Developer Token and fetch information about the current user and list items in the root folder. For production environments, consider more robust authentication methods like OAuth 2.0 or JWT. The developer token should be obtained from your Box Developer Console.

import os
from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth

# It's recommended to set your developer token as an environment variable
# For testing, you can replace os.environ.get with your actual token string
DEVELOPER_TOKEN = os.environ.get('BOX_DEVELOPER_TOKEN', 'YOUR_DEVELOPER_TOKEN')

if not DEVELOPER_TOKEN or DEVELOPER_TOKEN == 'YOUR_DEVELOPER_TOKEN':
    print("Please set the BOX_DEVELOPER_TOKEN environment variable or replace the placeholder.")
else:
    try:
        auth = BoxDeveloperTokenAuth(token=DEVELOPER_TOKEN)
        client = BoxClient(auth=auth)

        # Get information about the current user
        me = client.users.get_user_me()
        print(f"Hello, I'm {me.name} (ID: {me.id}) - Login: {me.login}")

        # List items in the root folder (ID '0')
        print("\nItems in your root folder:")
        root_folder_items = client.folders.get_folder_items('0').entries
        if root_folder_items:
            for item in root_folder_items:
                print(f"  - {item.type.value.capitalize()}: {item.name} (ID: {item.id})")
        else:
            print("  No items found in the root folder.")

    except Exception as e:
        print(f"An error occurred: {e}")
        print("Please ensure your developer token is valid and has the necessary permissions.")

view raw JSON →