Skip to content

legends-dataforseo v0.1.12

Choose a tag to compare

@avalonreset avalonreset released this 21 Nov 15:11
· 17 commits to main since this release

legends-dataforseo v0.1.12 (2026-11-21)

Decoy SERP Defense (Fail Closed)

  • Fail-closed decoy SERP defense: Google serves automated clients decoy SERPs (plausible organic results that are not what a person sees). On the 2026-11-20 bench (40 keywords, real logged-out Chrome page 1 as truth), the DataForSEO default pull was a decoy on 35/40 (88%, median top-10 overlap 0.10, #1 match 6/40); with resolve_poisoned_results on, 3/40 (median overlap 0.90, #1 match 31/40, all three near-misses). The CTO keyword subset went from 7/7 decoys to 0/7.
  • resolve_poisoned_results: true is mandatory on every Google organic task (live/advanced, live/regular, live/html, task_post). serp() always sends it; raw api_request injects it when absent (estimate raised one page per injected task) and raises RouteError for an explicit non-true value or udm=14 / udm=web tasks. The only escape hatch is LEGENDS_DFS_ALLOW_POISONED=1 plus an explicit resolve_poisoned_results=False (--no-resolve-poisoned); those results are stamped integrity: unprotected, verified: false. The 0.1.12-draft opt-out LEGENDS_DATAFORSEO_RESOLVE_POISONED is retired.
  • SERP paths default to a 300 s timeout (SERP_TIMEOUT_S; resolved pulls can take 66 s+). api_request(timeout=None) and the CLI --timeout default select it; other paths keep 90 s.
  • New suspect_decoy detector (assess_decoy_signals, conservative DECOY_THRESHOLDS): AI Overview backstop (AIO cites at least 3 sites and at most 60% appear in organic top 20; P=R=1.0 on default bench rows, n=20; brand-label matching), second-pull instability (top-10 overlap at most 0.5), and caller incumbents (at most 0.2). Result age and Labs traffic did not separate decoys on the bench and are not scored. suspect_poisoned keeps precedence.
  • Goto-wrapped organic items: organic_item_site_key() keys items by resolved domain, breadcrumb host, then website_name slug, never google.com.
  • serp() pipeline: resolve pull, detector, re-pull a suspect_decoy with resolve (within max_poison_retries and cumulative max_cost_usd), and, with verify_no_swap=True, one cap-checked verification pull when resolve swapped nothing (the provider resolve is fail-open). A SERP still suspect ends as status: unverified_decoy (detected_status: suspect_decoy, unresolved: true); it is never relabelled clean.
  • Every organic serp_integrity block carries verified, integrity, verified_basis (provider_from_web, double_pull_stable or provider_clean_no_decoy_signals), signals_used and unverified_reasons (stamp_verified, stamp_envelope_verified). serp() raises UnverifiedSerpError (stamped envelope on .response) for any unverified protected SERP unless allow_unverified=True / --allow-unverified; the CLI exits 2 and prints the stamped response.
  • Transient task code 40101 (seen on concurrent same-keyword requests, cost 0) is retried with 2 s / 5 s / 10 s backoff, and serp() serializes same-keyword calls with a per-process lock.
  • legends_serp envelope block: integrity, verified, verification, per-attempt task IDs, task status codes, resolve flag, provider-reported cost, latency and status, final_status, totals.
  • Removed before release: decoy_traffic_check and the age / filler-traffic signals. site_traffic() and the bulk-traffic route remain as informational Labs helpers.

Hardening, Billing Guards & 53-Route Catalog Expansion

  • docs discovery uses the certifi-backed TLS context (HTTPSHandler(context=_ssl_context())), fixing CERTIFICATE_VERIFY_FAILED against docs.dataforseo.com on Windows Python 3.12, and docs search includes an actionable legends-dataforseo docs read parameter lookup hint when llms.txt yields zero matches.
  • resolve_goto_urls is no longer forced by the transport. serp(resolve_goto_urls=None) sends it for depth <= 10 (page-1 pulls, about 2-3 s) and omits it for deeper rank tracking (redirect unwrapping can add about 40 s; breadcrumb / website_name domain extraction is free). CLI: --resolve-goto-urls / --no-resolve-goto-urls. Raw api_request never injects it.
  • Organic path split and case-normalized routing: normalize_path lowercases v3 endpoint segments while preserving task_get ID case, _is_organic_serp_request_path enforces resolve_poisoned_results: true on live pulls and standard-queue task_post, and _is_organic_serp_result_path normalizes and stamps live pulls and standard-queue task_get. URL-encoded udm=14 / udm=web parameters are detected and rejected, including invalid udm + resolve_poisoned_results=true pairs under LEGENDS_DFS_ALLOW_POISONED=1.
  • Google organic 5x search-operator surcharge guard (SERP_OPERATOR_COST_MULTIPLIER = 5, has_serp_cost_multiplier_operator, estimate --keyword): detects all 16 billed Google operators (site:, inurl:, intitle:, filetype:, cache:, allin*, etc., including parenthesized/quoted/encoded syntax and url q= parameters) and floors organic preflight estimates in serp(), api_request(), and call previews against task depth (depth / max_crawl_pages), mandatory resolve pages, and operator multipliers.
  • Closed WEBSITE_NAME_PLATFORMS allowlist (website_name_target) and international /goto handling: a goto item whose breadcrumb is engagement text (30+ comments · 2 years ago) and whose website_name is Reddit · r/Phoenixville resolves to resolved_domain: reddit.com, breadcrumb_path_hint: r/Phoenixville, resolution_basis: website_name. Regional Google /goto hosts (google.co.uk, google.ca, google.com.au, etc.) are unmasked while unwrapped URLs with stale google.com domains keep goto_wrapped: false and legitimate Google product subdomains (developers.google.com, cloud.google.com) retain their site keys. Business names are never slug-guessed into domains.
  • Clean single pulls verify while zero-organic / unparsed HTML blocks fail closed. stamp_verified rejects unprotected tasks, organic_count == 0 blocks, non-clean blocks, any fired decoy signal and disagreeing or failed verification pulls, and stamps verified_basis as provider_from_web, double_pull_stable or provider_clean_no_decoy_signals. incumbent_sites is evaluated per attempt in serp() so surface-clean decoys trigger bounded retries before optional verify_no_swap pulls.
  • serp(verify_no_swap=False) is the new default so clean SERPs no longer double cost; pass verify_no_swap=True / --verify-no-swap for the double pull. When the cap cannot cover the second pull, verification is failed (max_cost_usd_insufficient_for_second_pull) and the SERP fails closed.
  • Route catalog grows from 30 to 53 routes, each with section and mode, with llm_mentions routes aligned to current DataForSEO v3 paths (/search_mentions/live, /top_mentioned_domains/live, /top_mentioned_pages/live, /target_metrics/live) plus aliases: serp-task-post, serp-task-get, local-finder, ai-mode, serp-ai-summary, serp-screenshot, keywords-for-site, historical-serp, domain-intersection, subdomains, ai-keyword-volume, llm-mentions-top-domains, llm-mentions-top-pages, llm-mentions-aggregated, llm-responses-chatgpt, llm-responses-claude, llm-responses-gemini, llm-responses-perplexity, referring-domains, anchors, backlinks-list, content-parsing, lighthouse.