https://github.com/openthc/cre-adapter
API Adapter for BioTrackTHC, LeafDat, METRC, WCIA, and CCRS
https://github.com/openthc/cre-adapter
api-adapter biotrack ccrs leafdata metrc seed-to-sale traceability wcia
Last synced: 4 months ago
JSON representation
API Adapter for BioTrackTHC, LeafDat, METRC, WCIA, and CCRS
- Host: GitHub
- URL: https://github.com/openthc/cre-adapter
- Owner: openthc
- License: mit
- Created: 2018-10-10T00:08:09.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-12-19T17:26:43.000Z (4 months ago)
- Last Synced: 2025-12-22T07:25:32.692Z (4 months ago)
- Topics: api-adapter, biotrack, ccrs, leafdata, metrc, seed-to-sale, traceability, wcia
- Language: PHP
- Homepage:
- Size: 443 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cannabis Reporting Engine Adapters
API Adapters for BioTrack, METRC and other Cannabis Regulatory Engines.
These scripts expose a common interface for these different API interfaces.
## Examples
There is a convenience factory method to use with the proper configuration (loaded from `etc/cre.yaml`).
```php
$cfg = \OpenTHC\CRE::getConfig('usa-wa');
$cre = \OpenTHC\CRE::factory($cfg);
$res = $cre->license()->search();
$res = $cre->crop()->search();
foreach ($res as $rec) {
echo $rec['variety']['name'] . "\n";
}
$res = $cre->inventory()->search();
foreach ($res as $rec) {
echo $rec['id'] . ' ' . $rec['product_id'] . "\n";
}
```
## Supported Cannabis Reporting Engines
* BioTrack: Hawai'i, Illinois, New Mexico, Puerto Rico
* METRC: Alaska, California, Colorado, Maine, Massachusetts, Michigan, Montana, Nevada, Oklahoma, Oregon, etc
Other engines will be added, of course :)
Some of the engine specific adapters are very thin layers, they really only exist for consistency.
## Connect
```php
$cre = \OpenTHC\CRE::factory($cfg);
$cre->ping();
```
## Reading Objects
A low level, GET and POST/PUT interface exists.
```php
$res = $cre->get('/object?page=0&sort=created_at');
$res = $cre->post('/object', $arg);
$res = $cre->put('/object/id', $arg);
```
## High Level API
It's also possible to interface with the objects at a higher level.
```php
$obj_list = $cre->license()->search($arg);
$obj = $cre->license()->single($oid);
$res = $cre->license()->create($obj);
$res = $cre->license()->update($oid, $obj);
```