Python SDK for Box API with seamless Box Drive integration
Project description
fs-box-sync
Python SDK for Box API with seamless Box Drive integration.
Installation
pip install fs-box-sync
Or with uv:
uv add fs-box-sync
Quick Start
import asyncio
from fs_box_sync import box, BoxConfig
# Configure with your credentials
box.configure(BoxConfig(
client_id='your-client-id',
client_secret='your-client-secret',
))
async def main():
# List files in root folder
files = await box.list_folder_items('0')
for f in files:
print(f"{f.type}: {f.name} ({f.id})")
# Upload a file
file_id = await box.upload_file('folder-id', './local-file.pdf')
# Download a file
await box.download_file('file-id', './downloaded-file.pdf')
# Read file content
content = await box.get_file_content('file-id')
asyncio.run(main())
Architecture
The SDK provides a 3-layer architecture:
BoxFS (High-level filesystem API)
↓
BoxDrive (Sync bridge for local filesystem)
↓
BoxAPI (Pure REST API wrapper)
- BoxAPI: Pure REST API wrapper with token management, retry logic, and chunked uploads
- BoxDrive: Sync bridge for Box Drive local filesystem integration
- BoxFS: High-level filesystem-like API combining both layers
Authentication
Tier 1: Developer Token (Quick Testing)
box.configure(BoxConfig(
access_token='your-developer-token', # Expires in ~1 hour
))
Tier 2: OAuth with Refresh Token (Production)
box.configure(BoxConfig(
client_id='your-client-id',
client_secret='your-client-secret',
refresh_token='your-refresh-token', # Auto-renewing
))
Tier 3: Custom Token Provider (Enterprise)
async def get_token(callback_url: str) -> str:
# Your OAuth automation logic here
return authorization_code
box.configure(BoxConfig(
client_id='your-client-id',
client_secret='your-client-secret',
token_provider=get_token,
))
Box Drive Integration
If Box Drive is installed, you can access files locally:
# Get local path for a Box file
local_path = await box.get_local_path('file-id', 'file')
# Wait for sync and get local path
local_path = await box.get_local_path_synced('file-id', 'file')
# Check if Box Drive is available
if box.is_box_drive_available():
# Open file locally
await box.open_locally('file-id', 'file')
API Reference
File Operations
upload_file(folder_id, file_path)- Upload a filedownload_file(file_id, dest_path)- Download a fileget_file_content(file_id)- Get file content as stringget_file_info(file_id)- Get file metadatadelete_file(file_id)- Delete a filemove_file(file_id, to_folder_id)- Move a file
Folder Operations
list_folder_items(folder_id)- List folder contentsget_folder_info(folder_id)- Get folder metadatacreate_folder_if_not_exists(parent_id, name)- Create foldersearch(folder_id, query)- Search for files/folders
Webhooks
get_all_webhooks()- List all webhookscreate_webhook(folder_id, address)- Create a webhookdelete_webhook(webhook_id)- Delete a webhookdelete_all_webhooks()- Delete all webhooks
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fs_box_sync-0.1.0.tar.gz.
File metadata
- Download URL: fs_box_sync-0.1.0.tar.gz
- Upload date:
- Size: 46.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d0cdde24270b33b40cb44958b7f1e7dae6fb28733dfbd07cddf6108ae054fc
|
|
| MD5 |
52f1e92da62db995126abd6da73e9041
|
|
| BLAKE2b-256 |
91c788608cf6ecc730a0dfa11c7af6398b5d33da13934e53cc981583883c62fa
|
Provenance
The following attestation bundles were made for fs_box_sync-0.1.0.tar.gz:
Publisher:
publish.yml on oharu121/fs-box-sync-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fs_box_sync-0.1.0.tar.gz -
Subject digest:
40d0cdde24270b33b40cb44958b7f1e7dae6fb28733dfbd07cddf6108ae054fc - Sigstore transparency entry: 854023057
- Sigstore integration time:
-
Permalink:
oharu121/fs-box-sync-py@3513a3ec74118a88c040996c51a48c024d6d3e20 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/oharu121
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3513a3ec74118a88c040996c51a48c024d6d3e20 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fs_box_sync-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fs_box_sync-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01dc7861b7e7c8217ea2bf8471be0c526ee4bea9a9532ade33040c4aa7491b9c
|
|
| MD5 |
63931c76910ca768293be3186bb990ab
|
|
| BLAKE2b-256 |
bea6fd807101010770a36f223aa3f15bd08f89220a2aad11afe0f54ffeee0ce6
|
Provenance
The following attestation bundles were made for fs_box_sync-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on oharu121/fs-box-sync-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fs_box_sync-0.1.0-py3-none-any.whl -
Subject digest:
01dc7861b7e7c8217ea2bf8471be0c526ee4bea9a9532ade33040c4aa7491b9c - Sigstore transparency entry: 854023058
- Sigstore integration time:
-
Permalink:
oharu121/fs-box-sync-py@3513a3ec74118a88c040996c51a48c024d6d3e20 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/oharu121
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3513a3ec74118a88c040996c51a48c024d6d3e20 -
Trigger Event:
release
-
Statement type: