Export keywords for a search query (export_keywords_csv)
export_keywords_csv — method exports the list of keywords for a search query. The naming of the fields in the report depends on the language of the Serpstat interface.
Response example |
|||||||||||
Keywords | The number of queries | CPC | Competition in PPC | Results found | Keywords (broad match) | Types of keywords | social_domains | Correct spelling | Keyword length | lang | difficulty |
tatoo girl | 320 | 0 | 1 | 1020000000 | 0 | video | amazon,vimeo,wikipedia,instagram | 2 | 5.97 | ||
tatoos on hand | 40 | 0 | 0 | 44200000 | 0 | yelp, |
tattoos on hand | 3 | en | 0.6 | |
10 | 0 | 0 | 57300000 | 0 | pinterest,youtube,facebook, |
tattoo words | 2 | en | 42.72 | ||
star wars |
10 | 0 | 0 | 21500000 | 0 | pinterest, |
star wars tattoo | 3 | en | 13.44 | |
10 | 0 | 0 | 3320000 | 0 | facebook |
tattoo kit | 2 | en | 0.01 | ||
kool tatoos | 50 | 0 | 0 | 1120000000 | 0 |
related_search |
pinterest,facebook | 2 | 0.01 | ||
10 | 0 | 0 | 26800 | 0 | pic | 3 | 0.01 |
http://api.serpstat.com/v3/export_keywords_csv?query=example&token=XXX&se=XXX
import codecs
import json
import pprint
import urllib.request as urlrequest
from urllib.parse import urlencode
host = 'http://api.serpstat.com/v3'
method = 'export_keywords_csv'
params = {
'query': 'buy%20laptop',
'se': 'g_us',
'token': 'ijmiom4f5m34905g03um8342dm04923lre3w'}
api_url = "{host}/{method}?{params}".format(
host=host,
method=method,
params=urlencode(params, safe=',')
)
try:
csv_data = urlrequest.urlopen(api_url).read()
except Exception as e0:
print("API request error: {error}".format(error=e0))
codecs.open('csv_data.csv', mode='w', encoding='utf8').write(csv_data.decode('utf8'))