# node-bing-api

> Node.js module for the Cognitive Services Bing Search API

Latest version **4.1.1** (published 2021-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-bing-api
pnpm add node-bing-api
yarn add node-bing-api
bun add node-bing-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2021-04-03 |
| First published | 2014-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 56 |
| Author | Mr. Goferito |
| Maintainers | goferito |
| Keywords | bing, api, bing-api, search, cognitive |

## Links

- npm: https://www.npmjs.com/package/node-bing-api
- Repository: https://github.com/goferito/node-bing-api
- Homepage: https://github.com/goferito/node-bing-api#readme
- Issues: https://github.com/goferito/node-bing-api/issues
- npm.io page: https://npm.io/package/node-bing-api

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.44.0
- [underscore](https://npm.io/package/underscore.md) ^1.6.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 4.1.1 (latest) — 2021-04-03
- 4.0.1 — 2019-05-29
- 4.0.0 — 2018-04-10
- 3.2.2 — 2017-07-21
- 3.2.1 — 2017-02-02
- 3.1.1 — 2017-01-31
- 3.0.1 — 2016-11-01
- 3.0.0 — 2016-10-31
- 2.4.1 — 2016-04-24
- 2.4.0 — 2016-03-13
- 2.3.0 — 2015-11-06
- 2.2.0 — 2015-10-07
- 2.1.0 — 2015-10-07
- 2.0.0 — 2015-05-23
- 1.3.0 — 2015-05-07
- … 11 more at https://npm.io/package/node-bing-api/versions

## README

[![NPM downloads per month][npm-downloads-img]][npm-url]
[![NPM version][npm-version-img]][npm-url]
[![NPM license][npm-license-img]][npm-url]

# Node Bing API
Node.js lib for the Microsoft Cognitive Services Bing Web Search API

## Changelog v4
Use Cognitive V7. Apparently new registrations can use that version only. Upgrade with care!

## Changelog v3
Thanks to the contribution of [@franciscofsales](https://github.com/franciscofsales), version 3 supports the new API (Cognitive Services).

## Changelog v2
In order to follow JavaScript best practices and allow the library to
be promisified, the callback function is now the last parameter.

## Installation
````
npm install node-bing-api
````

## Usage

Require the library and initialize it with your account key:

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

## Promises

This API provdes callbacks by default, but users of node 8 and newer can make the library return Promises with `util.promisify()`. For example, to use `Bing.web`:

```js
var util = require('util'),
  Bing = require('node-bing-api')({ accKey: 'someKey' }),
  searchBing = util.promisify(Bing.web.bind(Bing));
```

#### Web Search (same as Composite):

```js
Bing.web("Pizza", {
    count: 10,  // Number of results (max 50)
    offset: 3   // Skip first 3 results
  }, function(error, res, body){

    // body has more useful information besides web pages
    // (image search, related search, news, videos)
    // but for this example we are just
    // printing the first two web page results
    console.log(body.webPages.value[0]);
    console.log(body.webPages.value[1]);
  });
```

#### Composite Search (same as Web):
```js
Bing.composite("Playstation 4 Pro", {
    count: 10,  // Number of results (max 15 for news, max 50 if other)
    offset: 3   // Skip first 3 results
  }, function(error, res, body){
    console.log(body.news);
  });
```

#### News Search:
```js
Bing.news("Anonymous", {
    count: 10,  // Number of results (max 15)
    offset: 3   // Skip first 3 results
  }, function(error, res, body){
    console.log(body);
  });
```

#### Video Search:
```js
Bing.video("monkey vs frog", {
    count: 10,  // Number of results (max 50)
    offset: 3   // Skip first 3 result
  }, function(error, res, body){
    console.log(body);
  });
```

#### Images Search:
```js
Bing.images("Ninja Turtles", {
  count: 15,   // Number of results (max 50)
  offset: 3    // Skip first 3 result
  }, function(error, res, body){
    console.log(body);
  });
```

#### Related Search (same as Web):
```js
Bing.relatedSearch('berlin'
, { market: 'en-US' }
, (err, res, body) => {
    const suggestions = body.relatedSearches.value.map(r => r.displayText)
    console.log(suggestions.join('\n'))
  })
```

#### Spelling Suggestions:
```js
Bing.spelling('awsome spell', function (err, res, body) {
  console.log(body.flaggedTokens.suggestions[0].suggestion); //awesome spell
});
```

Requires specific Account key

Available Options:
* mode:\<Proof | Spell\>
* preContextText:\<*String*\>
* postContextText:\<*String*\>

### request() options

* maxSockets: integer (default: Infinity)
* reqTimeout: ms

#### Specify Market
Getting spanish results:
```js
Bing.images("Ninja Turtles"
          , {count: 5, market: 'es-ES'}
          , function(error, res, body){

  console.log(body);
});
```

Full list of supported markets:
es-AR,en-AU,de-AT,nl-BE,fr-BE,pt-BR,en-CA,fr-CA,es-CL,da-DK,fi-FI,fr-FR,
de-DE,zh-HK,en-IN,en-ID,en-IE,it-IT,ja-JP,ko-KR,en-MY,es-MX,nl-NL,en-NZ,
no-NO,zh-CN,pl-PL,pt-PT,en-PH,ru-RU,ar-SA,en-ZA,es-ES,sv-SE,fr-CH,de-CH,
zh-TW,tr-TR,en-GB,en-US,es-US


#### Adult Filter
```js
Bing.images('Kim Kardashian'
          , {market: 'en-US', adult: 'Strict'}
          , function(error, res, body){

  console.log(body.value);
});
```
Accepted values: "Off", "Moderate", "Strict".

*Moderate level should not include results with sexually explicit images
or videos, but may include sexually explicit text.*

#### Web Only API Subscriptions
To use this library with a web only subscription, you can require and initialize it with an alternate root url:
```js
var Bing = require('node-bing-api')
            ({
              accKey: "your-account-key",
              rootUri: "https://api.datamarket.azure.com/Bing/SearchWeb/v1/"
            });
```

## Running Tests
In order to run the tests, the integration tests require to create a `secrets.js` file
from the provided `secrets.js.example` example, and fill it in with a valid access key.

Then just `mocha`.


## License
MIT

[npm-url]: https://npmjs.org/package/node-bing-api
[npm-downloads-img]: https://img.shields.io/npm/dm/node-bing-api.svg
[npm-version-img]: https://badge.fury.io/js/node-bing-api.svg
[npm-license-img]: https://img.shields.io/npm/l/node-bing-api.svg

---
_Source: https://npm.io/package/node-bing-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
