Tuesday, August 28, 2012

Using Bing Search API (使用 Bing API)

*updated: Bing had changed its api without updating the documentation. Now we need to use something like "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?Query=..."

Bing Search API had been moved to Windows Azure Marketplace. The way to use it also slightly changed (e.g., no ApplicationID any more). The perquisites to use Bing Search API is to have a account key in Windows Azure Marketplace. You may need to register in the Marketplace first.

After having the account key, using Bing Search API is straightforward. For example, if we want to search "iphone5", we can do
https://api.datamarket.azure.com/Bing/Search/Web/?Query=%27iphone5%27
 https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?Query=%27iphone5%27
If you want top10 results, do
https://api.datamarket.azure.com/Bing/Search/Web/?Query=%27iphone5%27&$top=10 
https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?
Query=%27iphone5%27&$top=10  
If you further want results in format in JSON, do
https://api.datamarket.azure.com/Bing/Search/Web/?Query=%27iphone5%27&$top=10&$format=JSON
https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web
?Query=%27iphone5%27&$top=10&$format=JSON 
You may wonder where the authentication happens since we no longer have an ApplicationID in the url. When you type in the search url, the browser will automatically pop up a dialog asking for user name and password. Leaving the user name blank and type your account key as password. Then you can see the search results right away.

What if you want to search for images? just do
https://api.datamarket.azure.com/Bing/Search/Image/?Query=%27iphone5%27
https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%27iphone5%27 
 This post only introduces some basic use of Bing Search API. For more uses, please look at this link.

1 comment:


  1. Hello,

    we provide affordable and result-oriented SEO services, please give a chance to serve you.


    Thanks
    Admin: E07.net

    ReplyDelete