semrush-research

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SemRush Research

SemRush 调研实操

Pull live SEO and competitive intelligence data from the SemRush API.
通过SemRush API获取实时SEO与竞争情报数据。

Prerequisites

前置条件

Requires
SEMRUSH_API_KEY
set in
.env
,
.env.local
, or
~/.claude/.env.global
.
bash
undefined
需要在
.env
.env.local
~/.claude/.env.global
文件中配置
SEMRUSH_API_KEY
bash
undefined

Verify the key is available

验证密钥是否已配置

echo "SEMRUSH_API_KEY is ${SEMRUSH_API_KEY:+set}"

If the key is not set, instruct the user:
> You need a SemRush API key. Get one at https://www.semrush.com/api/
> Then add `SEMRUSH_API_KEY=your_key` to your `.env` file.
echo "SEMRUSH_API_KEY is ${SEMRUSH_API_KEY:+set}"

如果未配置密钥,请告知用户:
> 你需要一个SemRush API密钥。可前往https://www.semrush.com/api/获取
> 然后在你的`.env`文件中添加`SEMRUSH_API_KEY=your_key`。

API Base

API 基础信息

All requests go to
https://api.semrush.com/
with the API key passed as
&key={SEMRUSH_API_KEY}
.
Responses are semicolon-delimited CSV. The first line is the header row. Parse accordingly.

所有请求均发送至
https://api.semrush.com/
,并通过
&key={SEMRUSH_API_KEY}
传递API密钥。
响应结果为分号分隔的CSV格式,第一行为表头,需按此解析。

1. Domain Overview

1. 域名概览

Get a high-level snapshot of any domain's organic and paid search performance.
获取任意域名自然搜索与付费搜索表现的高层快照。

Endpoint

接口地址

https://api.semrush.com/?type=domain_ranks&key={KEY}&export_columns=Dn,Rk,Or,Ot,Oc,Ad,At,Ac&domain={domain}
https://api.semrush.com/?type=domain_ranks&key={KEY}&export_columns=Dn,Rk,Or,Ot,Oc,Ad,At,Ac&domain={domain}

Export Columns

导出列说明

ColumnMeaning
Dn
Domain
Rk
SemRush Rank
Or
Organic keywords count
Ot
Organic traffic estimate
Oc
Organic traffic cost ($)
Ad
Paid keywords count
At
Paid traffic estimate
Ac
Paid traffic cost ($)
列名含义
Dn
域名
Rk
SemRush 排名
Or
自然关键词数量
Ot
自然流量估算值
Oc
自然流量成本(美元)
Ad
付费关键词数量
At
付费流量估算值
Ac
付费流量成本(美元)

Example curl

curl示例

bash
curl -s "https://api.semrush.com/?type=domain_ranks&key=${SEMRUSH_API_KEY}&export_columns=Dn,Rk,Or,Ot,Oc,Ad,At,Ac&domain=example.com"
bash
curl -s "https://api.semrush.com/?type=domain_ranks&key=${SEMRUSH_API_KEY}&export_columns=Dn,Rk,Or,Ot,Oc,Ad,At,Ac&domain=example.com"

Parsing the Response

响应结果解析

bash
undefined
bash
undefined

Response format (semicolon-delimited):

响应格式(分号分隔):

Dn;Rk;Or;Ot;Oc;Ad;At;Ac

Dn;Rk;Or;Ot;Oc;Ad;At;Ac

example.com;12345;8234;145000;234500;120;3400;5600

example.com;12345;8234;145000;234500;120;3400;5600

Parse with awk

使用awk解析

curl -s "..." | awk -F';' 'NR==2 { printf "Domain: %s\nSemRush Rank: %s\nOrganic Keywords: %s\nOrganic Traffic: %s\nOrganic Traffic Cost: $%s\nPaid Keywords: %s\nPaid Traffic: %s\nPaid Traffic Cost: $%s\n", $1,$2,$3,$4,$5,$6,$7,$8 }'

---
curl -s "..." | awk -F';' 'NR==2 { printf "域名: %s\nSemRush 排名: %s\n自然关键词: %s\n自然流量: %s\n自然流量成本: $%s\n付费关键词: %s\n付费流量: %s\n付费流量成本: $%s\n", $1,$2,$3,$4,$5,$6,$7,$8 }'

---

2. Keyword Overview

2. 关键词概览

Get search volume, CPC, competition, and SERP features for a keyword.
获取关键词的搜索量、CPC、竞争度及SERP特征。

Endpoint

接口地址

https://api.semrush.com/?type=phrase_all&key={KEY}&phrase={keyword}&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td
https://api.semrush.com/?type=phrase_all&key={KEY}&phrase={keyword}&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td

Export Columns

导出列说明

ColumnMeaning
Ph
Keyword phrase
Nq
Search volume (monthly)
Cp
CPC (USD)
Co
Competition (0-1)
Nr
Number of results
Td
Trend (12 months, comma-separated)
列名含义
Ph
关键词短语
Nq
月搜索量
Cp
单次点击成本(美元)
Co
竞争度(0-1)
Nr
搜索结果数量
Td
趋势(12个月数据,逗号分隔)

Example curl

curl示例

bash
curl -s "https://api.semrush.com/?type=phrase_all&key=${SEMRUSH_API_KEY}&phrase=content+marketing&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td"
bash
curl -s "https://api.semrush.com/?type=phrase_all&key=${SEMRUSH_API_KEY}&phrase=content+marketing&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td"

Supported Databases

支持的数据库

Use
&database=XX
where XX is:
us
,
uk
,
ca
,
au
,
de
,
fr
,
es
,
it
,
br
,
in
,
jp
.

使用
&database=XX
指定地区,XX可选值:
us
,
uk
,
ca
,
au
,
de
,
fr
,
es
,
it
,
br
,
in
,
jp

3. Related Keywords

3. 相关关键词

Find semantically related keywords for content planning and gap analysis.
查找语义相关的关键词,用于内容规划与差距分析。

Endpoint

接口地址

https://api.semrush.com/?type=phrase_related&key={KEY}&phrase={keyword}&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td&display_limit=20
https://api.semrush.com/?type=phrase_related&key={KEY}&phrase={keyword}&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td&display_limit=20

Example curl

curl示例

bash
curl -s "https://api.semrush.com/?type=phrase_related&key=${SEMRUSH_API_KEY}&phrase=project+management&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td&display_limit=20"
bash
curl -s "https://api.semrush.com/?type=phrase_related&key=${SEMRUSH_API_KEY}&phrase=project+management&database=us&export_columns=Ph,Nq,Cp,Co,Nr,Td&display_limit=20"

Parsing Multiple Rows

多行结果解析

bash
curl -s "..." | awk -F';' 'NR>1 { printf "%-40s Vol: %-8s CPC: $%-6s Comp: %s\n", $1, $2, $3, $4 }'

bash
curl -s "..." | awk -F';' 'NR>1 { printf "%-40s 搜索量: %-8s 单次点击成本: $%-6s 竞争度: %s\n", $1, $2, $3, $4 }'

4. Keyword Difficulty

4. 关键词难度

Estimate how hard it is to rank for a keyword.
估算关键词的排名难度。

Endpoint

接口地址

https://api.semrush.com/?type=phrase_kdi&key={KEY}&phrase={keyword}&database=us&export_columns=Ph,Kd
ColumnMeaning
Ph
Keyword
Kd
Keyword difficulty (0-100)
Interpretation:
  • 0-29: Easy - achievable with quality content
  • 30-49: Moderate - needs solid content + some backlinks
  • 50-69: Hard - needs strong domain authority + backlinks
  • 70-84: Very hard - requires established authority
  • 85-100: Extremely hard - dominated by top-tier domains

https://api.semrush.com/?type=phrase_kdi&key={KEY}&phrase={keyword}&database=us&export_columns=Ph,Kd
列名含义
Ph
关键词
Kd
关键词难度(0-100)
难度解读:
  • 0-29: 容易 - 优质内容即可实现排名
  • 30-49: 中等 - 需要优质内容+部分反向链接
  • 50-69: 困难 - 需要较高域名权重+反向链接
  • 70-84: 非常困难 - 需要成熟的域名权威
  • 85-100: 极难 - 由头部域名主导

5. Domain Organic Keywords

5. 域名自然关键词

See which keywords a domain ranks for organically.
查看域名自然排名的关键词列表。

Endpoint

接口地址

https://api.semrush.com/?type=domain_organic&key={KEY}&domain={domain}&database=us&export_columns=Ph,Po,Nq,Cp,Url,Tr,Tc&display_limit=50&display_sort=tr_desc
ColumnMeaning
Ph
Keyword
Po
Position
Nq
Search volume
Cp
CPC
Url
Ranking URL
Tr
Traffic (%)
Tc
Traffic cost
https://api.semrush.com/?type=domain_organic&key={KEY}&domain={domain}&database=us&export_columns=Ph,Po,Nq,Cp,Url,Tr,Tc&display_limit=50&display_sort=tr_desc
列名含义
Ph
关键词
Po
排名位置
Nq
搜索量
Cp
单次点击成本
Url
排名页面URL
Tr
流量占比(%)
Tc
流量成本

Example curl

curl示例

bash
curl -s "https://api.semrush.com/?type=domain_organic&key=${SEMRUSH_API_KEY}&domain=hubspot.com&database=us&export_columns=Ph,Po,Nq,Cp,Url,Tr,Tc&display_limit=20&display_sort=tr_desc"

bash
curl -s "https://api.semrush.com/?type=domain_organic&key=${SEMRUSH_API_KEY}&domain=hubspot.com&database=us&export_columns=Ph,Po,Nq,Cp,Url,Tr,Tc&display_limit=20&display_sort=tr_desc"

6. Backlink Overview

6. 反向链接概览

Get a summary of a domain's backlink profile.
获取域名反向链接配置文件的摘要信息。

Endpoint

接口地址

https://api.semrush.com/analytics/v1/?key={KEY}&type=backlinks_overview&target={domain}&target_type=root_domain&export_columns=total,domains_num,urls_num,ips_num,follows_num,nofollows_num,texts_num,images_num
https://api.semrush.com/analytics/v1/?key={KEY}&type=backlinks_overview&target={domain}&target_type=root_domain&export_columns=total,domains_num,urls_num,ips_num,follows_num,nofollows_num,texts_num,images_num

Example curl

curl示例

bash
curl -s "https://api.semrush.com/analytics/v1/?key=${SEMRUSH_API_KEY}&type=backlinks_overview&target=example.com&target_type=root_domain&export_columns=total,domains_num,urls_num,ips_num,follows_num,nofollows_num,texts_num,images_num"

bash
curl -s "https://api.semrush.com/analytics/v1/?key=${SEMRUSH_API_KEY}&type=backlinks_overview&target=example.com&target_type=root_domain&export_columns=total,domains_num,urls_num,ips_num,follows_num,nofollows_num,texts_num,images_num"

7. Competitor Discovery

7. 竞争对手发现

Find domains competing for the same organic keywords.
查找与目标域名竞争相同自然关键词的域名。

Endpoint

接口地址

https://api.semrush.com/?type=domain_organic_organic&key={KEY}&domain={domain}&database=us&export_columns=Dn,Cr,Np,Or,Ot,Oc,Ad&display_limit=10
ColumnMeaning
Dn
Competitor domain
Cr
Competition level
Np
Common keywords
Or
Organic keywords
Ot
Organic traffic
Oc
Organic traffic cost
Ad
Paid keywords
https://api.semrush.com/?type=domain_organic_organic&key={KEY}&domain={domain}&database=us&export_columns=Dn,Cr,Np,Or,Ot,Oc,Ad&display_limit=10
列名含义
Dn
竞争对手域名
Cr
竞争程度
Np
共同关键词数量
Or
自然关键词数量
Ot
自然流量
Oc
自然流量成本
Ad
付费关键词数量

Example curl

curl示例

bash
curl -s "https://api.semrush.com/?type=domain_organic_organic&key=${SEMRUSH_API_KEY}&domain=notion.so&database=us&export_columns=Dn,Cr,Np,Or,Ot,Oc,Ad&display_limit=10"

bash
curl -s "https://api.semrush.com/?type=domain_organic_organic&key=${SEMRUSH_API_KEY}&domain=notion.so&database=us&export_columns=Dn,Cr,Np,Or,Ot,Oc,Ad&display_limit=10"

8. Traffic Analytics (Estimates)

8. 流量分析(估算)

Estimate a domain's overall traffic sources and engagement.
估算域名的整体流量来源与用户参与度。

Endpoint

接口地址

https://api.semrush.com/analytics/ta/api/v3/summary?key={KEY}&targets={domain}&display_date=2024-01-01&country=us&export_columns=target,visits,users,bounce_rate,pages_per_visit,avg_visit_duration

https://api.semrush.com/analytics/ta/api/v3/summary?key={KEY}&targets={domain}&display_date=2024-01-01&country=us&export_columns=target,visits,users,bounce_rate,pages_per_visit,avg_visit_duration

Workflow: Full Competitive Analysis

工作流:完整竞争分析

When the user asks for a full competitive analysis, run these steps in order:
  1. Domain Overview - Get the target domain's metrics
  2. Competitor Discovery - Find top 5-10 competitors
  3. Domain Overview for each competitor - Compare metrics
  4. Top Keywords for each domain - Find keyword gaps
  5. Backlink Overview for each domain - Compare link profiles
当用户要求进行完整竞争分析时,按以下步骤执行:
  1. 域名概览 - 获取目标域名的各项指标
  2. 竞争对手发现 - 找出5-10个主要竞争对手
  3. 竞争对手域名概览 - 对比各竞争对手的指标
  4. 各域名核心关键词 - 发现关键词差距
  5. 各域名反向链接概览 - 对比链接配置文件

Output Format

输出格式

Present results as a comparison table:
| Metric              | target.com | competitor1.com | competitor2.com |
|---------------------|-----------|-----------------|-----------------|
| SemRush Rank        | ...       | ...             | ...             |
| Organic Keywords    | ...       | ...             | ...             |
| Organic Traffic     | ...       | ...             | ...             |
| Traffic Cost        | ...       | ...             | ...             |
| Backlinks           | ...       | ...             | ...             |
| Referring Domains   | ...       | ...             | ...             |
Then highlight:
  • Keyword gaps: Keywords competitors rank for but target does not
  • Quick wins: Keywords where target ranks positions 5-20 (improvement opportunities)
  • Content gaps: Topics competitors cover but target does not
  • Backlink opportunities: Sites linking to competitors but not target
以对比表格形式呈现结果:
| 指标              | target.com | competitor1.com | competitor2.com |
|---------------------|-----------|-----------------|-----------------|
| SemRush 排名        | ...       | ...             | ...             |
| 自然关键词数量    | ...       | ...             | ...             |
| 自然流量     | ...       | ...             | ...             |
| 流量成本        | ...       | ...             | ...             |
| 反向链接数量           | ...       | ...             | ...             |
| 引用域名数量   | ...       | ...             | ...             |
然后重点突出:
  • 关键词差距:竞争对手有排名但目标域名没有的关键词
  • 快速优化机会:目标域名排名在5-20位的关键词(有提升空间)
  • 内容差距:竞争对手覆盖但目标域名未涉及的主题
  • 反向链接机会:链接到竞争对手但未链接到目标域名的站点

Rate Limits and Costs

调用限制与成本

  • Each API call costs API units (check your plan)
  • Use
    &display_limit=
    to control result count (default varies by endpoint)
  • Cache results locally when doing multi-step analysis to avoid redundant calls
  • Domain overview calls are cheapest; backlink and traffic analytics cost more
  • 每次API调用消耗API点数(请查看你的套餐)
  • 使用
    &display_limit=
    控制返回结果数量(默认值因接口而异)
  • 多步骤分析时本地缓存结果,避免重复调用
  • 域名概览调用成本最低;反向链接与流量分析成本较高

Error Handling

错误处理

ErrorMeaning
ERROR 50 :: NOTHING FOUND
No data for this query
ERROR 120 :: WRONG KEY
Invalid API key
ERROR 130 :: LIMIT EXCEEDED
API unit limit reached
Empty responseUsually means no data available for the query parameters
When you get "NOTHING FOUND", try:
  • Different database (e.g.,
    uk
    instead of
    us
    )
  • Root domain instead of subdomain
  • Broader keyword phrase
错误信息含义
ERROR 50 :: NOTHING FOUND
该查询无数据返回
ERROR 120 :: WRONG KEY
API密钥无效
ERROR 130 :: LIMIT EXCEEDED
API点数已达上限
空响应通常表示查询参数对应的无可用数据
当收到“NOTHING FOUND”错误时,可尝试:
  • 更换数据库(例如用
    uk
    代替
    us
  • 使用主域名而非子域名
  • 使用更宽泛的关键词短语