Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mavera.io/llms.txt

Use this file to discover all available pages before exploring further.

Scenario

You know your own TrustScore — but how does it compare to competitors? Trustpilot lets you look up any business domain. You pull TrustScores for your competitors, compare distributions, and use Mave to analyze where you win and lose in the court of public opinion. Flow: Trustpilot GET /business-units/find?name={domain} (per competitor) → Compare scores → Mavera POST /mave/chat → Competitive positioning

Code

import os, requests, time

TP_KEY = os.environ["TRUSTPILOT_API_KEY"]
MV = os.environ["MAVERA_API_KEY"]
TP_BASE = "https://api.trustpilot.com/v1"
MV_H = {"Authorization": f"Bearer {MV}", "Content-Type": "application/json"}

DOMAINS = ["yourdomain.com", "competitor-a.com", "competitor-b.com", "competitor-c.com"]

# 1. Pull TrustScores for all domains
scores = []
for domain in DOMAINS:
    r = requests.get(f"{TP_BASE}/business-units/find",
        params={"apikey": TP_KEY, "name": domain})
    if r.status_code != 200:
        print(f"Could not find {domain}")
        continue
    bu = r.json()
    score_data = bu.get("score", {})
    scores.append({
        "domain": domain,
        "name": bu.get("displayName", domain),
        "trust_score": score_data.get("trustScore", 0),
        "stars": score_data.get("stars", 0),
        "total_reviews": bu.get("numberOfReviews", {}).get("total", 0),
        "star_distribution": bu.get("score", {}).get("distribution", {}),
    })
    time.sleep(0.2)

# 2. Pull sample reviews for each competitor
for s in scores:
    if s["domain"] == DOMAINS[0]:
        continue
    bu_id = requests.get(f"{TP_BASE}/business-units/find",
        params={"apikey": TP_KEY, "name": s["domain"]}).json().get("id", "")
    if not bu_id:
        continue
    revs = requests.get(f"{TP_BASE}/business-units/{bu_id}/reviews",
        params={"apikey": TP_KEY, "perPage": 10, "orderBy": "createdat.desc"}).json()
    s["recent_reviews"] = [
        f"[{r.get('stars',0)}★] {r.get('text','')[:150]}"
        for r in revs.get("reviews", [])[:5]
    ]
    time.sleep(0.2)

# 3. Mave competitive analysis
score_block = "\n".join(
    f"- {s['name']} ({s['domain']}): TrustScore={s['trust_score']}, Stars={s['stars']}, Reviews={s['total_reviews']}"
    for s in scores
)
review_block = "\n\n".join(
    f"## {s['name']}\n" + "\n".join(s.get("recent_reviews", []))
    for s in scores if s.get("recent_reviews")
)

analysis = requests.post("https://app.mavera.io/api/v1/mave/chat",
    headers=MV_H,
    json={"message": f"""Compare TrustScores across these competitors:

SCORES:
{score_block}

SAMPLE COMPETITOR REVIEWS:
{review_block}

Produce:
1. Where do we win on trust? (higher score, better sentiment)
2. Where do competitors beat us? (and why)
3. Messaging opportunities based on trust differential
4. Review volume strategy (if we have fewer reviews)
5. Specific claims we can make (e.g., "Highest TrustScore in [category]")"""}).json()

print("=== Competitive TrustScore Analysis ===")
print(analysis.get("content", "")[:1500])

Example Output

=== Competitive TrustScore Analysis ===

| Company | TrustScore | Stars | Reviews |
|---------|-----------|-------|---------|
| You | 4.5 | 5 | 340 |
| CompetitorA | 4.1 | 4 | 1,200 |
| CompetitorB | 3.8 | 4 | 890 |
| CompetitorC | 4.7 | 5 | 45 |

## Where We Win
- Highest TrustScore among established competitors (4.5 vs 4.1/3.8)
- Claim: "Rated 4.5/5 on Trustpilot — highest in our category"

## Where They Beat Us
- CompetitorA has 3.5x our review volume — perceived as more established
- CompetitorC has higher score (4.7) but only 45 reviews — not statistically robust

## Messaging Strategy
1. Use "Highest-rated" badge (vs established competitors)
2. Drive review volume to 500+ to match CompetitorA's perceived scale
3. Highlight trust differential in ads: "4.5 vs industry avg 4.0"

Error Handling

If a competitor isn’t on Trustpilot, GET /business-units/find returns 404. Skip gracefully and note the gap.
You can read public reviews for any business via the API. No special permissions needed beyond the API key.