# Cannabis License Watch (`socosupply/cannabis-license-watch`) Actor

Scheduled monitor of state cannabis business licenses from official regulator open data. Returns new licenses, status changes, and upcoming expirations since your last run.

- **URL**: https://apify.com/socosupply/cannabis-license-watch.md
- **Developed by:** [Soco Supply](https://apify.com/socosupply) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 licenses

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Cannabis License Watch

Monitor state cannabis **business** license registries from official regulator open data. Each scheduled run tells you what changed since the last run: new licenses, status changes, and licenses expiring soon—so vendors (packaging, compliance software, insurance, equipment, labs) can reach licensed businesses at the right time.

### Supported states

| State | Source | Status |
|-------|--------|--------|
| **CA** | California DCC public ExportAll registry (same feed as [search.cannabis.ca.gov](https://search.cannabis.ca.gov/)) | Verified |
| **NY** | [NYS Open Data — Current OCM Licenses](https://data.ny.gov/) (`jskf-tt3q`) | Verified |
| **OR** | [Oregon Open Data — OLCC Cannabis Business Licenses](https://data.oregon.gov/) (`q32u-cmam`) | Verified |
| **CT** | [Connecticut Open Data — Licensed cannabis retail locations](https://data.ct.gov/) (`42yd-3x3d`) | Verified |
| **WA** | [Washington Open Data — WSLCB Cannabis Renewal licensees](https://data.wa.gov/) (`brpd-b6zd`) | Verified |
| **MA** | [Massachusetts CCC open data — public license details](https://masscannabiscontrol.com/open-data/data-catalog/) (`l_licenses_all_details_public.json`) | Verified |
| CO, MI, IL, NJ, MD, MO | Official regulator portals (see `REPORT.md`) | Researched; no stable public bulk feed verified yet in this Actor |

We only ingest **regulator-published** open data. We do **not** include owner names, personal emails, personal phone numbers, or street addresses in output.

### Input

| Field | Description |
|-------|-------------|
| `states` | State codes to monitor (e.g. `["CA"]`) |
| `licenseTypes` | Optional allow-list (exact match) |
| `statuses` | Optional allow-list (e.g. `["Active"]`) |
| `counties` / `cities` | Optional geographic filters |
| `changeTypes` | `new`, `status_change`, `expiring` (when `emitAll` is false) |
| `expiringWithinDays` | Window for expiring alerts (default 30) |
| `maxResults` | Cap rows pushed per run (0 = unlimited); licenses over the cap stay pending until a later run emits them |
| `emitAll` | If true, push all matching licenses, not just deltas |
| `emitExistingOnFirstRun` | Default `false`: first run saves a baseline snapshot and emits **nothing** (no pay-per-event charge for ~20k existing licenses). Set `true` to emit existing licenses as `new` on the first run |

Example:

```json
{
  "states": ["CA"],
  "statuses": ["Active"],
  "changeTypes": ["new", "status_change", "expiring"],
  "expiringWithinDays": 30,
  "maxResults": 20,
  "emitAll": false
}
```

### Output

Each dataset row:

- `state`, `licenseNumber`, `licenseType`, `status`
- `businessLegalName`, `dba`, `county`, `city`
- `issueDate`, `expirationDate`
- `sourceUrl`, `changeType`, `previousStatus` (when status changed)

Example (from a local test run; values reflect the registry at run time):

```json
{
  "state": "CA",
  "licenseNumber": "C10-0000123-LIC",
  "licenseType": "Commercial - Retailer",
  "status": "Active",
  "businessLegalName": "Example Farms LLC",
  "dba": "Example Retail",
  "county": "Los Angeles",
  "city": "Los Angeles",
  "issueDate": "2020-03-15",
  "expirationDate": "2026-03-14",
  "sourceUrl": "https://fa-dcc-pub-vip-cann-ww-p-001.azurewebsites.net/api/ExportAll?searchQuery=",
  "changeType": "new",
  "previousStatus": null
}
```

### Pricing

**$2.50 per 1,000 licenses** returned, plus **$0.003 per run**. Platform usage is included. The first run saves a baseline and returns nothing (unless you turn on emitting existing licenses), so a daily California run with a few dozen changes typically costs cents.

### Sample run vs. monitoring

The example input in Console returns up to 10 current matching records so you can see the output right away ("Emit all matches" on, max results 10). For a scheduled monitor, turn "Emit all matches" off and clear the max-results limit: each run then returns only records that are new or changed since the previous run, so you pay only for what's new.

### Schedule on Apify

1. Deploy this Actor to your Apify account (Store or private).
2. Open **Schedules** → **Create new schedule**.
3. Choose the Actor, paste your input JSON, set cadence (e.g. daily after regulators update).
4. Send results to webhook, dataset, or your CRM.

State between runs is kept in the Actor key-value store `cannabis-license-watch-state`.

### Source attribution

- **California:** Data from the California Department of Cannabis Control public license export API. Not affiliated with or endorsed by the State of California. Verify critical compliance decisions against official DCC records.

### Local run

```bash
cd cannabis-license-watch
npm install
APIFY_LOCAL_STORAGE_DIR=./storage apify run -p --input-file=INPUT.json
## or:
APIFY_LOCAL_STORAGE_DIR=./storage node src/main.js
```

Requires Node.js 20+. First run with `emitAll: false` emits new/changed/expiring rows; a second run with the same input should emit **zero** delta rows if the registry unchanged.

# Actor input Schema

## `states` (type: `array`):

Two-letter state codes to monitor (e.g. CA). Only states with verified official open-data feeds are supported.

## `licenseTypes` (type: `array`):

Include only these license types (exact match, case-sensitive). Empty = all types.

## `statuses` (type: `array`):

Include only these license statuses (exact match). Empty = all statuses.

## `counties` (type: `array`):

Include only licenses in these counties (case-insensitive match). Empty = all counties.

## `cities` (type: `array`):

Include only licenses in these cities (case-insensitive match). Empty = all cities.

## `changeTypes` (type: `array`):

When emitAll is false, emit licenses matching these change categories since the last run.

## `expiringWithinDays` (type: `integer`):

For the expiring change type, include licenses whose expiration date falls within this many days from today.

## `maxResults` (type: `integer`):

Stop after pushing this many license records (0 = unlimited).

## `emitAll` (type: `boolean`):

If true, push every license matching filters (ignores change detection). If false, only new/changed/expiring since last run. The example input turns this on so a first run shows a sample; turn it off for scheduled monitoring.

## `emitExistingOnFirstRun` (type: `boolean`):

When no baseline snapshot exists yet, save all current licenses as the baseline and emit nothing (default). Set true to treat the first run like a normal diff and emit existing licenses as new.

## Actor input object example

```json
{
  "states": [
    "MA"
  ],
  "licenseTypes": [],
  "statuses": [
    "Active"
  ],
  "counties": [],
  "cities": [],
  "changeTypes": [
    "new",
    "status_change",
    "expiring"
  ],
  "expiringWithinDays": 30,
  "maxResults": 10,
  "emitAll": true,
  "emitExistingOnFirstRun": false
}
```

# Actor output Schema

## `results` (type: `string`):

New, changed or expiring cannabis licenses from this run (default dataset).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "states": [
        "MA"
    ],
    "licenseTypes": [],
    "statuses": [
        "Active"
    ],
    "counties": [],
    "cities": [],
    "changeTypes": [
        "new",
        "status_change",
        "expiring"
    ],
    "expiringWithinDays": 30,
    "maxResults": 10,
    "emitAll": true,
    "emitExistingOnFirstRun": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("socosupply/cannabis-license-watch").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "states": ["MA"],
    "licenseTypes": [],
    "statuses": ["Active"],
    "counties": [],
    "cities": [],
    "changeTypes": [
        "new",
        "status_change",
        "expiring",
    ],
    "expiringWithinDays": 30,
    "maxResults": 10,
    "emitAll": True,
    "emitExistingOnFirstRun": False,
}

# Run the Actor and wait for it to finish
run = client.actor("socosupply/cannabis-license-watch").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "states": [
    "MA"
  ],
  "licenseTypes": [],
  "statuses": [
    "Active"
  ],
  "counties": [],
  "cities": [],
  "changeTypes": [
    "new",
    "status_change",
    "expiring"
  ],
  "expiringWithinDays": 30,
  "maxResults": 10,
  "emitAll": true,
  "emitExistingOnFirstRun": false
}' |
apify call socosupply/cannabis-license-watch --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,socosupply/cannabis-license-watch"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/xeD0FODRLHH2qseDN/builds/VkdBBAqqPyLWn3mcg/openapi.json
