Fetching Search Console and Bing Data via API
A read-only Google service account and a Bing API key for a weekly script on my server, set up step by step in the German interfaces, with the mistakes to avoid.
Not reviewed by a person yet
Once the site was registered with Google and Bing (Registering a Website with Google and Bing), I wanted the numbers without clicking through two dashboards every week. A script on my server now collects them every Monday, and a scheduled Claude task turns them into a report with suggestions. The script needs two keys, and only I can create them, since they belong to my accounts. I set both up on 21 November 2026; the menu names below are the ones the German interfaces showed that day.
How it fits together
~/bin/seo-reporton the server runs every Monday at 5:30 UTC from cron and writes one JSON file per week to/srv/adrian-altner-com/seo/.- It has four parts: Google Search Console, Bing Webmaster Tools, Matomo and its own check of every page in the sitemap. A part without a key is skipped, the others still run.
--only google,bingruns single parts. - On Monday morning a scheduled Claude task fetches the file and compares it with the week before. It looks at the knowledge base and the recent news items and drops a report with checklists into the inbox of this knowledge base.
A dry run before the keys existed showed what happens without them: google: übersprungen (kein GSC_CREDENTIALS) and the same for Bing. The page check alone takes more than five minutes for about 780 pages.
Google › The project and the service account
The Search Console API only accepts OAuth 2.0. For a script without a person at the keyboard, that means a service account, a technical Google account with its own key. Read-only access is enough: the script uses the scope webmasters.readonly.
- Open the Google Cloud console. Without any project it shows a button Projekt erstellen.
- Name the project, for me
adrian-altner-com-seo. The project ID follows the name and cannot be changed later. Parent resource: Keine Organisation. The yellow note about the project quota is only information. - Menu, IAM und Verwaltung, Dienstkonten, Dienstkonto erstellen. Name
seo-report, optionally a description such as "Reads Search Console data for the weekly report". Check the ID before creating: it is also permanent, and a typo (mine wassee-report) would stay in the address forever. - Skip steps 2 and 3 (roles and principals) with Erstellen und schließen. The service account needs no roles in the project, so it does not show up on the IAM page, and that page needs no change.
- In the list of service accounts, under Aktionen, ⋮, Schlüssel verwalten, Schlüssel hinzufügen, Neuen Schlüssel erstellen, JSON. The browser downloads the file. It contains the private key, so treat it like a password and never paste it into a chat.
- Note the address of the service account:
[email protected].
Google › Activate the API
APIs und Dienste is not in the sidebar of IAM. The quickest way is the search bar at the top: type "Google Search Console API", open it and click Aktivieren. The page then shows status Aktiviert.
Nothing else is needed in the Cloud console. Under Anmeldedaten there is a menu Anmeldedaten erstellen with API key, OAuth client ID and service account: the script needs none of them, and the yellow note about the consent screen only concerns OAuth clients.
Google › Give the service account read access
Search Console is a separate site, not part of the Cloud console. The direct link to the users of a Domain property is https://search.google.com/search-console/users?resource_id=sc-domain:adrian-altner.com; otherwise Einstellungen, Nutzer und Berechtigungen.
- Nutzer hinzufügen.
- E-mail address: the address of the service account. The dialog had my own Gmail address filled in, which is wrong here.
- Permission: Eingeschränkt, the read-only level. Uneingeschränkt was preselected and is too much.
- Hinzufügen. The list then shows two users: me as owner and
seo-reportwith "Eingeschränkt".
Google › The key on the server
I copied the file from the Mac myself, so the key never passed through a chat:
ls ~/Downloads/adrian-altner-com-seo-*.json
scp ~/Downloads/<file>.json yaksha:/srv/adrian-altner-com/gsc-service-account.json
ssh yaksha 'chmod 600 /srv/adrian-altner-com/gsc-service-account.json && printf "GSC_CREDENTIALS=/srv/adrian-altner-com/gsc-service-account.json\n" >> /srv/adrian-altner-com/.env'
rm ~/Downloads/<file>.json
Bing › The API key
- In Bing Webmaster Tools, choose the site, then the gear at the top right (Einstellungen), API-Zugriff.
- Accept the terms the first time, then generate the API-Schlüssel.
There is one key per user, and it covers all sites of the account. If it leaks, delete it on the same page and generate a new one.
On the Mac, this writes it to the server without showing it and without leaving it in the shell history (zsh):
read -rs "BING?Bing-Schlüssel: " && echo && printf 'BING_WEBMASTER_KEY=%s\n' "$BING" | ssh yaksha 'cat >> /srv/adrian-altner-com/.env' && unset BING
Paste the key after the prompt and press Enter; nothing appears while you type.
Test it
~/bin/seo-report --only google --stdout
~/bin/seo-report --only bing --stdout
Both should report ok, with nothing under skipped and errors. My first results, three days after registering:
- Google: property
sc-domain:adrian-altner.com, data up to 18 November, because Search Console lags two to three days. 0 clicks, 0 impressions. The sitemap was read on 18 November without errors or warnings: 751 URLs submitted, 0 indexed yet. - Bing: works with the default address
https://adrian-altner.com/, soBING_SITE_URLis not needed for a site imported as a Domain property. 0 clicks so far. The crawl statistics showed eleven 301s and one 5xx. In Caddy's log the real Bingbot had only received 200 since 18 November; the 5xx probably dates from 17 November, when the site answered 502 for a while. - Bots that pretend to be Bingbot scan for
.envandserver.keyand get 404 or 429. The user agent alone proves nothing.
IndexNow in Bing
Bing Webmaster Tools has an IndexNow section. For a site that has not been matched yet it shows an introduction with Get Started and a freshly generated key. Ignore both. My key already lives in the environment file as INDEXNOW_KEY, and the key file at the root of the site returns 200 with the right content. The script ~/bin/indexnow reports changed pages after every push of the knowledge base, so far always with HTTP 200. A second key would only cause confusion. The statistics appear once Bing has matched the submissions to the site, which takes some days.
What is still open
- The first full weekly run with all four parts is on 23 November 2026.
- When Google indexes the first pages, and when Bing's IndexNow section shows the submissions.
- Microsoft recommends OAuth 2.0 over API keys. For a read-only weekly script on my own server, the key is enough for now.
Based on
-
Weekly search report for adrian-altner.com: setup
(
raw/2026/2026-11-18/weekly-search-report-for-adrian-altner-com-setup.md) [notes] -
Setting up the Search Console and Bing keys for seo-report
(
raw/2026/2026-11-21/setting-up-the-search-console-and-bing-keys-for-seo-report.md) [chat-2026-11-21]
Topic
- Search Engine Optimization Measures that help search engines find, understand and properly display pages. The basis is stable URLs, clear titles and internal links.
Builds on
- Registering a Website with Google and Bing Google Search Console via a DNS record at Cloudflare, Bing Webmaster Tools by import, then check sitemap and IndexNow.
See also
- Visitor Statistics from the Server Log with Matomo A self-hosted Matomo fed hourly from Caddy's access log: no tracking script, no cookies, masked IP addresses.