# @azure/cognitiveservices-imagesearch

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

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

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

## Install

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

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2020-07-27 |
| First published | 2018-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 832.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2302 |
| 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-imagesearch
- Repository: https://github.com/Azure/azure-sdk-for-js
- Homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-imagesearch
- Issues: https://github.com/Azure/azure-sdk-for-js/issues
- npm.io page: https://npm.io/package/@azure/cognitiveservices-imagesearch

## 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

- 3.0.1 (latest) — 2020-07-27
- 3.0.0 — 2019-09-11
- 2.0.1 — 2019-01-31
- 2.0.0 — 2018-12-06
- 0.1.0 — 2018-11-14

## README

## An isomorphic javascript sdk for - ImageSearchClient

This package contains an isomorphic SDK for ImageSearchClient.

### Currently supported environments

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

### How to Install

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

### How to use

#### nodejs - Authentication, client creation and search images 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 image search for 'Microsoft Azure' with conditions such as the color has to be 'Monochrome', etc. To know more, refer to the [Azure Documentation on Bing Image Search](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/)

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

async function main() {
  const imageSearchKey = process.env["imageSearchKey"] || "<imageSearchKey>";
  const imageSearchEndPoint =
    process.env["imageSearchEndPoint"] || "<imageSearchEndPoint>";
  const cognitiveServiceCredentials = new CognitiveServicesCredentials(
    imageSearchKey
  );
  const client = new ImageSearchClient(cognitiveServiceCredentials, {
    endpoint: imageSearchEndPoint
  });

  const query = "Microsoft Azure";
  const options = {
    color: "Monochrome",
    count: 10,
    imageType: "Photo",
    safeSearch: "Strict"
  };
  client.images
    .search(query, options)
    .then(result => {
      console.log("The result is: ");
      console.log(result);
    })
    .catch(err => {
      console.log("An error occurred:");
      console.error(err);
    });
}

main();
```

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

##### Sample code

- index.html
```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>@azure/cognitiveservices-imagesearch sample</title>
    <script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
    <script src="node_modules/@azure/cognitiveservices-imagesearch/dist/cognitiveservices-imagesearch.js"></script>
    <script type="text/javascript">
      const imageSearchKey = "<YOUR_IMAGE_SEARCH_KEY>";
      const imageSearchEndPoint = "<YOUR_IMAGE_SEARCH_ENDPOINT>";
      const cognitiveServiceCredentials = new msRest.ApiKeyCredentials({
        inHeader: {
          "Ocp-Apim-Subscription-Key": imageSearchKey
        }
      });
      const client = new Azure.CognitiveservicesImagesearch.ImageSearchClient(
        cognitiveServiceCredentials,
        {
          endpoint: imageSearchEndPoint
        }
      );

      const query = "Microsoft Azure";
      const options = {
        color: "Monochrome",
        count: 10,
        imageType: "Photo",
        safeSearch: "Strict"
      };
      client.images
        .search(query, options)
        .then(result => {
          console.log("The result is: ");
          console.log(result);
        })
        .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-imagesearch%2FREADME.png)

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