# Leafly Cannabis Strain Scraper (`lulzasaur/leafly-scraper`) Actor

Scrape cannabis strain data from Leafly. Get strain names, types (indica/sativa/hybrid), THC/CBD levels, effects, flavors, ratings, review counts, and terpene profiles from the largest cannabis database.

- **URL**: https://apify.com/lulzasaur/leafly-scraper.md
- **Developed by:** [lulz bot](https://apify.com/lulzasaur) (community)
- **Categories:** E-commerce
- **Features:** Limited permissions
- **Stats:** 8 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 results

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

## Leafly Cannabis Strain Scraper

Scrape cannabis strain data from [Leafly](https://www.leafly.com) -- the world's largest cannabis information resource with 6,000+ strain profiles.

### What it does

- **Browse mode**: Scrape all strains alphabetically, optionally filtering by type (indica/sativa/hybrid)
- **Search mode**: Search for specific strains by name
- **Detail mode**: Optionally fetch individual strain pages for full effects, flavors, terpenes, lineage, and medical conditions

Extracts data from Leafly's server-rendered **__NEXT_DATA__** -- no JavaScript rendering needed.

### Input Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `searchQueries` | array | Strain names to search for (e.g. "Blue Dream", "OG Kush"). Leave empty to browse all |
| `strainType` | string | Filter by type: indica, sativa, hybrid, or any |
| `maxResults` | integer | Max number of strains to scrape. Default: 20, max: 5000 |
| `includeDetails` | boolean | Fetch detail pages for full effects/flavors/description. Default: false |
| `proxyConfiguration` | object | Proxy settings (residential recommended) |

### Output Fields

Each result contains:

| Field | Type | Description |
|-------|------|-------------|
| `name` | string | Strain name (e.g. "Blue Dream") |
| `slug` | string | URL slug |
| `type` | string | indica, sativa, or hybrid |
| `thc` | number | Median THC percentage |
| `thcRange` | string | THC range (e.g. "17%-22%") |
| `cbd` | number | Median CBD percentage |
| `topEffect` | string | Primary reported effect |
| `effects` | array | Top 5 effects by user votes |
| `flavors` | array | Top 5 flavors (detail mode) |
| `rating` | number | Average user rating (0-5) |
| `reviewCount` | number | Number of user reviews |
| `topTerpene` | string | Dominant terpene |
| `terpenes` | array | Top 3 terpenes (detail mode) |
| `lineage` | array | Parent strain names (detail mode) |
| `helpsWith` | array | Medical conditions users report help with (detail mode) |
| `description` | string | Strain description |
| `imageUrl` | string | Strain photo URL |
| `sourceUrl` | string | Leafly strain page URL |
| `scrapedAt` | string | ISO 8601 timestamp |

### Example Output

```json
{
  "name": "Blue Dream",
  "slug": "blue-dream",
  "type": "hybrid",
  "thc": 21,
  "thcRange": "17%-24%",
  "cbd": 0,
  "topEffect": "relaxed",
  "effects": ["relaxed", "happy", "euphoric", "creative", "uplifted"],
  "rating": 4.34,
  "reviewCount": 15234,
  "topTerpene": "myrcene",
  "description": "Blue Dream is a sativa-dominant hybrid...",
  "imageUrl": "https://images.leafly.com/flower-images/...",
  "sourceUrl": "https://www.leafly.com/strains/blue-dream",
  "scrapedAt": "2026-04-26T10:00:00.000Z"
}
```

### Example Inputs

#### Browse all indica strains

```json
{
  "strainType": "indica",
  "maxResults": 50
}
```

#### Search for specific strains with full details

```json
{
  "searchQueries": ["Blue Dream", "OG Kush", "Girl Scout Cookies"],
  "includeDetails": true,
  "maxResults": 10
}
```

### How it works

1. Fetches Leafly's strain listing pages which contain server-rendered data in `__NEXT_DATA__`
2. Extracts strain profiles including THC/CBD levels, effects, ratings, and terpenes
3. Optionally fetches individual strain detail pages for enriched data (lineage, medical conditions, full descriptions)
4. Applies type and search filters client-side for precise results

# Actor input Schema

## `searchQueries` (type: `array`):

List of strain names to search for (e.g. 'Blue Dream', 'OG Kush'). Leave empty to browse all strains.

## `strainType` (type: `string`):

Filter by strain type.

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

Maximum number of strains to scrape.

## `includeDetails` (type: `boolean`):

Fetch individual strain pages for full details (effects, flavors, description). Slower but more data.

## `proxyConfiguration` (type: `object`):

Select proxies to be used by your scraper.

## Actor input object example

```json
{
  "searchQueries": [],
  "strainType": "",
  "maxResults": 20,
  "includeDetails": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

No description

## `csv` (type: `string`):

No description

# 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 = {
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("lulzasaur/leafly-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 = { "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    } }

# Run the Actor and wait for it to finish
run = client.actor("lulzasaur/leafly-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 '{
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call lulzasaur/leafly-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lulzasaur/leafly-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/K2ypq8BkfJmUXMSyf/builds/GHp8j0h2WJLktA0SN/openapi.json
