
legends-dataforseo: verified Google SERP, Maps, keyword, backlink, and AI visibility intelligence for coding agents

Point a raw Python script or an ambient MCP wrapper at a search API and three things break silently: Google feeds automated requests synthetic decoy SERPs where the top ten barely resembles a real browser, organic URLs arrive wrapped in opaque google.com/goto redirect links, and an eight-megabyte JSON response floods your coding agent’s context window on the very first turn.
The human is the controller. The agents do the operating.
legends-dataforseo connects coding agents, CLI workflows, and Python applications to the 101-route DataForSEO API v3 catalog using only the Python 3.11+ standard library. Every command previews its payload and baseline cost offline by default (--dry-run), enforces fail-closed decoy SERP defense, independent SERP Truth Gate consensus, and automatic /goto domain unmasking on live organic pulls, guards against hidden 5x search-operator billing surcharges, and banks untouched responses on disk with SHA-256 verification.

Set up legends-dataforseo through cto-legends, run the offline doctor check,
and preview a Google SERP and keyword demand lookup without spending credits.

Plain english · Decoy SERP defense · 101-route catalog · Reference
Search intelligence in plain english
You should never have to hand-write JSON task payloads, calculate search-operator billing multipliers, or grep multi-megabyte SERP responses by hand. Describe the search evidence you need in plain english, and cto-legends routes the request to legends-dataforseo.

Here are four everyday jobs legends-dataforseo handles from a single sentence.
“Pull verified Google SERPs for our query.”
Your agent previews the organic search request first, then executes within your approved dollar ceiling with mandatory decoy SERP protection (resolve_poisoned_results: true), automatic Page-1 /goto redirect unwrapping, and fail-closed serp_integrity.verified stamping. If Google returns an unresolved decoy SERP, the transport raises UnverifiedSerpError instead of handing fake rankings to your downstream analysis.
“Check keyword volume and domain gaps.”
Whether you need monthly search volume and CPC demand (demand), SERP competitors (competitors), every keyword a domain ranks for (ranked-keywords), top ranking pages (relevant-pages), or multi-domain keyword intersections (domain-intersection), your agent previews the DataForSEO Labs call offline and caches the complete response on disk.
“Track where ChatGPT and Gemini cite us.”
Across the AI Optimization and Google AI Mode lanes (ai-mode advanced and raw HTML, llm-scraper for ChatGPT and Gemini search answers, llm-mentions across all 15 full and _lite citation, brand, category, multi-target, and timeseries endpoints, and llm-responses across ChatGPT, Claude, Gemini, and Perplexity), your agent measures exactly which domains, brands, and URLs frontier models cite and compares AI search visibility directly against verified Google organic rankings.
“Export this search research to my vault.”
Instead of leaving search research trapped inside a chat transcript, legends-dataforseo evidence packages raw JSON responses into content-addressed folders bound to a SHA-256 manifest and workspace ID. Sibling modules such as legends-empire, legends-geogrid, legends-firecrawl, and legends-github verify and reuse those packages offline without paying for duplicate lookups.
The 88% decoy SERP trap and fail-closed verification
When an automated client queries Google organic search without active anti-poisoning verification, Google frequently returns a decoy SERP: ten plausible-looking organic listings that do not match what a human sees in a real browser.
On November 20, 2026, we benchmarked 40 real keywords against logged-out Chrome page 1 as ground truth:
- Default unprotected SERP pulls: 35 of 40 queries (88%) returned a decoy SERP, with a median top-10 overlap of just
0.10 and the true #1 result matching only 6 of 40 times.
- With
resolve_poisoned_results enabled: Median top-10 overlap jumped to 0.90 (31 of 40 exact #1 matches, and 0 of 7 decoys across our technical CTO keyword subset).

Simply turning on a provider flag is not enough, because upstream resolve parameters are fail-open: if a resolve pass fails to swap a decoy, the API still returns HTTP 200. legends-dataforseo enforces a fail-closed verification pipeline on every organic SERP pull:
- Mandatory
resolve_poisoned_results: true on organic SERPs. Both serp() and raw api_request() enforce resolve_poisoned_results: true across live and standard-queue organic endpoints (live/advanced, live/regular, live/html, task_post), while rejecting URL-encoded udm=14 / udm=web parameters that bypass protection.
- The AI Overview (
AIO) Decoy Detector. Even when a decoy swaps out the organic list, Google’s AI Overview block still cites the real page-1 authorities. Whenever an AI Overview cites at least three domains and fewer than 60% of them appear anywhere in the organic top 20, assess_decoy_signals() flags suspect_decoy (achieving 1.0 precision and 1.0 recall on default benchmark rows) and triggers bounded retries or raises UnverifiedSerpError.
- Automatic
/goto Redirect Unmasking and Platform Resolution. When Google wraps organic items in /goto?url= or /url?q= links (raw_domain: google.com), legends-dataforseo unwraps Page-1 URLs automatically (depth <= 10) and extracts the true domain from the breadcrumb host or a closed WEBSITE_NAME_PLATFORMS allowlist (so an item whose breadcrumb is "30+ comments · 2 years ago" and whose website_name is "Reddit · r/philadelphia" resolves cleanly to resolved_domain: reddit.com and breadcrumb_path_hint: r/philadelphia, never guessing domains from random business names).
- Google 5x Search-Operator Surcharge Preflight Guard. Using any of Google’s 16 billed search operators (
site:, inurl:, intitle:, filetype:, cache:, allin*, etc.) multiplies provider task billing 5x. The preflight estimator detects all 16 operators (including quoted, parenthesized, or URL-encoded q= syntax) and floors the cost estimate before a single byte leaves your machine.
Why verified search transport beats raw scripts and ambient MCPs
Loading an always-on search MCP server injects dozens of tool schemas into Turn 0 of every session and streams raw multi-megabyte JSON payloads straight into your prompt context. Writing ad-hoc Python scripts is even riskier: a naive retry loop around a slow POST request can drain your DataForSEO balance in minutes.

legends-dataforseo covers 101 registered DataForSEO v3 routes across ten families with zero third-party Python dependencies:
| Family |
Included CLI & Python surfaces |
What you get |
| Organic & AI Mode SERP |
serp(), ai_mode(), serp-task-post, serp-task-get, ai-mode (advanced + html + queue), serp-ai-summary, serp-screenshot |
Google organic SERPs with mandatory decoy defense, independent SERP Truth Gate verification (serp_integrity.verified), automatic /goto domain unmasking, 5x operator cost guards, Google AI Mode (structured JSON + raw HTML), AI summaries, and SERP screenshots |
| AI Optimization (LLM) |
llm_scraper() / llm-scraper (ChatGPT + Gemini advanced / html / queue), llm_mentions() / llm-mentions (all 15 full + _lite, brands, categories, multi-target, historical, timeseries delta/new-lost), llm_responses() / llm-responses (ChatGPT, Claude, Gemini, Perplexity live + queue + free llm-models-*), ai-keyword-volume |
Direct ChatGPT and Gemini search scraping, flattened _lite and full LLM citation tracking (note: _lite carries the same $0.10/task + $0.001/row pricing as standard LLM Mentions), brand/category share of voice, historical mention deltas, and live or queued frontier model responses with 180 s AI transport timeouts |
| Google Maps & Local |
maps() / legends-dataforseo maps, local-finder, standard queue tasks |
Coordinate-locked Google Maps rank packs, Local Finder results, and bounded wait / wait_task() GET polling for legends-geogrid circular-lattice studies |
| Business Profiles |
business() / legends-dataforseo business, business-task-post, business-task-get |
Google Business Profile (my_business_info) lookups and queue refreshes by exact cid, place_id, or keyword |
| DataForSEO Labs |
demand(), competitors(), ranked_keywords(), relevant_pages(), keywords-for-site, domain-intersection, historical-serp, subdomains |
Monthly search volume, CPC, keyword difficulty, SERP competitors, domain keyword portfolios, multi-domain gap intersections, numeric keyword_properties.words_count filters, and historical rank snapshots |
| Domain Analytics |
domain_technologies() / domain-tech, domains-by-technology, domains-by-html-terms, aggregation-technologies, technologies-summary, technology-stats, whois-overview |
Website technology stack fingerprinting, technology adoption trends, HTML-term prospecting, and WHOIS registration records enriched with traffic and backlinks |
| Content Analysis |
content_analysis() / content-analysis (search, summary, sentiment, rating-distribution, phrase-trends, category-trends) |
Web citation inventories, positive/negative/emotional sentiment polarity distributions, rating distributions, and keyword or category citation trendlines |
| Backlinks |
referring-domains, anchors, backlinks-list |
Referring domain inventories, anchor text distributions, and individual backlink authority and spam verification |
| On-Page & Lighthouse |
content-parsing, lighthouse |
Structured page content extraction and Google Lighthouse technical performance and accessibility audits |
| Docs & Evidence Bank |
routes, route, estimate, docs search, docs read, view, evidence |
Offline route discovery, certifi-backed official DataForSEO docs search/cache, 66 ms dotted-path JSON slicing, and SHA-256 research evidence packaging for legends-empire and legends-firecrawl |
Optional MCP Plug-In: Legends Gambit (Open Beta)
Want verified search results and keyword demand without opening a vendor account?
This module stays 100% local, free, and MIT open source on your own accounts. That does not change.
If you want pay-per-run audits without vendor accounts or subscriptions, Legends Gambit (Legends Gambit: SEO MCP Server & Market Intelligence (by CTO Legends), open beta) is one optional MCP intelligence plug-in beside it:
- One Streamable HTTP endpoint (
https://gambit.cto-legends.com/mcp) and one Bearer API key. Works in Claude Code, Cursor, Antigravity, Claude Desktop, and OpenCode (open read-only initialize and tools/list discovery)
- Non-expiring prepaid wallet ($10 starter top-up), zero vendor accounts, zero subscriptions
- From $0.05/run: verified SERP ($0.05), keyword demand ($0.05 for up to 25 keywords), competitor teardown ($0.15), market dossier ($0.50), and circular hexagonal Google Maps rank grids ($0.04/hex point: $0.76 for 19 pts, $1.48 for 37 pts, up to $6.76 for 169 pts across 0.5-50 km radius, with a 19-page vector hex PDF)
- Anything above your per-call limit (default $0.25) is quoted first. Failed runs and 24-hour same-wallet repeats cost $0.00, and verified cache hits are at least 60% off
claude mcp add --transport http legends-gambit https://gambit.cto-legends.com/mcp --header "Authorization: Bearer YOUR_API_KEY"
Create an API key at gambit.cto-legends.com/wallet or read the docs at cto-legends.com/gambit. Prefer to run 100% locally? Keep reading. Everything below needs nothing from us.
Reference
Everything you need to run legends-dataforseo through your coding agent is in the guide above. Open these drawers for the CLI reference, Python API examples, credential configuration, and documentation links.
CLI reference and agent setup
Agent setup (via cto-legends)
Part of the cto-legends ecosystem. cto-legends is the only registered skill; this repository vendors a pinned copy at skills/cto-legends/SKILL.md. Install with cto-legends install legends-dataforseo and let the router resolve docs/AGENT-RECIPE.md on demand. Do not register this module as a standalone skill folder.
python -m pip install cto-legends
cto-legends install legends-dataforseo
cto-legends install legends-dataforseo --apply
cto-legends handoff legends-dataforseo
For a standalone virtual-environment install from a GitHub release wheel or checkout (docs/INSTALL.md):
python -m pip install -e .
legends-dataforseo --version
legends-dataforseo doctor
Every named command previews its exact v3 path, JSON request body, and cost parameters offline by default without opening a network socket:
legends-dataforseo serp "technical SEO" --location-code 2840
{
"preview": true,
"path": "/serp/google/organic/live/advanced",
"method": "POST",
"body": [{"language_code": "en", "keyword": "technical SEO", "depth": 10, "location_code": 2840,
"resolve_poisoned_results": true, "resolve_goto_urls": true}],
"estimated_cost_usd": null,
"max_cost_usd": null,
"truth_gate": {"consensus_provider": "firecrawl", "country": "US", "local_maps_check": false}
}
Explore all 101 routes, preview AI/LLM scrapers and mentions offline, calculate preflight cost estimates (including 5x search-operator detection), search official provider documentation, or slice saved responses in milliseconds:
legends-dataforseo routes
legends-dataforseo estimate maps --tasks 9 --depth 100
legends-dataforseo llm-scraper "best crm for agencies" --provider chatgpt --dry-run
legends-dataforseo llm-mentions "technical seo" --endpoint target-metrics-lite --dry-run
legends-dataforseo ai-mode "technical SEO" --mode html --expand-citations --dry-run
legends-dataforseo demand "technical SEO" "local SEO"
legends-dataforseo docs search "google maps task_post" --limit 3
legends-dataforseo docs read serp/google/maps/task_post
legends-dataforseo view results.json --select tasks.0.result.0.items --limit 3
legends-dataforseo view results.json --summary
Paid CLI calls require three explicit flags (--execute, --estimated-cost-usd, and --max-cost-usd) and abort before opening a socket if the preflight floor exceeds your ceiling. Existing --output files are refused before HTTP so saved research is never overwritten. See docs/CLI.md and docs/FIRST-USE.md.
Python API, credentials, and architecture
Credentials
Set DATAFORSEO_LOGIN (or DATAFORSEO_USERNAME) and DATAFORSEO_PASSWORD in your shell or secret manager. The loader reads a complete process environment pair first, then the Windows user environment, and never mixes scopes or accepts secrets on command-line arguments (docs/INSTALL.md#credentials). Run legends-dataforseo doctor --live to verify authentication with a zero-charge check. Protected organic SERPs are also verified by the independent SERP Truth Gate, which by default calls https://api.firecrawl.dev/v2/search: set FIRECRAWL_API_KEY in the environment (or the Windows user environment, unless FIRECRAWL_DISABLE_USER_ENV=1), or supply your own independent view in Python. legends-dataforseo doctor reports firecrawl_api_key_configured as a boolean and never prints the key.
Python API
from legends_dataforseo import api_request, serp
# Verified organic SERP pull with mandatory decoy defense & /goto unmasking:
organic = serp(
"technical SEO consultant",
location_code=2840,
confirm=True,
consumer="my-app",
estimated_cost_usd=0.005,
max_cost_usd=0.01,
)
print(organic["legends_serp"]["verified"], organic["legends_serp"]["verified_basis"])
# Standard-queue Google Maps task submission:
response = api_request(
"/serp/google/maps/task_post",
[{"keyword": "coffee", "location_coordinate": "40.7128,-74.0060,15z",
"language_code": "en", "depth": 100, "priority": 1}],
confirm=True,
consumer="my-app",
estimated_cost_usd=0.01,
max_cost_usd=0.01,
)
for task in response.get("tasks") or []:
print(task.get("id"), task.get("status_code"))
Paid submissions are never placed inside automatic retry loops or switched between accounts. Retrieve saved queue tasks with api_request("/serp/google/maps/task_get/advanced/" + task_id) or wait_task(). Status 40102 indicates an empty search result for that coordinate or query, not a transport error. See docs/API.md.
Architecture & documentation map
Caller (Coding Agent, CLI, or Python App)
-> 101-route registry, 5x operator cost guard & offline --dry-run preview
-> Single-request HTTPS v3 transport (no blind POST retries)
-> Decoy SERP detector (resolve_poisoned_results + AIO backstop + SERP Truth Gate) & /goto unmasker
-> Untouched JSON envelope on disk + SHA-256 evidence bank (`legends-dataforseo evidence`)
FAQ, support, and attribution
- Does
legends-dataforseo make paid API calls by default?
No. Named CLI commands (serp, ai-mode, llm-scraper, llm-responses, llm-mentions, maps, business, demand, competitors, ranked-keywords, relevant-pages, domain-tech, content-analysis) preview the request payload and baseline cost offline by default (--dry-run). Paid execution requires --execute, --estimated-cost-usd, and --max-cost-usd on the CLI, or confirm=True in Python.
- What happens if Google returns a decoy SERP on a live organic pull?
Every organic pull enforces
resolve_poisoned_results: true, checks the response against the suspect_decoy detector (including the AI Overview domain-overlap backstop), and raises UnverifiedSerpError (CLI exit code 2) if the SERP remains unverified, preventing poisoned rankings from entering your reports or legends-firecrawl scrape-serp pipelines.
- Do I need DataForSEO credentials to explore routes or run tests?
No. Route discovery (
routes, route, estimate), offline previews, and the full pytest test suite run locally without credentials across Windows, Linux, and macOS.
- Support & security: Report a bug or request a feature ·
CONTRIBUTING.md · SUPPORT.md · CODE_OF_CONDUCT.md · SECURITY.md
- License & provenance: Released under the MIT License. See
NOTICE, THIRD_PARTY_NOTICES.md, CITATION.cff, and docs/PROVENANCE.md. Independent open-source software, not an official DataForSEO SDK.
Start here
Paste the agent handoff block at the top of this page into your coding agent, preview any of the 101 DataForSEO v3 routes offline, and run verified search intelligence with zero decoy SERPs and zero context bloat.

Running a company or technical SEO operation and want verified search intelligence, AI citation tracking, and local evidence banking wired directly into your stack? Message Avalon Reset at cto-legends.com/dm. The desk is async, so the conversation starts the moment you write and nobody forces you onto a sales call.

Specification & benchmarks on cto-legends.com:
评论