Yandex Webmaster API use case.

Yandex search ingine provides very powerfull Webmaster online web interface, but you can get most of it's useful information using Yandex Webmaster API and the power of Python. Then you can transform webmaster data in any easy-to-read format for postprocessing and visualisation.

You will need the same ACCESS_TOKEN, that we got in previous section about Yandex Metrika.

Yandex Webmaster API bot with Python.

Lets start from installing Yandex webmaster API library.

pip install yandex-webmaster-api

Then we should create client instance with your ACCESS_TOKEN.

from yandex_webmaster import YandexWebmaster
client = YandexWebmaster('')

Now we are ready to check available hosts for our credentials, we will need host IDs for the next steps.

hosts = client.get_hosts()

[{'ascii_host_url': '',
'host_id': '',
'main_mirror': None,
'unicode_host_url': '',
'verified': True},
{'ascii_host_url': '',
'host_id': '',
'main_mirror': None,
'unicode_host_url': '',
'verified': True}]

Then let's check if certain site is indexed and available for search.

result1 = client.get_host('')

{'ascii_host_url': '',
'host_data_status': 'OK',
'host_display_name': '',
'host_id': '',
'main_mirror': None,
'unicode_host_url': '',
'verified': True}

Now we are ready to display popular search queries for you site setting time period.

from datetime import datetime, timedelta
date_from = - timedelta(days=30)
date_to =
result2 = client.get_popular_search_queries('', date_from, date_to, query_indicator='TOTAL_SHOWS')
Popular queries.

Then let's check status and information about our sitemap file.

result3 = client.get_sitemaps(host_id='')

{'sitemaps': [{'children_count': 0,
'errors_count': 0,
'last_access_date': '2022-07-31T03:41:57.000+03:00',
'sitemap_id': '0500919e-ba70-32dd-a204-b970a136d873',
'sitemap_type': 'SITEMAP',
'sitemap_url': '',
'sources': ['ROBOTS_TXT', 'WEBMASTER'],
'urls_count': 138}]}

Now let's see site's indexing statistics and check if there are some problems.

result4 = client.get_indexing_stats(host_id='')

{'excluded_pages_count': 0,
'searchable_pages_count': 316,
'site_problems': {},
'sqi': 0}

Checking for site problems known by Yandex.

result5 = client.diagnostic_site(host_id='')
Site problems.

Check indexing information by pages.

result6 = client.get_indexing_samples(host_id='')
Pages indexing.

See also related topics: