# @azure/cognitiveservices-localsearch

> LocalSearchClient Library with typescript type definitions for node.js and browser.

Latest version **2.0.1** (published 2020-07-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @azure/cognitiveservices-localsearch
pnpm add @azure/cognitiveservices-localsearch
yarn add @azure/cognitiveservices-localsearch
bun add @azure/cognitiveservices-localsearch
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-07-27 |
| First published | 2018-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 458.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2300 |
| Author | Microsoft Corporation |
| Maintainers | amarzavery, azure-sdk, billytrend, sergeyshandar, veronicagg, vladbarosan |
| Keywords | node, azure, typescript, browser, isomorphic |

## Links

- npm: https://www.npmjs.com/package/@azure/cognitiveservices-localsearch
- Repository: https://github.com/Azure/azure-sdk-for-js
- Homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-localsearch
- Issues: https://github.com/Azure/azure-sdk-for-js/issues
- npm.io page: https://npm.io/package/@azure/cognitiveservices-localsearch

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^1.10.0
- [@azure/ms-rest-js](https://npm.io/package/@azure/ms-rest-js.md) ^2.0.4

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2020-07-27
- 2.0.0 — 2019-09-13
- 1.0.1 — 2019-01-31
- 1.0.0 — 2018-12-10

## README

## An isomorphic javascript sdk for - LocalSearchClient

This package contains an isomorphic SDK for LocalSearchClient.

### Currently supported environments

- Node.js version 6.x.x or higher
- Browser JavaScript

### How to Install

```bash
npm install @azure/cognitiveservices-localsearch
```

### How to use

#### nodejs - Authentication, client creation and search local as an example written in TypeScript.

##### Install @azure/ms-rest-azure-js

```bash
npm install @azure/ms-rest-azure-js
```

##### Sample code
The following sample performs an local business search with the query 'Coffee 98052'. To know more, refer to the [Azure Documentation on Bing Local Search](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-local-business-search/)

```javascript
const { LocalSearchClient } = require("@azure/cognitiveservices-localsearch");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
  const localSearchKey = process.env["localSearchKey"] || "<localSearchKey>";
  const cognitiveServiceCredentials = new CognitiveServicesCredentials(
    localSearchKey
  );
  const client = new LocalSearchClient(cognitiveServiceCredentials, {
    baseUri: "https://api.cognitive.microsoft.com/"
  });

  client.local
    .search("Coffee 98052")
    .then(result => {
      console.log("The result is: ");
      result.places.value.forEach(place => {
        console.log(place);
      });
    })
    .catch(err => {
      console.log("An error occurred:");
      console.error(err);
    });
}

main();

```

#### browser - Authentication, client creation and search local as an example written in JavaScript.

##### Sample code

- index.html
```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>@azure/cognitiveservices-localsearch sample</title>
    <script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
    <script src="node_modules/@azure/cognitiveservices-localsearch/dist/cognitiveservices-localsearch.js"></script>
    <script type="text/javascript">
      const localsearchKey = "<YOUR_LOCAL_SEARCH_KEY>";
      const cognitiveServiceCredentials = new msRest.ApiKeyCredentials({
        inHeader: {
          "Ocp-Apim-Subscription-Key": localsearchKey
        }
      });
      const client = new Azure.CognitiveservicesLocalsearch.LocalSearchClient(
        cognitiveServiceCredentials,
        {
          baseUri: "https://api.cognitive.microsoft.com/"
        }
      );

      client.local
        .search("Coffee 98052")
        .then(result => {
          console.log("The result is: ");
          result.places.value.forEach(place => {
            console.log(place);
          });
        })
        .catch(err => {
          console.log("An error occurred:");
          console.error(err);
        });
    </script>
  </head>
  <body></body>
</html>

```

## Related projects

- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-localsearch%2FREADME.png)

---
_Source: https://npm.io/package/@azure/cognitiveservices-localsearch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
