SuperAPI AI 工具集

ahrefs-research

营销与增长

查看项目

更新于 10-16 03:05

技能介绍

用途:在 Python 中程序化访问 Ahrefs SEO 数据。官方 SDK ahrefs-python 依据 OpenAPI 规范生成,提供类型化请求与响应模型。主要能力覆盖 Site Explorer(外链、自然关键词、域名评级、流量、引用域)、Keywords Explorer(关键词研究、搜索量、难度、相关词)、Rank Tracker(SERP 与竞品监控)、Site Audit(技术 SEO 问题、页面内容与浏览)、Brand Radar(AI 品牌提及、声量份额、曝光)、SERP Overview 与 Batch Analysis(批量域名/URL 指标)。安装:pip3 install git+https://github.com/ahrefs/ahrefs-python.git,需 Python 3.11+,依赖 httpx、pydantic。SDK 含 52 个方法、7 个 API 分区,可用内置搜索快速定位:Python 中 from ahrefs.search import search_api_methods 调用 search_api_methods("domain rating"),或在终端用 python3 -m ahrefs.api_search "backlinks" --section site-explorer --limit 3,--sections 可列出全部分区。基本用法:通过环境变量 AHREFS_API_KEY 提供密钥,用 with AhrefsClient(...) 管理客户端;异步版本为 AsyncAhrefsClient,可配合 asyncio.gather 并行。方法名遵循 {api_section}_{endpoint},如 site_explorer_domain_rating、keywords_explorer_overview;返回类型化数据对象。注意事项:必须使用 SDK,不要直接发 httpx/requests 请求;日期统一用 YYYY-MM-DD 字符串;列表端点建议用 select 只取所需列,并用 limit 控制数量(无分页);不要在源码硬编码 API Key;客户端已自动处理 429、5xx 与连接错误重试,不要自行叠加重试;异常包括 AuthenticationError、RateLimitError、NotFoundError、APIError、APIConnectionError,均继承自 AhrefsError。where 参数为 JSON 字符串,可用 json.dumps() 构造。API 配额、价格与具体数据覆盖范围暂未提供。