RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Introduction to the Live Search API

You can use Live Search on your site through the Live Search Box or by using the Windows Live Search API.

ave you ever wanted to implement search capabilities on your own Web site but didn't want to implement the logic and deal with issues such as storage and indexing? Now you can. The Live Search web service allows your site to make up to 25,000 queries a day for use in both commercial and non-commercial sites—at no cost.

Figure 1 shows the Live Search home page. In addition to a standard search service, Live Search offers specialty searches in categories such as images, news, maps, and more.

Figure 1. The Live Search Home Page: You can access both regular and specialty searches through the Live Search home page.

Two Access Methods
The Live Search team now offers two different ways to utilize search on your site: using the Live Search Box or Windows Live Search API.
Live Search offers two ways for site developers to build search capabilities into their sites. The Live Search Box allows a user to harness the power of Live Search without writing any code. It provides a fast, customizable search for any Web site. You can find details on how to get started with this option here. Basically, you just follow the wizard and copy the HTML code provided into your site.

Developers seeking more advanced search capabilities should use the Live Search Web Service, which lets you query the Live Search Engine directly. The Live Search Web Service is an Extensible Markup Language (XML) service with a Simple Object Access Protocol (SOAP) API that allows users to create a custom search engine that can query for Web results, images, news, phonebook listings, feeds, and meta tags.
Figure 2. The Developer Center Home Page: Here, you can download the Search SDK and create and manage Application IDs.
You should use this service when you want programmatic control over search terms and result displays.

You can find the fully documented SDK online. The documentation describes the requirements, the class libraries for the Live Search Web Service, and the terms of use. It also contains sample code demonstrating use of the Live Search Web Service.

Before You Start
To use the API, you need an Application ID. You can register and manage your Live Search Application IDs at the Live Search Developer Center. Figure 2 shows the Developer Center home page.

When creating a new Application ID, give your application a name and make note of the assigned Application ID as you will need to use it in your source code. Figure 3 shows the "Get Application ID" page.

Figure 3. Getting an Application ID: Here's the Developer Center page where you get an Application ID.
Figure 4. The Add Web Reference Dialog Box: In Visual Studio, add a reference to the Live Search Web Service through the Add Web Reference dialog.

Referencing the Web Service
After obtaining an Application ID, you need to configure your application to consume the Live Search Web Service. In Visual Studio, add a Web Reference to the WSDL located at http://soap.search.msn.com/webservices.asmx?wsdl. Figure 4 shows the Add Web Reference dialog box with the Live Search Web Service. After the application has located the Web Service, enter a name for the service and click the Add Reference button. All code examples in this article use "LiveSearch" as the service name.

Editor's Note: This article was first published in the "Windows Live" edition of CoDe Focus Magazine (2008, Vol. 5, Issue 2), and is reprinted here by permission.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date