Since Bing’s Azure API documentation is essentially non-existent (and its error handling is entirely useless), I wanted to give my fellow Python users an SEO-friendly, easily findable way of getting started with Bing’s Search API.

If you’re on this page, you’ve probably seen this error about 10 times by now:

“The authorization type you provided is not supported. Only Basic and OAuth are supported”

Below is a code snippet that should help (using Python 3.3):

# Gist available at:
# From article hosted at:

from urllib.parse import quote_plus
import json
import requests

def bing_search(query):
    # Your base API URL
    url = ""
    # Query parameters. Don't try using urlencode here.
    # Don't ask why, but Bing needs the "$" in front of its parameters.
    # The '$top' parameter limits the number of search results.
    url += "?$format=json&$top=10&Query=%27{}%27".format(quote_plus(query))
    # You can get your primary account key at
    r = requests.get(url, auth=("","YOUR_AZURE_API_PRIMARY_ACCOUNT_KEY"))
    resp = json.loads(r.text)

And there you have it. Hope that helps!