Skip to content

Commit d0aafc0

Browse files
committed
fix(seo-geo): correct DataForSEO API endpoints and add null checks for domain metrics
1 parent 38b68c2 commit d0aafc0

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

skills/seo-geo/scripts/domain_overview.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,25 @@ def main():
1717
data = [{
1818
"target": args.domain,
1919
"location_code": args.location,
20-
"language_code": "en"
20+
"language_code": "en",
21+
"limit": 1 # We only need overview metrics
2122
}]
2223

23-
response = api_post("dataforseo_labs/google/domain_metrics_by_categories/live", data)
24+
response = api_post("dataforseo_labs/google/ranked_keywords/live", data)
2425
results = get_result(response)
2526

2627
print(f"domain: {args.domain}")
2728
print(f"location: {args.location}")
2829

2930
if results:
3031
for result in results:
31-
metrics = result.get("metrics", {}).get("organic", {})
32-
print(f"organic_traffic: {format_count(metrics.get('etv'))}")
33-
print(f"keywords: {format_count(metrics.get('count'))}")
34-
pos_1 = metrics.get("pos_1", 0)
35-
pos_2_3 = metrics.get("pos_2_3", 0)
36-
print(f"top_3_positions: {pos_1 + pos_2_3}")
32+
metrics = result.get("metrics", {})
33+
if not metrics:
34+
continue
35+
organic = metrics.get("organic", {})
36+
print(f"organic_keywords: {format_count(organic.get('count', 0))}")
37+
print(f"organic_traffic: {format_count(organic.get('etv', 0))}")
38+
print(f"top_3_positions: {organic.get('pos_1', 0) + organic.get('pos_2_3', 0)}")
3739
else:
3840
print("No results found")
3941

skills/seo-geo/scripts/keyword_research.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def main():
1616
args = parser.parse_args()
1717

1818
data = [{
19-
"keyword": args.keyword,
19+
"keywords": [args.keyword], # API requires 'keywords' array (up to 20)
2020
"location_code": args.location,
2121
"language_code": "en",
2222
"limit": args.limit
2323
}]
2424

25-
response = api_post("keywords_data/google/keywords_for_keywords/live", data)
25+
response = api_post("keywords_data/google_ads/keywords_for_keywords/live", data)
2626
results = get_result(response)
2727

2828
print(f"keyword: {args.keyword}")

0 commit comments

Comments
 (0)