Home > Uncategorized > Bing Search API V2.0

Bing Search API V2.0

bingLogo_reverse_lg

 

 

EDIT: NB: This is no longer supported, please see this instead;

https://blog.dotnetframework.org/2017/04/24/bing-image-search-using-cognitive-search/

 

Once again, bing dissapoints, I spent an hour this morning getting the new Bing API to work. It’s great that the old documentation isn’t marked as deprecated. Grrr. Yup, if you see anything requiring an AppId, it’s obsolete.

Anyway, here is the new API, which on the free level, gives you 5,000 requests per month to play with. Unfortunately, for my needs, it wasn’t suitable, but the code is here anyway.

A word of note, is that you have to wrap your query in quotes for this to work, and yet again, I’m presuming a high trust environment for this code, such as Phonegap / Webworks / Windows Store / Firefox OS etc. Not the web.

function bingSearch(query,callback)
{
console.log(“bingSearch(” + query + “)”);
$.ajax
({
type: “GET”,
url: “https://api.datamarket.azure.com/Bing/SearchWeb/Web?$format=json&Query=” + encodeURIComponent(query),
dataType: ‘json’,
async: false,
headers: {
“Authorization”: “Basic ” + btoa(“:YOUR-PASSWORD”)
},
success: function (data){
console.log(“bingSearch() – success:”);
console.log(data);
callback(data);
}
});
}

Hope this is useful to someone.

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: