Introducting T3 Scripts
I'm excited to announce the newest addition to the T3 platform: T3 Scripts.
Users often ask for ways to generate reports, analyze Metrc data, or automate repetitive tasks, each with their own spin. The T3 API already supports all of this, but scripting and APIs are out of reach for many. Building custom one-off tools isn’t scalable, so T3 Scripts bridges that gap.
It makes creating Python scripts that talk to the T3 API simple, powered by two pieces:
- uv, an easy-to-use Python package manager
- t3api-python-utils, an open-source package for working with the T3 API
If you want to see how easy it is to use, here's a script that authenticates, loads out all active packages for a selected license. You just run it with uv run load-all-packages.py
load-all-packages.py
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.8"
# dependencies = [
# "t3api_utils",
# ]
# ///
from t3api_utils.api.parallel import load_all_data_sync
from t3api_utils.main.utils import (get_authenticated_client_or_error,
interactive_collection_handler,
pick_license)
api_client = get_authenticated_client_or_error()
license = pick_license(api_client=api_client)
all_packages = load_all_data_sync(
client=api_client,
path="/v2/packages/active",
license_number=license["licenseNumber"],
)
interactive_collection_handler(data=all_packages)
Source: https://github.com/classvsoftware/t3-api-examples/blob/master/load-all-packages.py
Learn more on the T3 WIki: https://github.com/classvsoftware/t3-wiki/wiki/T3-API-:-API-Scripts#api-scripts
t3api-utils
documentation: https://github.com/classvsoftware/t3-wiki/wiki/T3-API-:-Python-Utils