Incorporating Advertisements into Results


Bing API provides you with the ability to incorporate advertisements into your search results. To take advantage of this ability, perform the procedure at Monetize your search application. Creating a request to the Ad SourceType is much the same as creating a request to any Bing API SourceType, although there are a number of additional required parameters. These parameters are identified in Table 2.

Table 2: Ad SourceType Additional Required Parameters


Parameter Description


Your AdCenter Unit ID


Your AdCenter Property ID


The page number requested

Figure 4 shows results returned by a query to the Ad SourceType.

<?xml version="1.0" encoding="utf-8" ?> 
  <?pageview_candidate ?> 
- <SearchResponse xmlns="" Version="2.0">
- <Query>
  <SearchTerms>word powerpoint</SearchTerms> 
- <ads:Ad xmlns:ads="">
- <ads:Results>
- <ads:AdResult>
  <ads:Title>Sample Word 2007 Ad</ads:Title> 
  <ads:Description>Spend More Time Writing & Less Time Formatting with Word 2007.</ads:Description> 
+ <ads:AdResult>

Figure 4: Bing API Ad SourceType Response

As Figure 4 shows, Ad SourceType result sets are shaped exactly the same as other SourceTypes, with SearchResponse followed by the Ad element, and the Ad element having a number of AdResult elements. The data inside of AdResults can be used to create advertisements on your page; when a user clicks on that ad, your account at AdCenter is incremented.

If you are going to use the Ad SourceType, you must also send the search client IP address in a special custom HTTP header as well as the Client user agent. Specifically, with each search request you send a special custom HTTP header: “search-client-ip”. The value of this header will be the IP address of the machine sending the request. (That is, the end user accessing your web site). You will also need to send the user agent information. (HTTP Header webRequest.Headers.Add("search-client-ip", "");   User Agent request.UserAgent =”Your user agent”;)