0-PII GDPR-Safe Default ~80% Token Savings · mode="summary" Python · TypeScript · cURL · MCP 10 min build

Build a Trustpilot B2B Brand Reputation & 1–2 Star Crisis Alert Pipeline

Detect TrustScore drops, suspicious review-flagging spikes, and verified 1–2 star customer complaints before they hit enterprise renewal calls. This recipe combines Direct REST (httpx), the EdgeDataClient SDK pattern, and Claude/Cursor Hosted MCP with default 0-PII GDPR sanitization and mode="summary" to cut LLM token overhead by ~80%.

3 Endpoints
by-domain, transparency, and filtered reviews
~80% Less
LLM input tokens using mode="summary" vs raw JSON
0 Personal PII
Reviewer consumer PII stripped by default (GDPR-safe)
3 MCP Tools
trustpilot_lookup_company, _transparency, _reviews

1. Three-Step Reputation Pipeline & GDPR 0-PII Boundary

B2B SaaS, fintech, and vendor-risk teams rarely need to ingest raw HTML or store individual reviewer identities. A clean reputation pipeline chains three verified EdgeData REST endpoints (or their identical MCP tools) on a cron schedule or inside an AI agent:

STEP 1 · LOOKUP

Resolve Domain Baseline

POST /v1/trustpilot/companies/by-domain resolves stripe.com to trustScore, stars, numberOfReviews, and verification.

STEP 2 · TRANSPARENCY

Track Flagging Anomalies

POST /v1/trustpilot/companies/transparency exposes reportingStatistics (flagged/removed ratios) and invitation collection mix.

STEP 3 · CRISIS REVIEWS

Isolate Verified 1–2 Star Alerts

POST /v1/trustpilot/reviews filters stars: [1, 2], only_verified: true, and language: "en" for high-signal escalation.

GDPR-Safe 0-PII Architecture by Default

Every call to /v1/trustpilot/reviews and trustpilot_get_reviews enforces 0 personal PII sanitization by default (include_personal_data=false). All reviewer consumer identifiers—names, emails, avatars, profile URLs, and consumer IDs—are completely removed before payloads leave the gateway, while organizational metadata such as businessUnit.displayName is preserved for B2B reporting.

2. Production Python Crisis Alerting Script (Direct REST + SDK Equivalent)

The primary tab below uses standard httpx Direct REST against https://api.upp3.com/v1/trustpilot/* so you can copy, paste, and execute immediately in any Python 3.10+ environment with zero proprietary runtime dependencies. The second tab shows the equivalent EdgeDataClient SDK pattern for teams adopting the typed SDK.

Honest Runtime Note

Direct REST (httpx) is live and runnable immediately with any EdgeData Direct API key (X-API-Key). Install only pip install httpx, export EDGEDATA_API_KEY (and optional ALERT_WEBHOOK_URL), and run.

trustpilot_crisis_monitor.py — Direct REST (httpx)
import os
import sys
from datetime import datetime, timezone
import httpx

API_BASE = "https://api.upp3.com"
API_KEY = os.environ["EDGEDATA_API_KEY"]
WEBHOOK_URL = os.getenv("ALERT_WEBHOOK_URL")  # Optional Slack / Discord / PagerDuty webhook

WATCHLIST = [
    {"domain": "stripe.com", "min_trust_score": 2.5, "max_flagged_ratio": 0.15},
]


def post_trustpilot(client: httpx.Client, path: str, payload: dict) -> dict:
    resp = client.post(
        f"{API_BASE}{path}",
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json",
        },
        json=payload,
        timeout=30.0,
    )
    resp.raise_for_status()
    return resp.json().get("data", {})


def evaluate_brand(client: httpx.Client, rule: dict) -> dict:
    domain = rule["domain"]

    # 1) Resolve company baseline with mode="summary" (~80% fewer tokens)
    company = post_trustpilot(
        client,
        "/v1/trustpilot/companies/by-domain",
        {"domain": domain, "mode": "summary"},
    )

    # 2) Fetch transparency / flagging statistics
    transparency = post_trustpilot(
        client,
        "/v1/trustpilot/companies/transparency",
        {"domain": domain, "mode": "summary"},
    )

    # 3) Fetch verified 1-2 star English reviews (0-PII GDPR-safe by default)
    critical = post_trustpilot(
        client,
        "/v1/trustpilot/reviews",
        {
            "domain": domain,
            "stars": [1, 2],
            "only_verified": True,
            "language": "en",
            "page": 1,
            "mode": "summary",
        },
    )

    trust_score = float(company.get("trustScore") or 0.0)
    reporting = transparency.get("reportingStatistics") or {}
    flagged = int(reporting.get("flaggedReviews") or 0)
    total_reviews = max(1, int(company.get("numberOfReviews") or 1))
    flagged_ratio = round(flagged / total_reviews, 4)

    reviews = critical.get("reviews") or critical.get("items") or []
    alerts = []

    if trust_score and trust_score < rule["min_trust_score"]:
        alerts.append(
            f"TrustScore dropped to {trust_score} (threshold < {rule['min_trust_score']})"
        )
    if flagged_ratio > rule["max_flagged_ratio"]:
        alerts.append(
            f"Flagged review ratio elevated at {flagged_ratio:.1%} ({flagged} flagged)"
        )
    if len(reviews) >= 3:
        alerts.append(
            f"{len(reviews)} verified 1-2 star English reviews detected on page 1"
        )

    return {
        "checked_at": datetime.now(timezone.utc).isoformat(),
        "domain": domain,
        "display_name": company.get("displayName"),
        "trust_score": trust_score,
        "stars": company.get("stars"),
        "flagged_ratio": flagged_ratio,
        "verified_critical_sample_count": len(reviews),
        "sample_titles": [r.get("title") for r in reviews[:3] if isinstance(r, dict) and r.get("title")],
        "pii_included": False,
        "alerts": alerts,
    }


def dispatch_webhook(client: httpx.Client, report: dict) -> None:
    if not WEBHOOK_URL or not report["alerts"]:
        return
    body = {
        "text": (
            f"[Trustpilot Crisis Alert] {report['display_name'] or report['domain']} "
            f"(TrustScore: {report['trust_score']})\n- "
            + "\n- ".join(report["alerts"])
        ),
        "metadata": report,
    }
    resp = client.post(WEBHOOK_URL, json=body, timeout=15.0)
    resp.raise_for_status()


def main() -> int:
    with httpx.Client() as client:
        for rule in WATCHLIST:
            report = evaluate_brand(client, rule)
            print(report)
            if report["alerts"]:
                dispatch_webhook(client, report)
    return 0


if __name__ == "__main__":
    sys.exit(main())

3. mode="summary" vs Full Payload (~80% Token Savings + 0-PII JSON)

When feeding Trustpilot reviews into Claude, GPT, or an automated root-cause classifier, raw storefront objects contain deeply nested pagination graphs, localization tables, and UI display boilerplate. Passing "mode": "summary" projects only analytical fields and returns estimated_tokens_saved_pct directly in the response.

Full / Raw Payload (mode="raw") ~7,400 tokens / 3 calls

Full upstream JSON trees, nested category objects, UI badge metadata, and verbose review envelopes.

Summary Mode (mode="summary") ~1,480 tokens (~80% saved)

Projects trustScore, reportingStatistics, businessUnit.displayName, and 0-PII review excerpts.

Endpoint Full Payload (mode="raw") mode="summary" (Recommended) Est. Token Reduction
POST /v1/trustpilot/companies/by-domain ~1,450 tokens (raw profile + category trees) ~260 tokens (company_id, displayName, trustScore, stars, numberOfReviews) ~82% saved
POST /v1/trustpilot/companies/transparency ~1,150 tokens (full reporting & audit blocks) ~240 tokens (displayName, reportingStatistics, reviewStatistics) ~79% saved
POST /v1/trustpilot/reviews (1–2 star page) ~4,800 tokens (full review cards & UI metadata) ~980 tokens (0-PII stripped excerpts, star split, businessUnit.displayName) ~80% saved

Sample 0-PII mode="summary" JSON Output

JSON — Sanitized 0-PII Summary Payload (Zero Reviewer PII)
{
  "ok": true,
  "source": "trustpilot",
  "mode": "summary",
  "data": {
    "source": "trustpilot",
    "businessUnit": {
      "id": "4bf3f05e00006400050920c5",
      "displayName": "Stripe",
      "identifyingName": "stripe.com",
      "trustScore": 2.2,
      "stars": 2.0,
      "numberOfReviews": 16420
    },
    "totalCount": 3180,
    "returned_count": 20,
    "rating_distribution": { "1": 17, "2": 3 },
    "reviews": [
      {
        "rating": 1,
        "title": "Payout reserve held without clear escalation path",
        "text": "Verified merchant account experienced a 14-day rolling reserve with delayed support tickets...",
        "verified": true,
        "language": "en",
        "date": "2026-12-04T14:22:00Z"
      }
    ],
    "estimated_tokens_saved_pct": 80.4
  }
}

4. Claude Desktop & Cursor Hosted MCP Reputation Audit

Prefer an interactive analyst agent over a cron script? Connect Claude or Cursor to EdgeData’s Hosted Streamable HTTP MCP gateway (https://mcp.upp3.com/mcp). The server automatically defaults to mode="summary" across trustpilot_lookup_company, trustpilot_get_transparency, and trustpilot_get_reviews.

MCP Config — .cursor/mcp.json (Streamable HTTP)
{
  "mcpServers": {
    "edgedata": {
      "url": "https://mcp.upp3.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_EDGEDATA_API_KEY"
      }
    }
  }
}
Prompt — Copy-Paste into Claude / Cursor
Run a GDPR-safe B2B reputation crisis audit for stripe.com using EdgeData MCP tools (keep mode="summary" on every call):
1. Call trustpilot_lookup_company(domain="stripe.com", mode="summary") to get TrustScore, star rating, and total review volume.
2. Call trustpilot_get_transparency(domain="stripe.com", mode="summary") to inspect review flagging/removal ratios and invitation mix.
3. Call trustpilot_get_reviews(domain="stripe.com", stars=[1, 2], only_verified=true, language="en", page=1, mode="summary").

Deliver an executive risk brief with:
- Current TrustScore & transparency red-flag assessment
- Top 3 recurring root causes across verified 1-2 star reviews (billing, support SLA, onboarding, payouts)
- Severity classification (P1/P2/P3) and recommended customer-success action items
- Confirm zero reviewer PII appears in the report.

5. TypeScript (fetch) & cURL Production Snippets

Drop the exact same three-endpoint workflow into Node 18+, Cloudflare Workers, Next.js Route Handlers, or CI shell pipelines.

TypeScript — Zero-Dependency fetch Audit
const API_BASE = "https://api.upp3.com";
const API_KEY = process.env.EDGEDATA_API_KEY ?? "";

async function postTrustpilot<T>(path: string, body: Record<string, unknown>): Promise<T> {
  const res = await fetch(`${API_BASE}${path}`, {
    method: "POST",
    headers: {
      "X-API-Key": API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`EdgeData ${path} failed: ${res.status}`);
  const json = (await res.json()) as { data: T };
  return json.data;
}

export async function auditBrandReputation(domain: string) {
  const [company, transparency, critical] = await Promise.all([
    postTrustpilot<Record<string, unknown>>("/v1/trustpilot/companies/by-domain", {
      domain,
      mode: "summary",
    }),
    postTrustpilot<Record<string, unknown>>("/v1/trustpilot/companies/transparency", {
      domain,
      mode: "summary",
    }),
    postTrustpilot<Record<string, unknown>>("/v1/trustpilot/reviews", {
      domain,
      stars: [1, 2],
      only_verified: true,
      language: "en",
      page: 1,
      mode: "summary",
    }),
  ]);

  return { company, transparency, critical, piiIncluded: false };
}

auditBrandReputation("stripe.com").then(console.log);

6. Get Your Instant Free API Key & Run This Recipe

Provision a free EdgeData API key right here in seconds—no credit card required—and drop it into EDGEDATA_API_KEY or your Cursor/Claude MCP config.