Pull Bing Webmaster Tools data with an API key: traffic, crawl and free keyword numbers
I wanted Bing’s numbers in my weekly report, next to Google’s. Bing Webmaster Tools made that easy: one API key for the whole account, one URL per method, https://ssl.bing.com/webmaster/api.svc/json/<Method>?siteUrl=…&apikey=…, and JSON back. What took care was the key sitting in that URL, data that only covers a moving window, and URLs Bing accepted and then didn’t index.
I already pulled Search Console through a service account, which took a Google Cloud project, a key file and a signed token every hour. Bing needed none of that. Without its retries, my whole client is a URL and json.load:
API = "https://ssl.bing.com/webmaster/api.svc/json"
def call(self, method, **params):
url = f"{API}/{method}?" + urllib.parse.urlencode({**params, "apikey": self.key})
with urllib.request.urlopen(url, timeout=60) as r:
return tidy(json.load(r).get("d"))
Every answer sits under d. tidy drops the __type field Bing adds to every object and turns Bing’s date strings into plain dates. Microsoft’s API page names this JSON endpoint as the one to use, and gave 31 August 2026 as the end of the older SOAP and POX ones.
The key is in the URL
That’s the first thing to watch. Anything that prints a failed URL, or the answer to one, prints the key with it. My error path swaps the key for <key> before it shows anything.
It’s also an account-wide key that can submit URLs, not just read. I’m on Windows, so I typed it into Read-Host -AsSecureString, which doesn’t echo it, and stored it as a user environment variable. It’s in no repo and no .env file.
Keep your own history
Dates come as /Date(1795305600000)/, in milliseconds since 1970. Microsoft’s example adds a time zone offset, /Date(1316156400000-0700)/. The live answers I get have none and land on midnight UTC. My parser handles both forms.
GetRankAndTrafficStats and GetCrawlStats return one row per day, and GetQueryStats and GetPageStats one per week. Each call returns the whole window again, never more, so old days eventually drop off. A daily pull merges by date and keeps them:
saved["days"][r["Date"]] = {k: v for k, v in r.items() if k != "Date"}
GetCrawlStats also carries InIndex, the number of pages Bing has indexed. For Rubric it went from 74 on 8 November to 168 on 15 November and 320 on 22 November. Its AllOtherCodes, a catch-all for answers Bing doesn’t break out, looked alarming on one site until my server’s crawler log showed Bingbot getting 304s for the sitemap there. Harmless.
Keyword numbers for free
This was the bonus. GetKeyword takes q, country, language, startDate and endDate, with plain YYYY-MM-DD dates, and returns Bing’s impressions for the query:
{"BroadImpressions": 34433, "Impressions": 8547, "Query": "child support calculator"}
A query Bing has no data for comes back as "Query": null with zeros, not as an error. GetRelatedKeywords relates loosely. Its top suggestion for “custody schedule” was “who’s in custody”. I keep a related query only when it has two of the seed’s words side by side.
Submitted isn’t indexed
SubmitUrlBatch takes a POST of {"siteUrl": …, "urlList": […]}. GetUrlSubmissionQuota reported 100 URLs a day and 1,400 a month. Everything else in my client retries on 429 and 5xx. This call never does, because a retry after a timeout can spend the quota twice.
On 17 November I sent every URL of two new sites, Buying Costs and Coparent Math: 92 and 98, all accepted. Five days later Bing had indexed none of the first and 4 of the second. Rubric, which I never submitted, kept growing on its own. Accepted only means Bing has the list.