user1552627
user1552627

Reputation: 33

Using the new Bing API (nodejs)

I am trying to switch over to the new bing search api which is now hosted on azure and as most of you know that the Appid parameter has been removed for authentication, I can't figure out an easy way to get the results of the query.

I am using http module for nodejs and the current code uses http.get to query the api.bing.net .

Can someone show me the code to use the new one correctly?

I tried this, but the url fails to return anything http://gavinmhackeling.com/blog/2012/05/using-the-bing-search-api-in-python/

Upvotes: 2

Views: 2281

Answers (2)

Mr. Goferito
Mr. Goferito

Reputation: 7001

You can use this module that encapsulates the requests, so you can use it like:

var Bing = require('node-bing-api')({ accKey: "your-account-key" });

Bing.web("stack overflow", function(error, res, body){
    console.log(body);
  },
  {
    top: 50,
    market: 'en-US'
  });

It works with the Azure version. You only have to replace your account key.

Upvotes: 0

gavinmh
gavinmh

Reputation: 257

Sorry, there was a typo in my blog post.

Make sure that you are using your default account key from https://datamarket.azure.com/account/keys.

To use the basic authentication, replace <YourDefaultAccountKey> in https://user:<YourDefaultAccountKey>@api.datamarket.azure.com/Bing/SearchWeb/Web?Query=%27leo%20fender%27&Market=%27en-US%27&$top=50&$format=JSON. You will be returned results in JSON.

You can also use https://datamarket.azure.com/dataset/explore/5BA839F1-12CE-4CCE-BF57-A49D98D29A44 to test query parameters and formatting.

Upvotes: 1

Related Questions