ScavioScavio
产品定价文档
登录开始使用
  1. 首页
  2. 教程
  3. 如何使用搜索 API 构建代理机构 AEO 仪表板
教程

如何使用搜索 API 构建代理机构 AEO 仪表板

构建面向客户的 AEO 仪表板,用于跟踪 AI 概览引用、答案引擎存在情况以及跨多个客户的引用共享。

获取免费API密钥API文档

答案引擎优化 (AEO) 是 SEO 机构不断增长的服务线,但大多数排名跟踪工具不能很好地跟踪 AI 概述引用或为其收取高价。使用搜索 API 构建自定义 AEO 仪表板使代理机构能够完全控制数据、每个客户的视图,并使每个关键字检查的成本可预测为 0.005 美元。本教程构建了一个多客户端 AEO 仪表板后端,用于跟踪引文存在、语音份额和趋势数据,然后输出可用于任何前端框架的 JSON。

前置条件

  • 已安装 Python 3.9+
  • 请求已安装库
  • 来自 scavio.dev 的 Scavio API 密钥
  • 要监控的客户端关键字列表

操作指南

步骤 1: 定义多客户端数据结构

设置将每个客户端映射到其域和目标关键字的配置。这是仪表板的输入。

Python
clients = {
    'client_a': {
        'domain': 'clienta.com',
        'name': 'Client A - SaaS CRM',
        'keywords': [
            'best crm for small business',
            'crm software comparison 2026',
            'what is a crm system',
            'crm vs spreadsheet'
        ]
    },
    'client_b': {
        'domain': 'clientb.io',
        'name': 'Client B - Project Management',
        'keywords': [
            'best project management tools 2026',
            'how to manage remote teams',
            'project management software comparison',
            'agile vs waterfall 2026'
        ]
    }
}

total_keywords = sum(len(c['keywords']) for c in clients.values())
print(f'{len(clients)} clients, {total_keywords} total keywords')
print(f'Monthly cost (daily checks): ${total_keywords * 30 * 0.005:.2f}')

步骤 2: 构建AEO数据采集功能

对于每个关键字,检查 SERP 中的 AI 概述是否存在并提取引文数据。记录客户端域是否被引用。

Python
import requests, os, time

API_KEY = os.environ['SCAVIO_API_KEY']

def collect_aeo_data(keyword: str, client_domain: str) -> dict:
    resp = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY, 'Content-Type': 'application/json'},
        json={'query': keyword, 'country_code': 'us'})
    data = resp.json()
    aio = data.get('ai_overview', {})
    has_overview = bool(aio and aio.get('text'))
    citations = aio.get('citations', []) if has_overview else []
    cited_domains = [c.get('domain', '') for c in citations]
    # Also check organic position
    organic_position = None
    for r in data.get('organic_results', []):
        if client_domain in r.get('link', ''):
            organic_position = r['position']
            break
    return {
        'keyword': keyword,
        'has_ai_overview': has_overview,
        'total_citations': len(citations),
        'client_cited': any(client_domain in d for d in cited_domains),
        'citation_position': next(
            (i + 1 for i, d in enumerate(cited_domains) if client_domain in d), None),
        'organic_position': organic_position,
        'competitor_domains': [d for d in cited_domains if client_domain not in d]
    }

步骤 3: 生成每个客户端的仪表板数据

将关键字级数据聚合为客户级指标:引用率、平均引用位置、有机重叠和主要竞争对手领域。

Python
from collections import Counter

def generate_client_dashboard(client_id: str, config: dict) -> dict:
    domain = config['domain']
    results = []
    competitor_counter = Counter()
    for kw in config['keywords']:
        data = collect_aeo_data(kw, domain)
        results.append(data)
        for d in data['competitor_domains']:
            competitor_counter[d] += 1
        time.sleep(0.3)
    total = len(results)
    with_aio = sum(1 for r in results if r['has_ai_overview'])
    cited = sum(1 for r in results if r['client_cited'])
    avg_cite_pos = 0
    cite_positions = [r['citation_position'] for r in results if r['citation_position']]
    if cite_positions:
        avg_cite_pos = sum(cite_positions) / len(cite_positions)
    return {
        'client_id': client_id,
        'client_name': config['name'],
        'domain': domain,
        'total_keywords': total,
        'keywords_with_aio': with_aio,
        'aio_rate': round(with_aio / max(total, 1) * 100, 1),
        'citations': cited,
        'citation_rate': round(cited / max(with_aio, 1) * 100, 1),
        'avg_citation_position': round(avg_cite_pos, 1),
        'top_competitors': competitor_counter.most_common(5),
        'keyword_details': results
    }

步骤 4: 构建完整的机构仪表板输出

为所有客户端运行仪表板并输出可供前端使用的 JSON 结构。包括每个客户的成本跟踪。

Python
import json
from datetime import date

def build_agency_dashboard(clients: dict) -> dict:
    dashboard = {
        'generated': date.today().isoformat(),
        'clients': [],
        'summary': {}
    }
    total_credits = 0
    for client_id, config in clients.items():
        print(f'Processing {config["name"]}...')
        client_data = generate_client_dashboard(client_id, config)
        dashboard['clients'].append(client_data)
        total_credits += len(config['keywords'])
    # Agency summary
    all_clients = dashboard['clients']
    dashboard['summary'] = {
        'total_clients': len(all_clients),
        'total_keywords': sum(c['total_keywords'] for c in all_clients),
        'avg_citation_rate': round(
            sum(c['citation_rate'] for c in all_clients) / max(len(all_clients), 1), 1),
        'total_credits': total_credits,
        'cost': f'${total_credits * 0.005:.2f}'
    }
    with open(f'aeo_dashboard_{date.today()}.json', 'w') as f:
        json.dump(dashboard, f, indent=2)
    return dashboard

dashboard = build_agency_dashboard(clients)
for c in dashboard['clients']:
    print(f'{c["client_name"]}: {c["citation_rate"]}% citation rate, {c["citations"]}/{c["keywords_with_aio"]} cited')

Python 示例

Python
import os, requests, time, json
from datetime import date
from collections import Counter

API_KEY = os.environ['SCAVIO_API_KEY']

def check_aeo(keyword, domain):
    resp = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY, 'Content-Type': 'application/json'},
        json={'query': keyword, 'country_code': 'us'})
    aio = resp.json().get('ai_overview', {})
    citations = aio.get('citations', []) if aio.get('text') else []
    domains = [c.get('domain', '') for c in citations]
    return {'keyword': keyword, 'has_aio': bool(aio.get('text')),
            'cited': any(domain in d for d in domains), 'domains': domains}

def client_report(name, domain, keywords):
    results = [check_aeo(kw, domain) for kw in keywords]
    cited = sum(1 for r in results if r['cited'])
    with_aio = sum(1 for r in results if r['has_aio'])
    print(f'{name}: {cited}/{with_aio} cited ({len(keywords)} keywords, ${len(keywords)*0.005:.3f})')

client_report('Demo Client', 'example.com', ['best crm 2026', 'crm comparison'])

JavaScript 示例

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;

async function checkAeo(keyword, domain) {
  const resp = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ query: keyword, country_code: 'us' })
  });
  const data = await resp.json();
  const aio = data.ai_overview || {};
  const domains = (aio.citations || []).map(c => c.domain || '');
  return { keyword, hasAio: Boolean(aio.text), cited: domains.some(d => d.includes(domain)) };
}

async function main() {
  const keywords = ['best crm 2026', 'crm comparison'];
  let cited = 0;
  for (const kw of keywords) {
    const r = await checkAeo(kw, 'example.com');
    if (r.cited) cited++;
    console.log(`${r.hasAio ? '+' : '-'}AIO ${r.cited ? '+CITED' : ''} ${kw}`);
  }
  console.log(`Citation rate: ${(cited/keywords.length*100).toFixed(0)}%`);
}

main().catch(console.error);

预期输出

JSON
2 clients, 8 total keywords
Monthly cost (daily checks): $1.20

Processing Client A - SaaS CRM...
Processing Client B - Project Management...

Client A - SaaS CRM: 50.0% citation rate, 1/2 cited
Client B - Project Management: 33.3% citation rate, 1/3 cited

Agency summary:
  Total clients: 2
  Total keywords: 8
  Avg citation rate: 41.7%
  Cost: $0.04

相关教程

  • 如何跟踪预算中的人工智能概述引用
  • 如何使用 API 隔夜批量检查 SEO 排名
  • 如何使用搜索数据构建运营仪表板

常见问题

大多数开发者在15到30分钟内完成本教程。您需要一个Scavio API密钥(免费套餐即可)和可用的Python或JavaScript环境。

已安装 Python 3.9+. 请求已安装库. 来自 scavio.dev 的 Scavio API 密钥. 要监控的客户端关键字列表. Scavio API密钥注册即送50个免费积分。

可以。免费套餐注册即送50个积分,完全足够完成本教程并构建一个可运行的原型解决方案。

Scavio提供原生LangChain包(langchain-scavio)、MCP服务器以及适用于任何HTTP客户端的REST API。本教程使用 the raw REST API, 但您可以根据需要适配您选择的框架。

相关资源

Best Of

2026年高性价比AEO追踪API推荐

Read more
Best Of

Google I/O 2026 AI模式变化后最佳搜索API

Read more
Glossary

搜索 API 供应商格局(2026)

Read more
Glossary

免费搜索API层级对比

Read more
Comparison

Search APIs (Scavio, Tavily, SerpAPI) vs Headless Browser (Playwright, Puppeteer, Browserbase)

Read more
Comparison

Google Places API vs SERP Local Pack API

Read more

开始构建

构建面向客户的 AEO 仪表板,用于跟踪 AI 概览引用、答案引擎存在情况以及跨多个客户的引用共享。

获取免费API密钥阅读文档
ScavioScavio

面向AI智能体的实时搜索API。搜索所有平台,不仅仅是Google。

产品

  • 功能
  • 定价
  • 控制台
  • 联盟计划

开发者

  • 文档
  • API参考
  • 快速开始
  • MCP集成
  • Python SDK

替代方案

  • Tavily替代方案
  • SerpAPI替代方案
  • Firecrawl替代方案
  • Exa替代方案

工具

  • JSON格式化
  • cURL转代码
  • Token计数器
  • 全部工具

© 2026 Scavio. 保留所有权利。

Featured on TAAFT
服务条款隐私政策