Announcing Google Sheet Sync
Today, I'm launching a new feature for the T3 API that lets you sync your Metrc data to Google Sheets: Google Sheet Sync!
What is Google Sheet Sync?
Google Sheet Sync allows you to import entire Metrc datasets into a Google sheet with a single cell formula. The sheet will stay up-to-date with Metrc (updating at least once per hour).
How does it work?
T3 API Reports capture snapshots of your Metrc data all in a single request. Google Sheet Sync allows you to form a single Sync Link that loads your report data. This Sync Link can then be passed to the IMPORTDATA()
formula in Google Sheets.
How to get started with Google Sheet Sync?
Become a T3+ subscriber.
Google Sheet Sync is only available to T3+ subscribers. You can start your 30 day free trial here.
1) Generate your secret key
- Generate your secret key here.
- Store this secret key in a secure place, there is no way to access it again.
- Do not share this secret key! It allows access to your Metrc data
2) Create your Google Sheet Sync Link
All the information needed to generate the report is included in the Sync Link. At minimum, you will need:
- The path of the report you wish to generate (available in the API docs
- The license number for the data that should appear in the report
- Your secret key
For example, let's say you want to create an Active Packages report for the EX-00001 license.
- Report path (taken from the API docs):
/v2/packages/active/report
- License number:
EX-00001
- Secret key:
1234-1234-1234-1234-1234-1234
Your Sync Link would be: https://api.trackandtrace.tools/v2/packages/active/report?secretKey=1234-1234-1234-1234-1234-1234&licenseNumber=EX-00001&contentType=csv
Note: contentType=csv
is required
Note: Do not share this Sync Link! Anyone who has it can load all your Metrc Data
3) Import Data into Google Sheets
Pass your Sync Link to the Google Sheets IMPORTDATA()
function. Every hour, this function will load the report data using your Sync Link and insert it into the sheet.
In Google Sheets, in Cell A1, you would paste =IMPORTDATA("https://api.trackandtrace.tools/v2/packages/active/report?secretKey=1234-1234-1234-1234-1234-1234&licenseNumber=EX-00001&contentType=csv")
Loading your data usually takes 15-20 seconds. The IMPORTDATA
function automatically refreshes the information about once per hour.
Example output (redacted):
Bonus: Advanced Usage
These reports can be configured to include filters, sorting, and can return either JSON or CSV data.
- If you wanted to only return packages in the Bulk Storage room, you would add
&filter=locationName__eq:Bulk Storage
to your Sync Link - If you wanted to control which columns you want in the report, you would add
&fieldnames=label,productionBatchNumber,labTestingStateName
to your Sync Link
Details here: https://api.trackandtrace.tools/v2/docs/#/Reports/get_v2_packages_active_report
- JJoey Espinoza @joey
Could you provide a list of field names?
- JJoey Espinoza @joey
specifically was trying to learn what category should be titled
- MMatt Frisbie @mattfriz
I'll be making a followup YouTube video to demo all the advanced ways to use this, but I'll give a crash course here.
In the video at 2:28, the report header shows dataModel, which is listed as MetrcPackage. The dataModel describes what objects are being returned for the current report, and what columns are available.
To see a list of columns for MetrcPackage, refer to the API docs (https://api.trackandtrace.tools/v2/docs/): at the bottom of the page, there is a Schemas section:
In Schemas, find MetrcPackage and expand it to see all the possible columns:
So if you wanted to specify the columns to show License Number, Facility Name, Label, and Production Batch Number, you would add the following to your Sync Link:
https://api.trackandtrace.tools/v2/packages/active/report?licenseNumber=...&secretKey=...&contentType=csv
&fieldnames=licenseNumber,facilityName,label,productionBatchNumber
These will be returned as the column headers.
MetrcPackage has a special scenario, where
item
is nested inside it.If you want to show an item column, you add
item.*
in front of it. For example, the Item Category, you would useitem.productCategoryName
.Example sync link:
https://api.trackandtrace.tools/v2/packages/active/report?licenseNumber=...&secretKey=...&contentType=csv
&fieldnames=licenseNumber,facilityName,label,productionBatchNumber,item.productCategoryName
- In reply tojoey⬆:MMatt Frisbie @mattfriz
Advanced usage video: https://www.youtube.com/watch?v=alt5w72ZwKs