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

BigCommerce supports multi-channel selling — your own storefront, Amazon, Facebook Shop, eBay, and more. Each channel has different audience expectations and content norms. You pull order data grouped by channel, analyze which product categories perform best where, then use Mave Agent to generate channel-specific content strategies backed by real sales data. Flow: BigCommerce GET /v3/orders (filter by channel_id) → Aggregate revenue per channel per category → Mavera POST /mave/chat → Channel-optimized content strategies

Architecture

Code

import os, requests, time
from collections import defaultdict

STORE = os.environ["BIGCOMMERCE_STORE_HASH"]
BC_TOKEN = os.environ["BIGCOMMERCE_ACCESS_TOKEN"]
MV = os.environ["MAVERA_API_KEY"]
BC = f"https://api.bigcommerce.com/stores/{STORE}/v3"
BC_HEADERS = {"X-Auth-Token": BC_TOKEN, "Content-Type": "application/json", "Accept": "application/json"}

CHANNELS = {1: "Storefront", 2: "Amazon", 3: "Facebook Shop", 4: "eBay"}
channel_data = defaultdict(lambda: {"revenue": 0, "orders": 0, "categories": defaultdict(lambda: {"revenue": 0, "units": 0})})

for ch_id, ch_name in CHANNELS.items():
    page = 1
    while True:
        r = requests.get(f"{BC}/orders",
            headers=BC_HEADERS,
            params={"channel_id": ch_id, "page": page, "limit": 50, "sort": "date_created:desc"})
        if r.status_code == 429:
            time.sleep(2); continue
        if r.status_code == 204: break
        r.raise_for_status()
        orders = r.json().get("data", [])
        if not orders: break

        for order in orders:
            total = float(order.get("total_inc_tax", 0))
            channel_data[ch_name]["revenue"] += total
            channel_data[ch_name]["orders"] += 1

            prods = requests.get(f"{BC}/orders/{order['id']}/products",
                headers=BC_HEADERS).json().get("data", [])
            for p in prods:
                cat = p.get("product_options", [{}])[0].get("display_name", "General")
                channel_data[ch_name]["categories"][cat]["revenue"] += float(p.get("total_inc_tax", 0))
                channel_data[ch_name]["categories"][cat]["units"] += int(p.get("quantity", 0))
            time.sleep(0.15)

        if len(orders) < 50: break
        page += 1
        time.sleep(0.2)

summary_lines = []
for ch, data in channel_data.items():
    aov = data["revenue"] / max(data["orders"], 1)
    top_cats = sorted(data["categories"].items(), key=lambda x: -x[1]["revenue"])[:3]
    cats_str = ", ".join(f"{c}(${d['revenue']:.0f})" for c, d in top_cats)
    summary_lines.append(f"{ch}: ${data['revenue']:.0f} revenue, {data['orders']} orders, AOV ${aov:.0f}. Top: {cats_str}")

summary = "\n".join(summary_lines)

strategy = requests.post("https://app.mavera.io/api/v1/mave/chat",
    headers={"Authorization": f"Bearer {MV}", "Content-Type": "application/json"},
    json={"message": f"""Analyze this multi-channel e-commerce performance data and generate
channel-specific content strategies.

For each channel: what content formats work best, recommended messaging angles,
budget allocation suggestion, and one specific campaign idea.

{summary}"""}).json()

print("--- Multi-Channel Content Strategy ---")
print(strategy.get("content", "")[:2000])

Example Output

--- Multi-Channel Content Strategy