dataforseo
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDataForSEO API Skill
DataForSEO API 技能
Universal interface to all DataForSEO APIs for comprehensive SEO data retrieval and analysis.
一个可对接所有DataForSEO API的通用接口,用于全面的SEO数据获取与分析。
Credential Setup
凭证设置
Before first use, set up credentials:
python
import sys, os
sys.path.insert(0, os.path.expanduser('~/.agents/skills/dataforseo/scripts'))
from dataforseo_client import save_credentials, verify_credentials首次使用前,请先设置凭证:
python
import sys, os
sys.path.insert(0, os.path.expanduser('~/.agents/skills/dataforseo/scripts'))
from dataforseo_client import save_credentials, verify_credentialsGet credentials from https://app.dataforseo.com/
login = "your_email@example.com" # API login (email)
password = "your_api_password" # API password (from dashboard)
login = "your_email@example.com" # API登录账号(邮箱)
password = "your_api_password" # API密码(从控制台获取)
Verify and save
验证并保存凭证
if verify_credentials(login, password):
save_credentials(login, password)
print("Credentials saved!")
Credentials stored at `~/.dataforseo_config.json`. To update, run setup again.if verify_credentials(login, password):
save_credentials(login, password)
print("凭证保存成功!")
凭证将存储在`~/.dataforseo_config.json`文件中。如需更新,重新运行上述设置步骤即可。Quick Start
快速开始
python
import sys, os
sys.path.insert(0, os.path.expanduser('~/.agents/skills/dataforseo/scripts'))
from dataforseo_client import *python
import sys, os
sys.path.insert(0, os.path.expanduser('~/.agents/skills/dataforseo/scripts'))
from dataforseo_client import *Example: Get search volume
示例:获取搜索量
response = keywords_search_volume(
keywords=["seo tools", "keyword research"],
location_name="United States"
)
results = extract_results(response)
csv_path = to_csv(results, "keyword_volumes")
print(f"Results saved to: {csv_path}")
undefinedresponse = keywords_search_volume(
keywords=["seo tools", "keyword research"],
location_name="United States"
)
results = extract_results(response)
csv_path = to_csv(results, "keyword_volumes")
print(f"结果已保存至: {csv_path}")
undefinedAPI Selection Guide
API选择指南
| User Request | Function to Use |
|---|---|
| Search volume, CPC, competition | |
| Keyword ideas/suggestions | |
| Keywords a site ranks for | |
| SERP results for keyword | |
| Local/Maps rankings | |
| YouTube rankings | |
| Backlink profile | |
| List of backlinks | |
| Referring domains | |
| Domain authority/rank | |
| Competing domains | |
| Keyword gap analysis | |
| Link gap analysis | |
| Technical page audit | |
| Lighthouse scores | |
| Technology stack | |
| Brand mentions | |
| Google Trends | |
| 用户需求 | 调用函数 |
|---|---|
| 搜索量、CPC、竞争度 | |
| 关键词灵感/建议 | |
| 网站排名关键词 | |
| 关键词SERP结果 | |
| 本地/地图排名 | |
| YouTube排名 | |
| 反向链接概况 | |
| 反向链接列表 | |
| 引荐域名 | |
| 域名权重/排名 | |
| 竞品域名 | |
| 关键词差距分析 | |
| 链接差距分析 | |
| 页面技术审计 | |
| Lighthouse评分 | |
| 技术栈分析 | |
| 品牌提及监测 | |
| Google Trends数据 | |
Core Workflow
核心工作流程
- Import client: Add skill path and import functions
- Call API function: Pass required parameters
- Extract results: Use
extract_results(response) - Export to CSV: Use
to_csv(results, "filename")
python
import sys, os
sys.path.insert(0, os.path.expanduser('~/.agents/skills/dataforseo/scripts'))
from dataforseo_client import labs_ranked_keywords, extract_results, to_csv
response = labs_ranked_keywords(
target="competitor.com",
location_name="United States",
language_name="English",
limit=500
)
results = extract_results(response)
csv_path = to_csv(results, "ranked_keywords")- 导入客户端:添加技能路径并导入函数
- 调用API函数:传入所需参数
- 提取结果:使用
extract_results(response) - 导出为CSV:使用
to_csv(results, "filename")
python
import sys, os
sys.path.insert(0, os.path.expanduser('~/.agents/skills/dataforseo/scripts'))
from dataforseo_client import labs_ranked_keywords, extract_results, to_csv
response = labs_ranked_keywords(
target="competitor.com",
location_name="United States",
language_name="English",
limit=500
)
results = extract_results(response)
csv_path = to_csv(results, "ranked_keywords")Default Parameters
默认参数
Most functions use these defaults:
- : "United States" (override with "India", "United Kingdom", etc.)
location_name - : "English"
language_name - : 100 (increase up to 1000 for more results)
limit - : "desktop" (or "mobile" for SERP)
device
多数函数使用以下默认值:
- : "United States"(可替换为"India"、"United Kingdom"等)
location_name - : "English"
language_name - : 100(最多可增加至1000以获取更多结果)
limit - : "desktop"(SERP查询可改为"mobile")
device
Common Location Names
常用地区名称
- United States, United Kingdom, India, Germany, Australia, Canada
- For city-level: "New York,New York,United States", "London,England,United Kingdom"
- United States, United Kingdom, India, Germany, Australia, Canada
- 城市级地区格式:"New York,New York,United States"、"London,England,United Kingdom"
Output
输出结果
All results export to CSV at . Files auto-named with timestamp if not specified.
~/dataforseo_outputs/所有结果将导出至CSV文件,存储路径为。若未指定文件名,系统将自动添加时间戳命名。
~/dataforseo_outputs/Reference Files
参考文件
- API Reference: - Complete endpoint documentation
references/api_reference.md - Use Cases: - Ready-to-use code recipes
references/use_cases.md
- API参考文档:- 完整的端点文档
references/api_reference.md - 使用案例:- 可直接使用的代码示例
references/use_cases.md
Error Handling
错误处理
python
response = some_api_function(...)
if response.get("status_code") == 20000:
results = extract_results(response)
# Process results
else:
print(f"Error: {response.get('status_message')}")python
response = some_api_function(...)
if response.get("status_code") == 20000:
results = extract_results(response)
# 处理结果
else:
print(f"错误信息: {response.get('status_message')}")Rate Limits & Costs
请求限制与成本
- 2000 requests/minute max
- Live methods cost more than Standard
- Check usage with
get_user_data() - Response includes field
cost
- 最大请求限制:2000次/分钟
- 实时接口成本高于标准接口
- 使用查询使用情况
get_user_data() - 响应结果包含字段显示本次请求成本
cost
Important Notes
重要提示
- Async endpoints: Some APIs (merchant, app_data, business reviews) create tasks. Check task status separately.
- Limits: Increase parameter for comprehensive data (default 100, max usually 1000)
limit - Multiple keywords: Pass as list:
keywords=["kw1", "kw2", "kw3"]
- 异步端点:部分API(电商平台、应用数据、商家评论)会创建任务,需单独查询任务状态。
- 结果数量限制:可增加参数以获取更全面的数据(默认100,通常最大为1000)
limit - 多关键词查询:以列表形式传入关键词:
keywords=["kw1", "kw2", "kw3"]