Stay organized with collections
Save and categorize content based on your preferences.
Thursday, December 22, 2011
For all the developers who have expressed interest in getting programmatic access to the search
queries data for their sites in Webmaster Tools, we've got some good news. You can now get access
to your search queries data in
CSV format
using a open source Python script from the
webmaster-tools-downloads
project. Search queries data is not currently available via the Webmaster Tools API, which has
been a common API user request that we're considering for the next API update. For those of you
who need access to search queries data right now, let's look at an example of how the search
queries downloader Python script can be used to download your search queries data and upload it
to a Google Spreadsheet in Google Docs.
Example usage of the search queries downloader Python script
If Python is not already installed on your machine, download and install
Python.
Create a folder and add the
downloader.py
script to the newly created folder.
Copy the
example-create-spreadsheet.py
script to the same folder as downloader.py and edit it to replace the example
values for website, email and password with valid values
for your Webmaster Tools verified site.
Open a Terminal window and run the example-create-spreadsheet.py script by entering
python example-create-spreadsheet.py at the terminal window command line.
Visit Google Docs to see a new spreadsheet containing your search queries data.
If you just want to download your search queries data in a .csv file without uploading the data to
a Google spreadsheet use
example-simple-download.py
instead of example-create-spreadsheet.py in the example above.
You could easily configure these scripts to be run daily or monthly to archive and view your
search queries data across larger date ranges than the current one month of data that is available
in Webmaster Tools, for example, by setting up a cron job or using Windows Task Scheduler.
An important point to note is that this script example includes user name and password credentials
within the script itself. If you plan to run this in a production environment you should follow
security best practices like using encrypted user credentials retrieved from a secure data storage
source. The script itself uses HTTPS to communicate with the API to protect these credentials.
Take a look at the search queries downloader script and start using search queries data in your
own scripts or tools. Let us know if you have questions or feedback in the
Webmaster Help Forum.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eWebmaster Tools users can now access their search queries data in CSV format using a Python script.\u003c/p\u003e\n"],["\u003cp\u003eThe provided script allows downloading data directly or uploading it to a Google Spreadsheet.\u003c/p\u003e\n"],["\u003cp\u003eWhile the Webmaster Tools API does not yet support search queries data, it's being considered for future updates.\u003c/p\u003e\n"],["\u003cp\u003eUsers can automate data retrieval using tools like cron jobs or Windows Task Scheduler for archiving and analysis over extended periods.\u003c/p\u003e\n"],["\u003cp\u003eSecurity best practices, such as using encrypted credentials, should be followed when running the script in production environments.\u003c/p\u003e\n"]]],["Developers can now access website search query data in CSV format using an open-source Python script. The script, found in the `webmaster-tools-downloads` project, downloads data and optionally uploads it to Google Spreadsheets. Users must install Python and the Google Data APIs Python Client Library, then modify and run either `example-create-spreadsheet.py` or `example-simple-download.py`. It's advised to employ secure credential management if implementing in production and to use HTTPS. This allows archiving data beyond the one-month window available in Webmaster Tools.\n"],null,["# Download search queries data using Python\n\n| It's been a while since we published this blog post. Some of the information may be outdated (for example, some images may be missing, and some links may not work anymore).\n\nThursday, December 22, 2011\n\n\nFor all the developers who have expressed interest in getting programmatic access to the search\nqueries data for their sites in Webmaster Tools, we've got some good news. You can now get access\nto your search queries data in\n[CSV format](https://en.wikipedia.org/wiki/Comma-separated_values)\nusing a open source Python script from the\n[webmaster-tools-downloads](https://code.google.com/p/webmaster-tools-downloads/)\nproject. Search queries data is not currently available via the Webmaster Tools API, which has\nbeen a common API user request that we're considering for the next API update. For those of you\nwho need access to search queries data right now, let's look at an example of how the search\nqueries downloader Python script can be used to download your search queries data and upload it\nto a Google Spreadsheet in Google Docs.\n\nExample usage of the search queries downloader Python script\n------------------------------------------------------------\n\n1. If Python is not already installed on your machine, download and install [Python](https://python.org/download/).\n2. Download and install the [Google Data APIs Python Client Library](https://code.google.com/apis/gdata/articles/python_client_lib).\n3. Create a folder and add the [`downloader.py`](https://code.google.com/p/webmaster-tools-downloads/source/browse/downloader.py) script to the newly created folder.\n4. Copy the [`example-create-spreadsheet.py`](https://code.google.com/p/webmaster-tools-downloads/source/browse/example-create-spreadsheet.py) script to the same folder as `downloader.py` and edit it to replace the example values for `website`, `email` and `password` with valid values for your Webmaster Tools verified site.\n5. Open a Terminal window and run the `example-create-spreadsheet.py` script by entering `python example-create-spreadsheet.py` at the terminal window command line.\n6. Visit Google Docs to see a new spreadsheet containing your search queries data.\n\n\nIf you just want to download your search queries data in a .csv file without uploading the data to\na Google spreadsheet use\n[`example-simple-download.py`](https://code.google.com/p/webmaster-tools-downloads/source/browse/example-simple-download.py)\ninstead of `example-create-spreadsheet.py` in the example above.\n\n\nYou could easily configure these scripts to be run daily or monthly to archive and view your\nsearch queries data across larger date ranges than the current one month of data that is available\nin Webmaster Tools, for example, by setting up a cron job or using Windows Task Scheduler.\n\n\nAn important point to note is that this script example includes user name and password credentials\nwithin the script itself. If you plan to run this in a production environment you should follow\nsecurity best practices like using encrypted user credentials retrieved from a secure data storage\nsource. The script itself uses HTTPS to communicate with the API to protect these credentials.\n\n\nTake a look at the search queries downloader script and start using search queries data in your\nown scripts or tools. Let us know if you have questions or feedback in the\n[Webmaster Help Forum](https://support.google.com/webmasters/community/label?lid=462896acb3879639&hl=en).\n\n\nWritten by\n[Jonathan Simon](/search/blog/authors/jonathan-simon),\nWebmaster Trends Analyst"]]