Try a request
curl https://api.nativeport.ai/dataforseo/v3/keywords_data/google_ads/search_volume/live \
-H "Authorization: Bearer $NATIVEPORT_API_KEY" \
-H "Content-Type: application/json" \
--data '[{
"keywords": ["web scraping api", "serp api", "ocr api"],
"location_code": 2840,
"language_code": "en"
}]'{
"cost": 0.0075,
"tasks": [{
"result": [
{"keyword": "web scraping api", "search_volume": 1900,
"competition": "HIGH", "cpc": 12.41},
{"keyword": "serp api", "search_volume": 12100,
"competition": "MEDIUM", "cpc": 7.83},
{"keyword": "ocr api", "search_volume": 1600,
"competition": "LOW", "cpc": 4.02}
]
}]
}Read the keyword metrics
Send your keywords with the location and language you want to research. The
request body is an array of task objects, even for a single task. Keyword results
are returned in tasks[0].result, and the top-level cost field reports the
request cost.
The competition field describes competition among advertisers in paid search.
It does not measure how difficult a keyword is to rank for organically. Use the
DataForSEO field reference
to interpret the metrics before using them in an SEO score.
The example below sorts keywords using search volume and a simple weight for advertising competition. Those weights are an illustration you can change; they do not predict rankings or the cost of winning a customer.
Search volume summarizes past searches. Check monthly data when you need to understand seasonality or recent changes, rather than relying on a single average.
Sort keywords by volume and advertising competition
Uses a simple, adjustable score to order your keyword list. Advertising competition is not organic ranking difficulty.
import json, os, sys, urllib.request
WEIGHT = {"LOW": 1.0, "MEDIUM": 0.5, "HIGH": 0.2}
req = urllib.request.Request(
"https://api.nativeport.ai/dataforseo/v3/keywords_data"
"/google_ads/search_volume/live",
data=json.dumps([{
"keywords": sys.argv[1:],
"location_code": 2840, # United States
"language_code": "en",
}]).encode(),
headers={
"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}",
"Content-Type": "application/json",
},
)
with urllib.request.urlopen(req) as r:
body = json.load(r)
rows = body["tasks"][0]["result"]
rows.sort(key=lambda k: (k["search_volume"] or 0) * WEIGHT.get(k["competition"], 0.2),
reverse=True)
print(f"{'keyword':<24} {'vol':>7} {'comp':<7} {'cpc':>6}")
for k in rows:
print(f"{k['keyword']:<24} {k['search_volume'] or 0:>7} "
f"{k['competition'] or '-':<7} {k['cpc'] or 0:>6.2f}")
print(f"\nthis call cost ${body['cost']}")$ python keywords.py "web scraping api" "serp api" "ocr api" keyword vol comp cpc serp api 12100 MEDIUM 7.83 ocr api 1600 LOW 4.02 web scraping api 1900 HIGH 12.41 this call cost $0.0075
Use it with NativePort
Use your NativePort key for keyword research and the search APIs you use alongside it. All requests draw from the same balance.
Before you start
Do I need to wait for a background job?
No. This live endpoint returns the result in the same request. NativePort does not support DataForSEO’s asynchronous task flow on this route.
Where do I find the cost?
The response’s top-level cost field reports the amount. NativePort bills that reported cost with nothing added per call, so you can record it alongside the keyword results.
How do I choose the location and language?
Use the codes for your target audience. The example uses location 2840 for the United States and language en for English. DataForSEO lists the supported values in its documentation.
Can I send several keywords at once?
Yes. Put them in the keywords array and keep each batch within the endpoint’s current limits. Check the DataForSEO reference before processing a large list.