Search Microsoft Bing with XML and JSON APIs

July 29, 2009

Bing! Opportunity is ringing.

Bing Search Engine interface

Microsoft recently released Bing!, a re-branded and much improved search engine based on its older and less successful Live Search platform. Bing! quickly gathered a small share of the search market after its initial release, placing it just behind Yahoo! but still far behind the Google powerhouse.

Today, however, the game has changed. According to the New York Times, Microsoft and Yahoo! announced a deal on a search and advertising partnership that will give Bing! approximately 28% share of the search market. Microsoft Bing! will provide the search technologies to power Yahoo!'s media websites. Meanwhile, Yahoo! forgoes its own search initiatives to strengthen itself as a media producer. Ultimately, this deal will bring more ad revenue to Yahoo! (88% of search-generated ad revenue, initially) while driving more search traffic to Microsoft's Bing! search engine.

Exploring Bing's search APIs

That said, today is an exciting time to be a web developer. Although the fate of several innovative Yahoo! search tools like B.O.S.S and social site fall into question, there are new and exciting search APIs to discover with Bing!.

Bing!'s search API can provide search results programmatically as XML or JSON. Search results are fetched from various sources, including the Web, Images, News, Encarta Online, Phonebook, RelatedSearch, and Advertisements.

Get a Bing! Application ID

Before you can query Bing!'s search APIs, you must first obtain an Application ID from the Bing! Developer Center. Click on "Create an AppID" beneath "Get Started" and follow the instructions on the website.

Bing! Search API using XML

It is very simple to query Bing! programatically for XML search results. You only need to submit an HTTP GET request to the correct URL using several GET parameters (in other words, paste the URL below into a web browser and insert your application id). For example, we can search Bing! for "web design" by sending the following HTTP GET query.[your_app_id]&query=web+design&sources=web

Let's break this down. First, we are sending this GET request to This URL will return search results as XML (indicated by the "xml.aspx" URI suffix). Next, we append our unique application ID as the "Appid" parameter; this is the Application ID you obtained from the Bing! Developer Center above. Next, we tell Bing! what we want to find; we append the "query" parameter and set its value to our search term "web+design". Last, we tell Bing! where to search; in this example we will search Bing!'s Web search index. Other search sources include "instantanswer", "spell", "phonebook", "relatedsearch", "news", and "ad".

The search results for the above query are returned as XML and look like this (shortened for brevity):

<?xml version="1.0" encoding="utf-8" ?>
<SearchResponse xmlns="" Version="2.2">
		<SearchTerms>web design</SearchTerms>
	<web:Web xmlns:web="">
				<web:Title>Open Source Web Design - Download free web design templates.</web:Title>
					Download and upload free web designs. ... We love design. Open Source Web Design is 
					a site to download free web design templates and share yours with others.
				<web:Title>Web design - Wikipedia, the free encyclopedia</web:Title>
					Web design is the skill of creating presentations of content (usually hypertext or hypermedia) 
					that is delivered to an end-user through the World Wide Web, by way of a Web browser ...

Bing! Search API using JSON

Javascript developers will be excited to learn that Bing! can also return search results as JSON, or Javascript Object Notation. The same ideas above still apply here. We submit an HTTP GET request with the "Appid", "query", and "sources" GET parameters. However, the base URL is different. We can search Bing! for "web design" using the JSON interface with this GET request:[your_app_id]&query=web+design&sources=web

The search results for this query are returned as JSON and look like this:

		"Query":{"SearchTerms":"web design"},
					"Title":"Open Source Web Design - Download free web design templates.",
					"Description":"Download and upload free web designs. ...",
					"Title":"Web design - Wikipedia, the free encyclopedia",
					"Description":"Web design is the skill of creating presentations...",

Monetizing your search results

Microsoft is currently running an Ads Pilot Program. This program allows you to receive compensation for ads placed in your website's search results. To incorporate ads on your website, you must first obtain an Application ID from the Bing! Developer Center. Next, you must submit an Ads Pilot Program application. After you are contacted by a Microsoft representative and get setup, you can append "ad" to your search query's sources parameter. This pilot program is still very much in development. You can read more about it at the Bing! Developer Center Help website.


Josh Lockhart 's avatar
Josh Lockhart

@AJ The details about the phonebook search source are scare, but I can point you to the official Microsoft documentation on it.

It appears to be more like Google Local where you can search businesses based on certain criteria and receive search results that include the business phone number, address, website, and user ratings.

AJ's avatar

Josh - Do you know if the "phonebook" feature within the search API actually means a full national business database, complete with business names, phone numbers, address info, SIC codes, etc?

Leave a comment