Skip to main content

Official Box Python Generated SDK

Project description

“box-dev-logo”

Box Python SDK GENERATED

Project Status build PyPI version image Platform Coverage

We are excited to introduce the stable release of the latest generation of Box Python SDK, designed to elevate the developer experience and streamline your integration with the Box Content Cloud.

With this SDK, you’ll have access to:

  1. Full API Support: The new generation of Box SDKs empowers developers with complete coverage of the Box API ecosystem. You can now access all the latest features and functionalities offered by Box, allowing you to build even more sophisticated and feature-rich applications.
  2. Rapid API Updates: Say goodbye to waiting for new Box APIs to be incorporated into the SDK. With our new auto-generation development approach, we can now add new Box APIs to the SDK at a much faster pace (in a matter of days). This means you can leverage the most up-to-date features in your applications without delay.
  3. Embedded Documentation: We understand that easy access to information is crucial for developers. With our new approach, we have included comprehensive documentation for all objects and parameters directly in the source code of the SDK. This means you no longer need to look up this information on the developer portal, saving you time and streamlining your development process.
  4. Enhanced Convenience Methods: Our commitment to enhancing your development experience continues with the introduction of convenience methods. These methods cover various aspects such as chunk uploads, classification, and much more.
  5. Seamless Start: The new SDKs integrate essential functionalities like authentication, automatic retries with exponential backoff, exception handling, request cancellation, and type checking, enabling you to focus solely on your application's business logic.

Embrace the new generation of Box SDKs and unlock the full potential of the Box Content Cloud.

Table of contents

Installing

pip install box-sdk-gen

This is autogenerated Box SDK version. Supported Python versions are Python 3.8 and above.

To install also extra dependencies required for JWT authentication, use command:

pip install "box-sdk-gen[jwt]"

Getting Started

To get started with the SDK, get a Developer Token from the Configuration page of your app in the Box Developer Console. You can use this token to make test calls for your own Box account.

The SDK provides an BoxDeveloperTokenAuth class, which allows you to authenticate using your Developer Token. Use instance of BoxDeveloperTokenAuth to initialize BoxClient object. Using BoxClient object you can access managers, which allow you to perform some operations on your Box account.

The example below demonstrates how to authenticate with Developer Token and print names of all items inside a root folder.

from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth

def main(token: str):
    auth: BoxDeveloperTokenAuth = BoxDeveloperTokenAuth(token=token)
    client: BoxClient = BoxClient(auth=auth)
    for item in client.folders.get_folder_items('0').entries:
        print(item.name)

if __name__ == '__main__':
    main('INSERT YOUR DEVELOPER TOKEN HERE')

Documentation

Browse the docs or see API Reference for more information.

Upgrades

Upgrading from our legacy SDKs to the new generation SDKs is a straightforward process. See our migration guide and changelog for more information.

Integration Tests

Running integration tests locally

Create Custom Application

To run integration tests locally you will need a Custom App created in the Box Developer Console with Server Authentication (with JWT) selected as authentication method. Once created you can edit properties of the application:

  • In section App Access Level select App + Enterprise Access. You can enable all Application Scopes.
  • In section Advanced Features enable Make API calls using the as-user header and Generate user access tokens.

Now select Authorization and submit application to be reviewed by account admin.

Export configuration

  1. Select Configuration tab and in the bottom in the section App Settings download your app configuration settings as JSON.
  2. Encode configuration file to Base64, e.g. using command: base64 -i path_to_json_file
  3. Set environment variable: JWT_CONFIG_BASE_64 with base64 encoded jwt configuration file
  4. Set environment variable: BOX_FILE_REQUEST_ID with ID of file request already created in the user account, BOX_EXTERNAL_USER_EMAIL with email of free external user which not belongs to any enterprise.
  5. Set environment variable: WORKFLOW_FOLDER_ID with the ID of the Relay workflow that deletes the file that triggered the workflow. The workflow should have a manual start to be able to start it from the API.
  6. Set environment variable: APP_ITEM_ASSOCIATION_FILE_ID to the ID of the file with associated app item and APP_ITEM_ASSOCIATION_FOLDER_ID to the ID of the folder with associated app item.

Running tests

To run integration tests locally:

  1. pip install -r requirements-test.txt
  2. pytest

Questions, Bugs, and Feature Requests?

Need to contact us directly? Browse the issues tickets! Or, if that doesn't work, file a new one and we will get back to you. If you have general questions about the Box API, you can post to the Box Developer Forum.

Copyright and License

Copyright 2023 Box, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

box_sdk_gen-1.7.0.tar.gz (217.1 kB view details)

Uploaded Source

Built Distribution

box_sdk_gen-1.7.0-py3-none-any.whl (426.8 kB view details)

Uploaded Python 3

File details

Details for the file box_sdk_gen-1.7.0.tar.gz.

File metadata

  • Download URL: box_sdk_gen-1.7.0.tar.gz
  • Upload date:
  • Size: 217.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.2

File hashes

Hashes for box_sdk_gen-1.7.0.tar.gz
Algorithm Hash digest
SHA256 17c1bd61b4ff1b232804601835d995e98866da4b5a3cdd81cb097a07078bc9a4
MD5 662d0b51c006d6db532a1147639b7625
BLAKE2b-256 712b193ab4ec074b84bdcec5c852e896451707e29dbcc9565600fc2cee2571f2

See more details on using hashes here.

File details

Details for the file box_sdk_gen-1.7.0-py3-none-any.whl.

File metadata

  • Download URL: box_sdk_gen-1.7.0-py3-none-any.whl
  • Upload date:
  • Size: 426.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.2

File hashes

Hashes for box_sdk_gen-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 069fd7590eef18ca8dffa73c2700a7226714ea1374b3a00c7447ca54920355c0
MD5 fe3b9eefe8388da90a24de18c9e11f95
BLAKE2b-256 390c694181df78efc6eda072b07f855938ef1b7be1611f8bd299e561eb065ff2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page