There is usually a need to get search console data (namely, search terms, landing page data for blending which we will cover in another post). Search console data remains the primary source of search traffic to your own site from the google search engine which Google allows us to access. This data can also be linked to a Google analytics account where we can also glean information on site behaviour stemming from organic sources including landing page level conversion/transaction attribution (however the actual keywords are not directly obvious).
Extracting this in a programmatic way via python in this example is advantageous if you intend to automate or run more sophisticated enrichment (eg machine learning, topic labeling on the keywords for content optimization). Machine learning on SEO data is extremely useful and powerful!
Here is the code for it. You can run it out of colab directly.
-Your own Search console API keys and secret. You can get the instructions here.
-Your Google Cloud Service Account key to allow the outputs of the API calls to be be written into bigquery. You can get instructions to obtain the GCP service account details.