Bing Search API V2.0
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.