API Scripts
API Scripts¶
Running Python Scripts with UV¶
T3 Scripts
Inline Packages¶
This lets you declare your dependencies at the top of the script using special comments. When run with uv run example.py, uv automatically resolves and installs those dependencies in an isolated environment.
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.8"
# dependencies = [
# "t3api-utils",
# ]
# ///
from t3api_utils.main.utils import get_authenticated_client_or_error, pick_license
api_client = get_authenticated_client_or_error()
license_number = pick_license(api_client=api_client)
Virtual Environments¶
You can install dependencies into a standard Python virtual environment managed by uv venv:
from t3api_utils.main.utils import get_authenticated_client_or_error, pick_license
api_client = get_authenticated_client_or_error()
license_number = pick_license(api_client=api_client)
T3 Python Libraries¶
T3 supports various Python packages to make using the API easier:
t3api¶
t3api is a wrapper around the entire T3 API. It allows you to authenticate and send requests in a structured way without needing to manually build HTTP requests.
t3api-utils¶
t3api-utils is a collection of pre-built utilities for solving common patterns. Utilities include automatic authentication, license selection, and loading entire collections in parallel.
The documentation for this library is located here
t3py¶
t3py is a command line program with prebuilt commands. It can be run with t3py [<command_name>].
Next Steps¶
- Use Supercollections to load packages + lab results (or transfers + packages) in a single call.
- Use Reports to dump entire Metrc datasets without pagination.
- Learn about the OpenAPI spec — including how to feed a pruned subset to an LLM or code generator.
- Refer to the T3 API documentation to explore all the available endpoints.
- Most API endpoints require a T3+ subscription. If you don't have a T3+ subscription, you can sign up here.