A Python application that demonstrates how to use Box AI to extract structured metadata from files and attach it back to the file in Box. This quickstart guide will walk you through these steps.
- Python 3.11+
- Box Developer Account
- Box App with appropriate permissions
-
Clone the repository
git clone https://github.com/box-community/box-ai-extract-quickstart.git cd box-ai-extract-quickstart -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install python-dotenv "boxsdk>=10" -
Configure environment variables
cp .env.template .env
Edit
.envand add your values:BOX_DEVELOPER_TOKEN: Your Box developer tokenBOX_FILE_ID: ID of the file to extract metadata fromBOX_METADATA_TEMPLATE_KEY: Key of your metadata template
Run the extraction script:
python extract.pyThe script will:
- Authenticate with Box using your developer token
- Extract structured metadata from the specified file using Box AI
- Attach the extracted metadata to the file
- Create a Box App with
Client Credentials Grantauthentication - Create a metadata template in your Box enterprise
- Ensure your app has permissions to read files and manage metadata
- Upload a file to Box and note its file ID
extract.py- Main application script.env.template- Environment variables template.env- Your environment variables (not tracked in git).gitignore- Git ignore rules for Python projects