# Cannabis Dispensary Monitor (`codingfrontend/cannabis-dispensary-scraper`) Actor

Collects public dispensary records from configured official state registry feeds and reports source coverage/change health.

- **URL**: https://apify.com/codingfrontend/cannabis-dispensary-scraper.md
- **Developed by:** [Coding Frontned](https://apify.com/codingfrontend) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

### What does Cannabis Dispensary Monitor do?

This Actor collects public cannabis dispensary business records from state registry feeds. Pennsylvania is configured as the default source through its [Medical Marijuana Program](https://www.pa.gov/agencies/health/programs/medical-marijuana); you can also provide public HTTPS JSON, GeoJSON, or ArcGIS query feeds. The Actor does not access patient, caregiver, practitioner, or other confidential program data.

### Why use Cannabis Dispensary Monitor?

Use the Actor to build a public dispensary directory, review published license and product availability details, map source-provided locations, or compare records between runs. It can enrich matched Pennsylvania records with details from a public state document, de-duplicate records across feeds, and identify published license expiries within selected alert windows.

The Actor writes business records to the run's default dataset. A separate `OUTPUT_SUMMARY` key-value-store record reports the run result. Change events, source health, expiry alerts, and the comparison baseline are stored in separate key-value-store records.

### How to start a run

1. Open the Actor's **Input** tab. Keep the default Pennsylvania state or enter state codes and public registry feed URLs that you want to collect.
2. Set the record limit, page limit, deduplication, and detail options for your run. All input fields are optional; the defaults select Pennsylvania and request up to 100 records from one page.
3. Click **Start** and wait for the run to finish.
4. Open the **Results** dataset for business records. Use **Output summary** to see the three-field run result. Other monitoring records are in the run's default **Key-value store**.

### Input

Every field is optional in the schema. `states` defaults to `PA`; if it is an empty array, the runtime also falls back to `PA`. Only Pennsylvania has a built-in registry feed. Other states need a public feed in `sourceUrls`.

#### States and registry feeds

| Field | Type | Required? | Default | What it does |
| --- | --- | --- | --- | --- |
| `states` | Array of text | Optional | `["PA"]` | Two-letter state codes. Up to 60 entries. Pennsylvania has a configured official ArcGIS feed. Other codes need a matching `sourceUrls` entry. |
| `state` | Text | Optional | None; falls back to `states` | Legacy alias for one state. When both `states` and `state` are supplied, `states` takes precedence. |
| `includeStateSources` | Boolean | Optional | `true` | Include configured state feeds. Set to `false` to use only `sourceUrls`. |
| `sourceUrls` | Array of objects | Optional | `[]` | Additional public JSON, GeoJSON, or ArcGIS query feeds. Up to 60 entries; identical URLs are fetched once. Each URL must be public HTTPS. |

Each `sourceUrls` entry supports these fields:

| Field | Type | Required? | Default | What it does |
| --- | --- | --- | --- | --- |
| `sourceUrls[].url` | URL text | Required in each entry | None | Public HTTPS URL returning JSON, GeoJSON, or an ArcGIS query response. |
| `sourceUrls[].state` | Text | Optional | None | Two-letter state represented by this feed. Used to label records when the source does not provide a state. |
| `sourceUrls[].source` | Text | Optional | `"configured public registry"` | Label shown in source health reporting; it does not add a field to business records. Maximum 200 characters. |

#### Records and monitoring

| Field | Type | Required? | Default | What it does |
| --- | --- | --- | --- | --- |
| `includeOfficialDetails` | Boolean | Optional | `true` | For Pennsylvania runs with records, fetch the public state product PDF once and add details only to uniquely matched registry records. Matched phone, website, source link, and printed date values may be added. Set to `false` to skip this request. |
| `maxResultsPerSource` | Integer | Optional | `100` | Maximum saved records from each feed, from `0` to `5000`. `0` removes this per-source count limit; page and response-size limits still apply. |
| `maxPages` | Integer | Optional | `1` | Maximum pages per feed, from `1` to `50`. The Actor follows supported public next links or ArcGIS transfer-limit pages. |
| `deduplicate` | Boolean | Optional | `true` | Remove matching records across feeds and pages using source IDs or public business identity fields. |
| `licenseExpiryAlertDays` | Array of integers | Optional | `[30, 60, 90]` | Days-ahead windows for `EXPIRING_LICENSES`. Up to 10 values, each from 1 to 3650. Use `[]` to disable expiry alerts. Alerts require a source-published `licenseExpiresAt` date. |
| `webhookUrl` | URL text | Optional | None | Public HTTPS destination for change events. A POST is sent only when changes exist and collection has not hit a source boundary. Leave it out to keep alerts in Apify. |

#### Advanced settings (Developer Options)

| Field | Type | Required? | Default | What it does |
| --- | --- | --- | --- | --- |
| `sourceTimeoutSecs` | Integer | Optional | `120` seconds | Timeout for each public source request, from 5 to 1800 seconds. |
| `timeoutSecs` | Integer | Optional | `120` seconds | Legacy alias for `sourceTimeoutSecs`. Use one timeout field. If both differ and one is `120`, the non-default value wins; other conflicting values are rejected. |
| `maxRequestRetries` | Integer | Optional | `1` | Retries transient transport faults and HTTP 500, 502, or 504 responses. Range: 0 to 3. Access restrictions and policy failures are not retried. |
| `requestDelayMs` | Integer | Optional | `0` milliseconds | Delay before each content request, from 0 to 10000 milliseconds. Requests run sequentially. |
| `maxResponseBytes` | Integer | Optional | `5242880` bytes (5 MiB) | Maximum response size, from 1024 bytes to 20971520 bytes (20 MiB). Larger responses are rejected. |
| `userAgent` | Text | Optional | `CannabisPublicRegistryScraper/1.0` | Transparent HTTP user-agent string. Maximum 300 characters; line breaks are not allowed. |

`state` and `timeoutSecs` are compatibility aliases. Prefer `states` and `sourceTimeoutSecs` in new inputs. There is no public proxy input or automatic paid Apify Proxy use. Requests honor existing HTTP/HTTPS proxy environment settings when the runtime supplies them.

#### Copyable input examples

Small Pennsylvania run using the built-in source:

```json input
{
  "states": ["PA"],
  "maxResultsPerSource": 10
}
```

Skip the optional Pennsylvania document enrichment:

```json input
{
  "states": ["PA"],
  "includeOfficialDetails": false,
  "maxResultsPerSource": 25
}
```

Allow more pages and set expiry alert windows:

```json input
{
  "states": ["PA"],
  "maxPages": 3,
  "maxResultsPerSource": 200,
  "licenseExpiryAlertDays": [30, 90],
  "requestDelayMs": 250
}
```

Add public feeds and deduplicate identical URLs. Replace the example URLs with the source URLs you intend to use before starting the run:

```json input
{
  "includeStateSources": false,
  "states": ["NY"],
  "sourceUrls": [
    {
      "url": "https://registry.example.org/dispensaries.json",
      "state": "NY",
      "source": "State registry"
    },
    {
      "url": "https://registry.example.org/dispensaries.json",
      "state": "NY",
      "source": "Duplicate feed URL"
    }
  ],
  "deduplicate": true,
  "maxPages": 2
}
```

`sourceUrls` entries use the source's public feed URL. A URL is fetched once even if repeated or already selected by a built-in state source. The Actor does not search a registry website for feeds on your behalf.

### Output

The dataset contains business records only. A record must have a source-provided name, street address, and registry feed URL. Other values are included only when present in source data; the Actor does not invent license details, coordinates, hours, or business URLs.

The values and links below are **illustrative** and are not verified live results. This example shows every supported business field. Real records omit unavailable optional fields.

```json business-output
{
  "sourceRecordId": "12345",
  "sourceUrl": "https://services5.arcgis.com/RqxnMm8RWsjEA1kX/ArcGIS/rest/services/PA___Medical_Marijuana_Dispensaries/FeatureServer/0/query?where=1%3D1&outFields=*&returnGeometry=true&f=json",
  "name": "Example Wellness Dispensary",
  "legalName": "Example Wellness LLC",
  "state": "PA",
  "country": "US",
  "licenseNumber": "MMJ-12345",
  "licenseType": "Medical dispensary",
  "licenseStatus": "Active",
  "operationalStatus": "Open",
  "address": "100 Main Street",
  "addressLine2": "Suite 2",
  "city": "Harrisburg",
  "municipality": "Harrisburg",
  "county": "Dauphin County",
  "region": "Central",
  "zip": "17101",
  "latitude": 40.2732,
  "longitude": -76.8867,
  "phone": "717-555-0100",
  "website": "https://www.example.com/",
  "hours": {
    "monday": { "opens": "09:00", "closes": "17:00" },
    "sunday": "Closed"
  },
  "categories": ["Medical dispensary"],
  "products": ["Medical cannabis"],
  "description": "A licensed medical dispensary.",
  "openedAt": "2018-02-15",
  "licenseIssuedAt": "2018-02-15",
  "licenseExpiresAt": "2027-12-31",
  "productAvailability": "Yes",
  "productAvailabilityAsOf": "2025-01-15",
  "productAvailableAt": "2025-01-15",
  "officialSourceUrl": "https://www.pa.gov/content/dam/copapwp-pagov/en/health/documents/topics/documents/programs/medical-marijuana/Medical%20Marijuana%20Dispensaries%20in%20Pennsylvania%20with%20Product.pdf",
  "registryDateColumns": ["2018-02-15", "2025-01-15"],
  "registryProductAsOf": "2025-01-15"
}
```

#### Output fields

| Field | Type | Required? | Meaning |
| --- | --- | --- | --- |
| `sourceRecordId` | Text | Optional | Identifier supplied by the registry. |
| `sourceUrl` | URL text | Required | Public HTTPS feed that supplied the record. |
| `name` | Text | Required | Dispensary or public location name. |
| `legalName` | Text | Optional | Legal business name. |
| `state` | Text | Optional | State code from the source or feed label. |
| `country` | Text | Optional | Country code or name. |
| `licenseNumber` | Text | Optional | Published license or permit identifier. |
| `licenseType` | Text | Optional | Published license or permit type. |
| `licenseStatus` | Text | Optional | Published license status. |
| `operationalStatus` | Text | Optional | Published business operating status. |
| `address` | Text | Required | Street address. |
| `addressLine2` | Text | Optional | Unit, suite, or second address line. |
| `city` | Text | Optional | City or town. |
| `municipality` | Text | Optional | Municipality when separately published. |
| `county` | Text | Optional | County. |
| `region` | Text | Optional | Region, district, or similar subdivision. |
| `zip` | Text | Optional | Postal code. |
| `latitude` | Number | Optional | Source coordinate or point-geometry latitude, from -90 to 90. |
| `longitude` | Number | Optional | Source coordinate or point-geometry longitude, from -180 to 180. |
| `phone` | Text | Optional | Public business telephone number. |
| `website` | URL text | Optional | Public business website from the feed or the same matched PDF table row. Separate website lines with no reliable row attribution are omitted. |
| `hours` | Text, object, or array | Optional | Opening hours in the shape supplied by the source. |
| `categories` | Array of text | Optional | Published category or facility-type labels. |
| `products` | Array of text | Optional | Published product types. |
| `description` | Text | Optional | Public business description. |
| `openedAt` | Text | Optional | Published opening date. |
| `licenseIssuedAt` | Text | Optional | Published license issue date. |
| `licenseExpiresAt` | Text | Optional | Published license expiry date. |
| `productAvailability` | Text | Optional | Published product availability statement. |
| `productAvailabilityAsOf` | Text | Optional | Publisher's product availability as-of date. |
| `productAvailableAt` | Text | Optional | Published product availability date or time. |
| `officialSourceUrl` | URL text | Optional | Public official document used for a matched detail, when available. |
| `registryDateColumns` | Array of text | Optional | Dates printed on the matched official registry row, kept in source order. |
| `registryProductAsOf` | Text | Optional | Product document's published as-of date. |

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

### Run status and output summary

The run status is based on validated business records whose dataset writes completed:

- **SUCCEEDED** means at least one real business record was saved and collection completed.
- **SUCCEEDED with limited results** means at least one record was saved and a source, page, optional document enrichment, or dataset write failure limited collection. The Actor keeps the saved records and marks `isPartial` as `true`.
- **FAILED** means no real business records were saved. Empty, blocked, invalid, or diagnostic-only data does not create dummy dataset rows.
- Reaching `maxResultsPerSource` is normal completion when no other failure stops collection.

The separate **Output summary** link opens `OUTPUT_SUMMARY` in the run's default **Key-value store**. It contains exactly these fields:

| Field | Type | Required? | Meaning |
| --- | --- | --- | --- |
| `status` | Text | Required | `SUCCEEDED` when at least one real record was saved; otherwise `FAILED`. |
| `itemsStored` | Nonnegative integer | Required | Number of validated business records whose dataset writes completed. |
| `isPartial` | Boolean | Required | `true` when a source, page, optional document enrichment, or dataset write failure limited collection and at least one real record was saved. |

```json summary
{
  "status": "SUCCEEDED",
  "itemsStored": 25,
  "isPartial": false
}
```

Other key-value-store records support monitoring: `RUN_HEALTH` contains source outcomes, `SNAPSHOT` is the comparison baseline, `CHANGES` contains new or updated records, and `EXPIRING_LICENSES` contains expiry alerts. These are separate from the business dataset and `OUTPUT_SUMMARY`.

### Tips and access limits

- For states without a built-in feed, supply a public JSON, GeoJSON, or ArcGIS query endpoint in `sourceUrls` and label its state when useful.
- Results from a source depend on the fields it publishes. The Actor cannot create license, address, contact, or location data that is missing upstream.
- Requests are sequential and bounded by page count, response size, and timeout. Keep limits modest and follow source terms and robots guidance.
- The Actor uses HTTPS requests and honors existing runtime HTTP/HTTPS proxy settings. It does not authenticate to private registries, follow redirects, bypass access restrictions, or solve CAPTCHAs.
- Each source must pass its public URL and robots policy checks. An inaccessible robots policy stops collection even if the source is described as public. With no saved records, the run fails; check the run log and `RUN_HEALTH` for the source response.
- Feed and webhook URLs must be public and cannot include URL credentials or credential-like query parameters.
- Pennsylvania's optional PDF enrichment matches rows to existing ArcGIS records; it does not add PDF-only locations or infer formal permit details the document does not publish. Phone numbers, printed dates, and websites depend on an unambiguous match. Website text separated from its table row is omitted, and unavailable optional details remain absent. If the document request or parser fails, valid base records are still saved with limited-results status.

### Cost, support, and responsible use

This Actor has no fixed price in its code. Apify platform usage is billed according to your account plan and current compute settings; review your Apify usage page for current rates. Sequential requests and smaller result limits can reduce run time.

For help, use the Actor's **Issues** tab and include the run ID and a copy of the input. Use the **API** tab for programmatic runs and dataset access.

This Actor is not affiliated with Pennsylvania or any registry provider. It collects public business records, which may still include personal or commercial information. Use the data lawfully, follow source terms and applicable privacy rules, and consult legal counsel if you are unsure whether your use is permitted.

# Actor input Schema

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

Two-letter state codes. PA is backed by Pennsylvania's public ArcGIS registry; other states require sourceUrls.

## `state` (type: `string`):

Legacy alias for one state code. If states is also supplied, states takes precedence.

## `includeStateSources` (type: `boolean`):

Fetch configured official licensing feeds.

## `includeOfficialDetails` (type: `boolean`):

When Pennsylvania records are found, fetch the official public product PDF once and add matched phone, website, source-link, and printed-date details. The PDF does not add unmatched locations or unpublished permit fields.

## `sourceUrls` (type: `array`):

Public HTTPS JSON, GeoJSON, or ArcGIS query URLs. Identical URLs are fetched once. Each entry can include optional state and source labels.

## `maxResultsPerSource` (type: `integer`):

Maximum dispensary records emitted from each source. 0 means the full bounded response.

## `maxPages` (type: `integer`):

Maximum observed next-link or ArcGIS result pages per source. The default preserves the legacy one-request behavior.

## `deduplicate` (type: `boolean`):

Deduplicate records across sources and pages using normalized public identity fields.

## `licenseExpiryAlertDays` (type: `array`):

Days-ahead windows used for the EXPIRING_LICENSES key. Runtime bounds are 1 through 3650 days, with at most 10 windows.

## `webhookUrl` (type: `string`):

Optional public HTTPS destination for change events after useful records are saved and no source boundary is observed. Omit to keep alerts in Apify.

## `sourceTimeoutSecs` (type: `integer`):

Timeout for each source and policy request, from 5 to 1800 seconds.

## `timeoutSecs` (type: `integer`):

Legacy alias for sourceTimeoutSecs. Use one field; when both differ and one is 120, the nondefault value wins. Other conflicting values fail.

## `maxRequestRetries` (type: `integer`):

Retries only transient transport faults or HTTP 500, 502, and 504 responses. Policy failures, redirects, access restrictions, and HTTP 503 are not retried.

## `requestDelayMs` (type: `integer`):

Delay before public content requests. Requests remain sequential.

## `maxResponseBytes` (type: `integer`):

Fail closed when a public JSON or PDF response exceeds this limit.

## `userAgent` (type: `string`):

Optional transparent HTTP user-agent string.

## Actor input object example

```json
{
  "states": [
    "PA"
  ],
  "includeStateSources": true,
  "includeOfficialDetails": true,
  "maxResultsPerSource": 100,
  "maxPages": 1,
  "deduplicate": true,
  "licenseExpiryAlertDays": [
    30,
    60,
    90
  ],
  "sourceTimeoutSecs": 120,
  "timeoutSecs": 120,
  "maxRequestRetries": 1,
  "requestDelayMs": 0,
  "maxResponseBytes": 5242880,
  "userAgent": "CannabisPublicRegistryScraper/1.0"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Public business records collected from configured registry feeds.

## `runSummary` (type: `string`):

Three-field status summary stored under OUTPUT_SUMMARY in the run's default Key-value store.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("codingfrontend/cannabis-dispensary-scraper").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("codingfrontend/cannabis-dispensary-scraper").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 '{}' |
apify call codingfrontend/cannabis-dispensary-scraper --silent --output-dataset

```

## MCP server setup

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

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/F2FH1CmALWOnlAI30/builds/BsUol2aHHPyJiccWv/openapi.json
