Added bing Composite Search support
This commit is contained in:
parent
1aa77581a4
commit
352f36d7c9
2 changed files with 33 additions and 1 deletions
11
README.md
11
README.md
|
@ -19,6 +19,17 @@ var Bing = require('node-bing-api')({ accKey: "your-account-key" });
|
||||||
Bing.web("Pizza", function(error, res, body){
|
Bing.web("Pizza", function(error, res, body){
|
||||||
console.log(body);
|
console.log(body);
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
top: 10, // Number of results (max 50)
|
||||||
|
skip: 3, // Skip first 3 results
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Composite Search:
|
||||||
|
```js
|
||||||
|
Bing.composite("xbox", function(error, res, body){
|
||||||
|
console.log(body);
|
||||||
|
},
|
||||||
{
|
{
|
||||||
top: 10, // Number of results (max 50)
|
top: 10, // Number of results (max 50)
|
||||||
skip: 3, // Skip first 3 results
|
skip: 3, // Skip first 3 results
|
||||||
|
|
23
lib/bing.js
23
lib/bing.js
|
@ -22,7 +22,7 @@ var Bing = function( options ) {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
|
|
||||||
//Bing Search API URI
|
//Bing Search API URI
|
||||||
rootUri: "https://api.datamarket.azure.com/Bing/Search/",
|
rootUri: "https://api.datamarket.azure.com/Bing/Search/v1/",
|
||||||
|
|
||||||
//Account Key
|
//Account Key
|
||||||
accKey: null,
|
accKey: null,
|
||||||
|
@ -131,6 +131,27 @@ Bing.prototype.web = function(query, callback, options) {
|
||||||
Bing.prototype.search = Bing.prototype.web;
|
Bing.prototype.search = Bing.prototype.web;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a Bing search in the Composite vertical.
|
||||||
|
*
|
||||||
|
* @param {String} query Query term to search for.
|
||||||
|
*
|
||||||
|
* @param {requestCallback} callback Callback called with (potentially
|
||||||
|
* json-parsed) response.
|
||||||
|
*
|
||||||
|
* @param {Object} options Options to command, allows overriding
|
||||||
|
* of rootUri, accKey (Bing API key),
|
||||||
|
* userAgent, reqTimeout, top, skip,
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
Bing.prototype.composite = function(query, callback, options) {
|
||||||
|
this.searchVertical(query, "Composite", callback, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Alias Bing.search to Bing.web
|
||||||
|
// Note: Keep this for compatibility with older versions
|
||||||
|
Bing.prototype.search = Bing.prototype.composite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a Bing search in the Images vertical.
|
* Performs a Bing search in the Images vertical.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue