# Keyword Research Tool — Seed Keywords to Thousands of Ideas (`amassuo/semrush-keyword-expander`) Actor

Turn a few seed keywords into thousands of keyword ideas: related keywords, question keywords and broad-match variants, each with search volume, keyword difficulty, CPC and competition. Excel export included.

- **URL**: https://apify.com/amassuo/semrush-keyword-expander.md
- **Developed by:** [Aperox](https://apify.com/amassuo) (community)
- **Categories:** SEO tools, Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 9 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 3.07 out of 5 stars

## Pricing

from $8.00 / 1,000 keyword ideas

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

## Keyword Research & Expansion (Semrush)

Turn a handful of seed keywords into **thousands of keyword ideas** — related keywords,
question keywords, and broad-match variants — each with search volume, keyword difficulty,
CPC and competition. Excel export included.

### How it works

```
seeds ─┬─▶ phrase_related     (semantically related)   ~40 units/row
       ├─▶ phrase_questions   (how/what/why searches)  ~40 units/row
       └─▶ phrase_fullsearch  (broad-match variants)   ~20 units/row
                    │
        dedup across seeds & sources ─▶ sort by volume ─▶ dataset + Excel
```

### ⚠️ Billing model (read before pricing)

Unit costs were **measured against a live key**, and they differ per report:

| Report | Cost | Billing event |
|---|---|---|
| `phrase_related` | ~40 units/row | `keyword` |
| `phrase_questions` | ~40 units/row | `keyword` |
| `phrase_fullsearch` | ~20 units/row | `keyword_broad` |

That's **4× and 2×** the cost of `domain_organic` (10 units/row) used by the other
actors — so this one must be priced higher. Two events keep revenue aligned with the
report actually used.

**Keyword Difficulty is free here.** These reports include `Kd` at no extra cost, unlike
`phrase_kdi` (50 units/row). Always request it.

Rows are charged **on fetch**, because Semrush bills every returned row. Duplicates across
seeds/sources are removed from your output but were still billed by Semrush.

### Safety rails

- **Seed dedup** — `seo tools` and `SEO TOOLS` count once.
- **`limitPerSeed`** — bounds cost per seed per source.
- **Server-side filters** (`minVolume`, `maxDifficulty`, `excludeKeywords`) applied by
  Semrush *before* billing, so narrowing genuinely costs less.
- **Charge-limit guard** — per-event; stops before spending unbillable units.
- **Units pre-flight** — estimates cost and warns if your balance is short.
- **Per-report error isolation** — one failing report doesn't kill the run.

### Setup

Set **`SEMRUSH_API_KEY`** as a secret environment variable on the actor.

### Run locally

```bash
cd semrush-keyword-expander
npm install
$env:SEMRUSH_API_KEY = "your-semrush-api-key"   # PowerShell
node src/main.js
```

Example input:

```json
{
  "seedKeywords": ["seo tools", "email marketing"],
  "sources": ["related", "questions", "broad"],
  "database": "us",
  "limitPerSeed": 200,
  "minVolume": 500,
  "maxDifficulty": 70
}
```

### Input

| Field | Meaning |
|---|---|
| `seedKeywords` / `seedKeywordsText` | starting keywords |
| `sources` | `related`, `questions`, `broad` (any combination) |
| `database` | country market (`us`, `uk`, `de`…) |
| `limitPerSeed` | ideas per seed per source — drives depth and cost |
| `minVolume` / `maxDifficulty` | server-side filters (also reduce cost) |
| `excludeKeywords` | drop keywords containing these terms |
| `xlsxOutput` | save formatted Excel (default on) |
| `semrushApiKey` | optional key override |

### Output

```json
{
  "keyword": "how much does email marketing cost",
  "volume": 590,
  "difficulty": 31,
  "cpc": 4.12,
  "competition": 0.35,
  "results": 120000,
  "seed": "email marketing",
  "sources": "question",
  "database": "us"
}
```

`sources` lists every expansion type that surfaced the keyword (e.g. `related, broad match`).

### Publish + pay-per-event

```bash
apify login
apify push
```

**Publication ▸ Monetization ▸ Pay per event** — delete the auto `apify-default-dataset-item`
"Result" event, then add:

| Event name | Title | Suggested price | Why |
|---|---|---|---|
| `keyword` | Keyword idea | **$0.008** | related + questions cost ~40 units |
| `keyword_broad` | Broad match keyword | **$0.004** | broad match costs ~20 units |

Note these are **4× and 2× the price** of your other actors' `keyword` event — because the
underlying reports cost 4× and 2× more. Do not copy the $0.002 price across.

### Roadmap

1. **Intent tagging** — classify each idea (informational / commercial / transactional).
2. **Clustering** — group ideas into topic clusters for content planning.
3. **Chained expansion** — feed top results back as seeds for a second wave.

# Actor input Schema

## `seedKeywords` (type: `array`):

A few starting keywords. Each one is expanded into hundreds of ideas.

## `seedKeywordsText` (type: `string`):

Alternative: paste seeds separated by new lines or commas.

## `sources` (type: `array`):

related = semantically similar keywords. questions = how/what/why searches (great for content). broad = variants containing your seed (cheapest).

## `database` (type: `string`):

Semrush country database: us, uk, de, fr, es, it, ca, au, in…

## `limitPerSeed` (type: `integer`):

How many ideas to pull for each seed and each expansion type. Drives depth and cost.

## `minVolume` (type: `integer`):

Ignore keywords below this monthly volume. Applied by Semrush before billing, so it also reduces cost.

## `maxDifficulty` (type: `integer`):

Only keep keywords at or below this difficulty (0-100). Great for finding easy wins.

## `excludeKeywords` (type: `array`):

Drop keywords containing any of these terms. Applied by Semrush before billing where possible, so it also reduces cost.

## `xlsxOutput` (type: `boolean`):

Also save a formatted Excel file to the run's key-value store.

## `semrushApiKey` (type: `string`):

Optional. Normally the operator sets SEMRUSH_API_KEY as an actor environment variable.

## Actor input object example

```json
{
  "seedKeywords": [
    "seo tools"
  ],
  "sources": [
    "related",
    "questions"
  ],
  "database": "us",
  "limitPerSeed": 200,
  "xlsxOutput": true
}
```

# Actor output Schema

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

One row per unique keyword idea: search volume, keyword difficulty, CPC, competition, the seed it came from and which expansion types surfaced it.

## `excel` (type: `string`):

Formatted spreadsheet of all keyword ideas, sorted by search volume.

# 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 = {
    "seedKeywords": [
        "seo tools"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("amassuo/semrush-keyword-expander").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 = { "seedKeywords": ["seo tools"] }

# Run the Actor and wait for it to finish
run = client.actor("amassuo/semrush-keyword-expander").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 '{
  "seedKeywords": [
    "seo tools"
  ]
}' |
apify call amassuo/semrush-keyword-expander --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,amassuo/semrush-keyword-expander"
        }
    }
}
```

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/inYcRmkB2hj4bKC0K/builds/qIZtfpbbHNPpQh5L4/openapi.json
