# SEO Forensics Agent (`bigasif/seo-analyzer-agent`) Actor

See how Google actually ranks a page. Audit, competitor gap, and content brief, each cited to the 2024 Google leak and real search patents.

- **URL**: https://apify.com/bigasif/seo-analyzer-agent.md
- **Developed by:** [khondokar md asiful islam](https://apify.com/bigasif) (community)
- **Categories:** Agents, SEO tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## SEO Analyzer Agent

An [Apify Actor](https://apify.com/actors) that runs a full SEO pass on **any URL** and returns structured data plus a Markdown report. Point it at a page and it will:

1. **On-page / technical audit** — crawl the page and flag issues across title, meta, headings, links, images, structured data, mobile & i18n. *(No API key needed.)*
2. **SERP & keyword research** — pull live Google results for the keyword and extract who ranks, People-Also-Ask, and related searches. *(Uses `apify/google-search-scraper`.)*
3. **AI content optimization** — generate an SEO content brief (title, meta, outline, entities, gaps, internal links, priority actions) with **Claude**. *(Needs an Anthropic API key.)*

Each job is independently toggleable, so it runs fine with just the audit, or all three together.

### Grounded in primary sources — live corpus lookup

The AI steps are grounded in the **2024 Google Content Warehouse leak** (14,022 attributes) and
**5,456 Google search patents**, bundled in `src/leakdata/` from the
[Missing Intent SEO skill](https://github.com/thebigasif/google-leak-patents-seo).

On **every run**, the Actor queries the real corpus for the page's situation: it detects intent
(commercial/reviews, local, YMYL, informational, thin, media-heavy) and retrieves the actual
matching ranking signals (with Google's own descriptions) and patents (with their actions).
Claude then follows an **evidence rule** — cite the real leak attribute (`Module.attributeName`)
or patent (`US…`), treat undocumented fields as existence-only, never invent weights — and applies
**Signal Projection** (optimize the *behavior* a signal measures, not the metric). The content
brief and keyword insights each return an `evidence` list with those citations, so every
recommendation is checkable.

**Two modes** (via `researchMode`): **Agentic** (default) gives Claude the corpus as tools
(`search_signals`, `search_patents`) and lets it decide what to research and iterate — like the
skill's router — with a structured synthesis at the end; the searches it ran appear in the report
under "What the agent researched." **Standard** retrieves the matching evidence deterministically
in one pass (faster, fewer API calls). Both surface a receipts section; if agentic research ever
fails it falls back to standard automatically.

Query engine: `src/leakdb.py` (reuses the skill's whole-word/camelCase matching);
per-page retrieval: `src/evidence.py`; agentic loop: `src/agent.py`.

### Input

| Field | Type | Notes |
|---|---|---|
| `targetUrl` | string (required) | The page to analyze. |
| `seedKeyword` | string | Primary keyword/topic. Inferred from the page title/H1 if omitted. |
| `runOnpageAudit` | boolean | Default `true`. Works with no API key. |
| `runKeywordResearch` | boolean | Default `true`. Consumes Apify credits (calls the Google SERP scraper). |
| `runContentOptimization` | boolean | Default `true`. Requires `anthropicApiKey`. |
| `anthropicApiKey` | string (secret) | Your `sk-ant-...` key. Stored encrypted; never logged. |
| `model` | select | `claude-opus-5` (default) · `claude-sonnet-5` · `claude-haiku-4-5`. |
| `researchMode` | select | **`agentic`** (default) — Claude queries the leak/patents with tools and iterates · `standard` — fast single-pass retrieval. |
| `country` | select | SERP localization (default `us`). |
| `resultsPerKeyword` | integer | Organic results to pull (default 10). |

### Output

- **Dataset**: one record with `onpage`, `serp`, `keyword_insights`, and `content_brief` sections.
- **Key-value store**: a rendered Markdown report under the key `REPORT`.

### Run it locally

```bash
pip install apify-cli            # or: npm i -g apify-cli
cd seo-agent
apify run --input '{"targetUrl":"https://example.com/","runKeywordResearch":false,"runContentOptimization":false}'
```

That command runs just the audit (no keys/credits). Add `anthropicApiKey` and flip the flags on to enable the AI and SERP steps.

### Deploy to Apify

```bash
apify login
apify push
```

### Notes

- The AI steps default to **Claude Opus 5** via the official `anthropic` SDK, using structured outputs so the brief is always valid JSON. Switch to Sonnet 5 or Haiku 4.5 for lower cost.
- The on-page audit is fully deterministic — no LLM, no keys — so it's cheap, fast, and reproducible.
- Keyword research relies on the `apify/google-search-scraper` Actor, which consumes platform usage.

### Roadmap ideas

- Multi-page crawl (audit a whole site, not one URL)
- Competitor backlink & content-gap comparison
- Internal-linking graph across the crawled pages
- Rank tracking over time (scheduled runs)

# Actor input Schema

## `targetUrl` (type: `string`):

The page you want to analyze and optimize (include https://).

## `seedKeyword` (type: `string`):

The main keyword or topic to research and optimize for. If left blank, it is inferred from the page's title and H1.

## `runOnpageAudit` (type: `boolean`):

Crawl the page and flag technical/on-page SEO issues (title, meta, headings, links, images, structured data). Works with no API key.

## `runKeywordResearch` (type: `boolean`):

Pull Google results for the keyword and extract competitors, People-Also-Ask, and related searches. Uses the apify/google-search-scraper Actor (consumes platform credits).

## `runContentOptimization` (type: `boolean`):

Generate an SEO content brief (title, meta, outline, entities, gaps, internal links) with Claude. Requires an Anthropic API key.

## `runCompetitorGap` (type: `boolean`):

Fetch and analyze the top-ranking pages for the keyword and show what they cover that your page doesn't (grounded in information gain, US11354342B2). The raw comparison works with no API key; the AI gap analysis needs one. Requires SERP research to be on.

## `competitorCount` (type: `integer`):

How many top-ranking pages to fetch and compare against (one per domain).

## `anthropicApiKey` (type: `string`):

Your Anthropic API key (sk-ant-...). Required for AI content optimization and keyword synthesis. Stored encrypted; never logged.

## `model` (type: `string`):

Which Claude model powers the AI steps.

## `researchMode` (type: `string`):

How the AI content brief is grounded. 'Agentic' lets Claude autonomously query the Google leak + patents with tools and iterate (deepest analysis, more API calls). 'Standard' retrieves the matching evidence in one pass (faster, cheaper).

## `country` (type: `string`):

Country to localize Google search results for.

## `resultsPerKeyword` (type: `integer`):

How many organic Google results to pull for the keyword.

## Actor input object example

```json
{
  "targetUrl": "https://example.com/",
  "runOnpageAudit": true,
  "runKeywordResearch": true,
  "runContentOptimization": true,
  "runCompetitorGap": true,
  "competitorCount": 4,
  "model": "claude-opus-5",
  "researchMode": "agentic",
  "country": "us",
  "resultsPerKeyword": 10
}
```

# 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 = {
    "targetUrl": "https://example.com/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("bigasif/seo-analyzer-agent").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 = { "targetUrl": "https://example.com/" }

# Run the Actor and wait for it to finish
run = client.actor("bigasif/seo-analyzer-agent").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "targetUrl": "https://example.com/"
}' |
apify call bigasif/seo-analyzer-agent --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=bigasif/seo-analyzer-agent",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/c2knAIuTPWGybC4X3/builds/Qmr5IzqfSbD99PJHf/openapi.json
