For the T3 API's new tag list paging. Upgrade before using tag lists against
it: 2.1.0 reads only the first page of list(), entries() and resolve(),
and its resolve() returns the entries rather than their objects.
- Tag lists page by cursor.
client.tag_lists.list(),entries()andresolve()send each page'snextCursorback ascursorwhilehasMoreis true, as the API now requires; it no longer acceptspageor returnstotalPageson these routes. Pages are read one after another rather than in parallel.list()andentries()ask for 500 rows a page (was 100). A response withoutdataandhasMoreraisesSpecErrorinstead of being read as one page. resolve()keeps its contract: the objects in the order the entries were added, orTagListResolveErrorwhen any handle matched zero objects or several. The server now answers every page with a 200 and a status per entry, soresolve()raises once it has read the whole list.errorskeeps its shape (handle,reason,matchCount) and lists every failing handle, andcodeisTAG_LIST_UNRESOLVED_ENTRIES.status_codeis now 200 andresponseis the last page's; both were the server's 422.- No list size limit. A tag list can hold any number of entries, so
create()no longer warns about lists of more than 5,000. Each request still carries at most 5,000, and larger batches are still sent in chunks.t3api_utils.tag_lists.ENTRIES_PER_REQUESTis the new name forMAX_ENTRIES, which still works. - Refreshed the bundled spec.
- The three tag-list
GETroutes are now cursor-paginated, so they're classified asotherrather thancollection, andcollect()no longer accepts them. Useclient.tag_lists. - 80 of the 85 Metrc write routes now have endpoint IDs, so
client.post("METRC_DISCONTINUE_ITEM", ...)works as well as the path, and labels in messages readPOST /v2/items/discontinue (METRC_DISCONTINUE_ITEM). /supercollections declarepageSizeat most 50, socollect()now caps their page size at 50.- 58 report routes take
tagListId(seetag_list=below). - Metrc write routes take
applyDynamicConfirmation, which has T3 confirm the write with Metrc before answering. Pass it withparams={"applyDynamicConfirmation": "true"}.
- The three tag-list
resolve_entries()onclient.tag_listsandTagList: every entry, in the order added, withstatus(FOUND,NOT_FOUNDorAMBIGUOUS),matchCountandobject(the object whenFOUND, elseNone). It never raises for a bad handle. Takes the same arguments asresolve().tag_list=onreport()andreport_url(), and--tag-listont3api report: one report row per entry, in list order, in one request. Pass the list's license, and nofilter,filter_logic,sortorrow_limit. If any entry matches no row or several, the server answers 422 and the library raisesTagListResolveErrorwith the first 1,000 inerrors.
Changes from writing and testing the T3 example scripts against 2.0.1.
- A license number the login doesn't have now raises
t3.UnknownLicensebefore anything is sent, on production as well as in the sandbox. 2.0.1 only warned, and only in the sandbox. The first call that names a license (withlicense=,licenses=or the default license) lists the login's licenses once withGET /v2/licenses;exc.licenseandexc.knownhold the number given and the login's numbers. Every client method is covered, includingbulk()(checked once, before the first row),download(),report(),report_url()andclient.tag_lists. The check is skipped where the spec markslicenseNumberoptional (/v2/saved-reports, where it filters), and when the license list can't be loaded. - Network failures raise
t3.NetworkError, aT3Error, instead of rawhttpx2exceptions, once retries are used up. Thehttpx2exception is__cause__.maybe_sentisFalsewhen the connection failed before the request went out, and the message of a write that may have gone through says to check before sending it again. Code that caughthttpx2.TransportError(orReadTimeoutand the like) around client calls should catcht3.NetworkErrorinstead.client.httpstill raiseshttpx2exceptions. RowResult.erroris typedT3Error | None(wasAPIError | None), since a row can now hold theNetworkErrorthat stopped a run.read_rows()returnst3.Rowobjects: dicts with alineattribute (see Added). They compare equal to plain dicts. A JSON Lines value that isn't an object becomes{"value": ...}, as in JSON files.read_rows()skips CSV and TSV lines whose cells are all empty (,,,, which spreadsheets often leave at the end), as it already skipped blank lines.filter_rows()match files skip them too, instead of warning that they matched nothing.- Default export names (
to_csv()andto_json()without a path, or with a folder) use the license only when the rows share one, andmultiplewhen they hold several; 2.0 used the first row's. The data model likewise comes from the rows only when they share one, elserows.
bulk()keeps itslog_tofile when a run stops on an exception: anAuthError, aNetworkError, Ctrl-C at a prompt or mid-run. The rows being sent are markedfailedwith a message saying they may have gone through (ornot_sentwhen nothing was sent, or during validation), every later row isnot_sent, and the exception is raised again. Before, the file wasn't written at all, so there was no record of which rows had been submitted.page_sizeis capped at the endpoint's maximum.collect()anditer_rows()lower it to themaximumthe spec declares for an endpoint'spageSize, so the default of 100 doesn't get a 400 from endpoints that allow fewer rows per page.t3.flattenis exported from the top-level package, as the reference docs already said.read_rows()on JSON Lines failed on files written byto_json(lines=True)when a value held U+2028, U+2029 or U+0085: it split lines on those characters too. It now splits on newlines only.read_rows()on a CSV or TSV that starts with blank lines took the blank line as the header. It now uses the first line with content.
name=onto_csv()andto_json()replaces the data model part of the default file name:t3.to_csv(rows, "output/", name="licenses")writesoutput/licenses__<license>__<time>.csv. It has no effect when the path is a file, so a script can pass its--outputvalue through either way.Row.lineon rows fromread_rows(): the line each row starts on in the file, counting from 1 as a text editor does, for CSV, TSV and JSON Lines (Nonefor JSON). It stays right after blank lines and quoted cells that span several lines. Use it in messages such asf"line {row.line}: ...".t3.UnknownLicense,t3.NetworkErrorandt3.Rowin the top-level package.
Fixes and additions from porting the T3 example scripts to 2.0. Use this release instead of 2.0.0.
bulk()on list routes. Most Metrc write routes (68 of 85) take a JSON list, even for one object, and answer a bare object with an unexplained HTTP 500.bulk()sent every row as an object, so on those routes every row came backinvalid. It now wraps each row in a list where the spec says the body is one. You still pass one dict per object.- Production licenses in the sandbox.
connect(sandbox=True)keptT3_LICENSEor the profile's license, and the sandbox answers a request for a license it doesn't have with an empty 200, so scripts quietly found nothing. In the sandbox those defaults are now ignored (an explicitconnect(license=...)still counts),enter_sandbox()clearsclient.license, and a call naming a license the sandbox session doesn't have logs a warning. - Dry-run wording. A dry run is static validation: format, required fields
and types, not whether the records a request names exist. The docs,
docstrings and
BulkResult.summary()now say so.summary()reads12 passed validation, 1 failed validationrather than12 valid, 1 invalid(the row statuses themselves are unchanged), and lists statuses in pipeline order: passed validation, failed validation, submitted, failed, not sent.
bulk(submit="ask")validates every row, shows the route, license, counts and any failures (and says "sandbox" in the sandbox), then asks whether to submit, default no. Without a terminal it raisesNotInteractivebefore sending anything. A script can map its flag in one line:submit=True if args.yes else "ask". On routes with no dry run it asks instead of needingconfirm=True.bulk(batch_size=N)sends up to N rows per request on list routes. A failed request marks every row in it. The default stays 1.dynamic=Trueonpost(),put(),patch(),delete()andbulk()sendsapplyDynamicValidation=true, for the routes that offer it.- A warning when a
json=body's shape doesn't match the route: an object sent to a list route, or a list to an object route. t3.confirm(),t3.ask()andt3.choose(), public prompts that match the library's pickers and raiseNotInteractivewithout a terminal.confirm()defaults to no.ask(parse=float)asks again untilparsesucceeds.choose()(the existing picker, now exported) turns filtering on for more than 10 items unlessfilterable=says otherwise. New guide page: Prompts and pickers.- Sandbox: the
T3_SANDBOXenvironment variable (1,true,yesoron), a globalt3api --sandboxoption for the data commands,client.sandbox,client.hostname(the Metrc hostname, fromwhoami), and an INFO log line on entering the sandbox.t3api whoamishows asandboxrow there. client.download(endpoint, to, ...)streams afileendpoint (manifest and COA PDFs, item photos) to disk through a temporary file that's renamed when complete, so a failed download never leaves a partial file.include=oncollect(),iter_rows()andget()for super endpoints, sent as a repeated parameter (the server rejects a comma-joined one). Values the spec doesn't list are warned about.to_csv()andto_json()accept a folder: an existing folder, or a path ending in/, gets the default<dataModel>__<license>__<time>file name inside it.Endpoint.body_type/Endpoint.body_is_arrayandParam.choicesin the spec registry.- Docs: array bodies, uploads with
files=, downloads, super collections andinclude, and the difference betweenbulk(confirm=True)andsubmit="ask".
connect(sandbox=True)now callswhoamionce even withvalidate=False, to log the sandbox hostname.
A hard-break rewrite. No 1.x import path still works, and there is no compatibility layer. The migration guide maps every 1.x name to its replacement and shows the example scripts before and after.
t3.connect()is the one way in. It finds a credential (argument, thenT3_SECRET_KEY/T3_JWT, then the saved profile, then an interactive login only when a person can answer), validates it, and returns aT3Client. Scripts get fromimportto data in three lines.- Secret keys first.
t3api logincreates a T3 secret key from your Metrc login and saves it to a named profile, with the secret in the OS keyring. The Metrc password is never stored.client.secret_keysandt3api keyslist, create, rotate and revoke keys. JWTs remain as a fallback. - Spec-driven endpoints. Endpoints are named by T3 endpoint ID
(
METRC_ACTIVE_ITEMS) or path, checked against the T3 OpenAPI spec at runtime. A live copy is fetched and cached per host, with the spec bundled in the package as a fallback, so new endpoints work without a release. Missing required parameters fail before any request is sent. - Collections:
client.collect()loads every page of any of the 187 paginated endpoints in parallel behind one shared rate limiter; 1.x's picker found 138.client.iter_rows()streams large collections. Rows are plain dicts, exactly as the API returns them. - Safe writes. Metrc writes are a dry run unless
submit=True. Routes with no dry run rejectsubmit=.client.bulk()validates every row before submitting any, and can log each row's outcome to CSV. - Server-side reports:
client.report()downloads any of the 83 report endpoints as CSV, XLSX, JSON or a Google Sheet, for up to 20 licenses.client.report_url()builds a secret-key URL for spreadsheets to pull. - Tag lists:
client.tag_listscreates lists from a CSV column or rows and resolves them to packages, items, harvests and more, with per-handle errors when something doesn't match. - A
t3apicommand for login, profiles, keys, default license, endpoint search,pull(collection to CSV/JSON or the inspector),report,tag-lists,inspectandspec info/spec refresh. - Local helpers:
t3.filter_rows()(indexed, with dotted paths),t3.to_csv()(UTF-8 with BOM for Excel, lists as JSON),t3.to_json()(optionally JSON Lines),t3.read_rows(), andt3.pick_file(). - The Textual inspector is kept as
t3.inspect(), behind the optional[tui]extra. - Errors keep their response. Every
APIErrorhasstatus_code,detail,errors,codeand theresponse; 1.x always reportedstatus_code=None. Auth errors say whether to rotate a key or log in again. - Runs the same on Linux, macOS, Windows and in Jupyter. CI covers all three operating systems on Python 3.12 and 3.13, with 100% line and branch coverage.
- Writes are no longer retried after a 5xx or a timeout, and a POST that gets
a 400 is sent once, not three times. Reads retry only on connection errors,
429, 502, 503 and 504, honouring
Retry-After. - The rate limiter really limits: 1.x let 20 requests through in 0.2 seconds.
- HTTP debug logging masks auth headers, secret keys in paths and queries, and password, OTP, OTP seed, secret key and token fields in bodies. 1.x logged credential-login bodies, password included.
- Secret keys are sent in the
X-T3-API-Keyheader instead of the URL. - Exported CSV lists are JSON text instead of Python reprs.
- The async
T3APIClient, its sync wrappers,send_api_request, therequest_*helpers and theget_collection/load_all_data_*/parallel_load_*family. UseT3Clientmethods, orclient.httpfor the configuredhttpx2.Client. get_authenticated_client_or_error()and the other ~22 auth functions, including the*_with_validationvariants.- API-key auth (
/v2/auth/apikey,API_KEY,API_STATE_CODE). - The
.t3.envfile,ConfigManagerand the 37EnvKeys. 2.0 reads eight environment variables:T3_SECRET_KEY,T3_JWT,T3_PROFILE,T3_LICENSE,T3_API_HOST,T3_SPEC,T3_LOG_HTTP,T3_LOG_FILE. - DuckDB and pyarrow, and the
db/module (relational tables, schema export). interactive_collection_handlerand the numbered menu,match_collection_from_csv,save_collection_to_*/save_dicts_to_*,pick_collection.- The
MetrcObject,MetrcCollectionResponseand other TypedDicts. - The public
style/module andlogging.setup_logging(). - The
intro.pytutorial, now the Getting started docs page. - Dependencies:
httpx(replaced byhttpx2),duckdb,pyarrow,questionary,python-dotenv,certifi.
- Still published as
t3api-utils, imported ast3api_utils, for Python 3.12 or later. License GPL-3.0-only. Built withuv_build. - Core dependencies:
httpx2,rich,typer,keyring,platformdirs,pyotp,tomli-w. Textual is no longer installed by default; it's in the[tui]extra.
Final 1.x release. 1.x is frozen: no further releases or fixes. Pin
t3api-utils<2 to keep using it.