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

Your competitors appear in industry news daily — product launches, funding rounds, executive hires, partnerships. This job searches for competitor mentions across all news sources, aggregates them by competitor, then runs the corpus through Mave for structured competitive intelligence: what they’re doing, how the market reacts, and what opportunities emerge for your brand. Flow: NewsAPI GET /everything?q={competitor} → Aggregate by entity → Mavera POST /mave/chat → Competitive intelligence brief

Code

import os, requests, time
from datetime import datetime, timedelta

NA_KEY = os.environ["NEWSAPI_KEY"]
NA_BASE = "https://newsapi.org/v2"
NA_H = {"X-Api-Key": NA_KEY}
MV = os.environ["MAVERA_API_KEY"]
MV_BASE = "https://app.mavera.io/api/v1"
MV_H = {"Authorization": f"Bearer {MV}", "Content-Type": "application/json"}

COMPETITORS = ["Competitor A", "Competitor B", "Competitor C"]
LOOKBACK_DAYS = 7
from_date = (datetime.now() - timedelta(days=LOOKBACK_DAYS)).strftime("%Y-%m-%d")

# 1. Search news for each competitor
all_articles = {}
for comp in COMPETITORS:
    r = requests.get(f"{NA_BASE}/everything", headers=NA_H, params={
        "q": f'"{comp}"', "from": from_date, "sortBy": "relevancy",
        "language": "en", "pageSize": 15,
    })
    if r.status_code == 429:
        print(f"Rate limited — skipping {comp}")
        continue
    r.raise_for_status()
    articles = r.json().get("articles", [])
    all_articles[comp] = articles
    print(f"{comp}: {len(articles)} articles")
    time.sleep(1)

# 2. Build competitor corpus
corpus_parts = []
for comp, articles in all_articles.items():
    corpus_parts.append(f"\n## {comp} ({len(articles)} articles)")
    for a in articles:
        corpus_parts.append(
            f"- [{a.get('source',{}).get('name','')}] {a['title']}\n"
            f"  {a.get('description','')[:250]}\n"
            f"  Published: {a.get('publishedAt','')[:10]}"
        )
corpus = "\n".join(corpus_parts)

# 3. Mave synthesis
analysis = requests.post(f"{MV_BASE}/mave/chat", headers=MV_H, json={
    "message": f"You are a competitive intelligence analyst. Analyze these news mentions from the past {LOOKBACK_DAYS} days.\n\n{corpus[:6000]}\n\n"
        "For EACH competitor provide:\n"
        "1. **Activity Summary** — What they shipped, announced, or changed\n"
        "2. **Media Sentiment** — Positive/negative/neutral tone across sources\n"
        "3. **Strategic Signal** — What this tells us about their direction\n"
        "4. **Our Opportunity** — Specific actions we should take in response\n\n"
        "End with a PRIORITY MATRIX: rank competitive threats by urgency (1-10) and impact (1-10)."
}).json()

print(f"\nCompetitive Intelligence Brief — {from_date} to today")
print(f"{'='*60}")
print(analysis.get("content", "")[:3000])

Example Output

Competitor A: 12 articles
Competitor B: 8 articles
Competitor C: 3 articles

Competitive Intelligence Brief — 2026-03-10 to today
============================================================

## Competitor A — High Activity
**Activity:** Launched enterprise tier with SOC 2 compliance. Hired VP Sales
from Salesforce. Announced Slack integration.
**Sentiment:** Positive (75%) — TechCrunch, VentureBeat praised UX.
**Signal:** Moving upmarket aggressively. Enterprise play confirmed.
**Our Opportunity:** They'll lose SMB focus. Double down on SMB messaging
and self-serve onboarding.

PRIORITY MATRIX:
| Competitor | Urgency | Impact | Action |
|------------|---------|--------|--------|
| A          | 8       | 9      | Counter enterprise narrative |
| B          | 5       | 6      | Monitor pricing changes |
| C          | 3       | 4      | No immediate action |

Error Handling

Wrap competitor names in double quotes ("Competitor A") to avoid partial matches. For common names, add industry terms: "Acme" AND "marketing platform".
Free tier searches back 1 month. Business tier goes back to 2019. Adjust LOOKBACK_DAYS accordingly.
NewsAPI may return syndicated copies. Deduplicate by title similarity before sending to Mave.