Semrush API 访问需要每月 499.95 美元以上的商业计划,每个 API 调用都会消耗每月到期的单位。对于只需要有机 SERP 数据(排名、摘要、People Also Ask)的团队来说,这是一笔巨大的超支。 Scavio API 以每次查询 0.005 美元的价格返回相同的结构化 SERP 数据,除了每月 250 个积分之外,没有最低承诺。本教程展示如何将现有的 Semrush API 调用迁移到轻量级替代方案,并进行成本比较和直接替换功能。
前置条件
- 已安装 Python 3.9+
- 请求已安装库
- 当前要迁移的 Semrush API 集成
- 来自 scavio.dev 的 Scavio API 密钥
操作指南
步骤 1: 审核您当前的 Semrush API 使用情况
迁移之前,确定您实际使用的 Semrush 端点。大多数团队仅使用有机 SERP 数据、关键字概述和域分析。此步骤可帮助您了解需要更换的内容。
# Common Semrush API endpoints and their replacements:
endpoint_map = {
'domain_organic': 'Replace with SERP query for site:domain.com',
'phrase_organic': 'Replace with direct SERP query',
'keyword_difficulty': 'Not available via SERP API (keep Semrush for this)',
'backlinks_overview': 'Not available via SERP API (keep Semrush for this)',
'url_organic': 'Replace with SERP query for exact URL',
}
for endpoint, action in endpoint_map.items():
print(f'{endpoint}: {action}')步骤 2: 构建直接替换功能
创建一个与 Semrush 有机搜索调用具有相同接口的函数。它接受关键字并以标准化格式返回结构化结果。
import requests, os
API_KEY = os.environ['SCAVIO_API_KEY']
def serp_search(keyword: str, country: str = 'us', num_results: int = 10) -> list:
"""Drop-in replacement for Semrush phrase_organic endpoint."""
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': country})
resp.raise_for_status()
results = resp.json().get('organic_results', [])[:num_results]
return [{
'position': r['position'],
'url': r['link'],
'title': r['title'],
'snippet': r.get('snippet', ''),
} for r in results]步骤 3: 并排比较输出格式
验证替换函数返回等效数据。关键字段——位置、URL、标题、片段——直接映射。
results = serp_search('best project management software 2026')
for r in results[:3]:
print(f"#{r['position']} {r['title']}")
print(f" {r['url']}")
print(f" {r['snippet'][:80]}...")
print()步骤 4: 计算您节省的成本
比较 Semrush API 和轻量级替代方案之间的每月成本。考虑 Semrush 业务计划基本成本加上单位费用。
def compare_costs(monthly_queries: int) -> dict:
semrush_base = 499.95 # Business plan minimum
semrush_unit_cost = 0.01 # approximate per API unit
semrush_total = semrush_base + (monthly_queries * semrush_unit_cost)
scavio_cost = monthly_queries * 0.005
savings = semrush_total - scavio_cost
savings_pct = (savings / semrush_total) * 100
return {
'queries': monthly_queries,
'semrush_monthly': f'${semrush_total:,.2f}',
'scavio_monthly': f'${scavio_cost:,.2f}',
'savings': f'${savings:,.2f}',
'savings_pct': f'{savings_pct:.0f}%'
}
for vol in [5000, 20000, 50000]:
c = compare_costs(vol)
print(f"{c['queries']:,} queries: Semrush {c['semrush_monthly']} vs Scavio {c['scavio_monthly']} (save {c['savings']}, {c['savings_pct']})")步骤 5: 迁移您现有的代码库
查找并用新函数替换您的 Semrush API 调用。保留 Semrush 来获取需要其专有数据库的功能(关键字难度、反向链接索引)。使用轻量级 API 来获取所有 SERP 数据。
# Before (Semrush):
# from semrush_client import SemrushClient
# client = SemrushClient(api_key=SEMRUSH_KEY)
# results = client.phrase_organic(keyword='best crm', database='us')
# After (lightweight API):
results = serp_search('best crm', country='us')
# The rest of your pipeline stays the same:
for r in results:
print(f"#{r['position']} {r['url']}")Python 示例
import os, requests
API_KEY = os.environ['SCAVIO_API_KEY']
def serp_search(keyword: str, country: str = 'us') -> list:
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': country})
resp.raise_for_status()
return [{'position': r['position'], 'url': r['link'],
'title': r['title'], 'snippet': r.get('snippet', '')}
for r in resp.json().get('organic_results', [])]
def main():
keywords = ['best crm software', 'crm pricing 2026', 'hubspot alternatives']
for kw in keywords:
results = serp_search(kw)
print(f'{kw}: {len(results)} results')
if results:
print(f' #1: {results[0]["title"]}')
monthly = len(keywords) * 30
print(f'Projected monthly cost: ${monthly * 0.005:.2f} vs $499.95+ Semrush')
if __name__ == '__main__':
main()JavaScript 示例
const API_KEY = process.env.SCAVIO_API_KEY;
async function serpSearch(keyword, country = 'us') {
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: country })
});
const data = await resp.json();
return (data.organic_results || []).map(r => ({
position: r.position, url: r.link,
title: r.title, snippet: r.snippet || ''
}));
}
async function main() {
const keywords = ['best crm software', 'crm pricing 2026', 'hubspot alternatives'];
for (const kw of keywords) {
const results = await serpSearch(kw);
console.log(`${kw}: ${results.length} results`);
if (results.length) console.log(` #1: ${results[0].title}`);
}
console.log(`Projected: $${(keywords.length * 30 * 0.005).toFixed(2)}/mo vs $499.95+ Semrush`);
}
main().catch(console.error);预期输出
best crm software: 10 results
#1: Best CRM Software for 2026 - Forbes Advisor
crm pricing 2026: 10 results
#1: CRM Pricing Comparison Guide (Updated May 2026)
hubspot alternatives: 10 results
#1: 12 HubSpot Alternatives Worth Considering
Projected monthly cost: $0.45 vs $499.95+ Semrush
5,000 queries: Semrush $549.95 vs Scavio $25.00 (save $524.95, 95%)
20,000 queries: Semrush $699.95 vs Scavio $100.00 (save $599.95, 86%)
50,000 queries: Semrush $999.95 vs Scavio $250.00 (save $749.95, 75%)