This package has been deprecated

Author message:

Please note, this package is deprecated and not functional as it uses a version of the Form Recognizer service (v1.0-preview) that is no longer available. As of August 2020, you can instead use @azure/ai-form-recognizer.

@azure/cognitiveservices-formrecognizer
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

An isomorphic javascript sdk for - FormRecognizerClient

This package contains an isomorphic SDK for FormRecognizerClient.

Currently supported environments

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

How to Install

npm install @azure/cognitiveservices-formrecognizer

How to use

nodejs - Authentication, client creation and getExtractedKeys as an example written in TypeScript.

Install @azure/ms-rest-azure-js
npm install @azure/ms-rest-azure-js
Sample code

The following sample reads the scanned copy of a sample receipt. To know more, refer to the Azure Documentation on Form Recognizer

const { FormRecognizerClient } = require("@azure/cognitiveservices-formrecognizer");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
  const formRecognizerKey = process.env["formRecognizerKey"] || "<formRecognizerKey>";
  const endPoint = process.env["endPoint"] || "<endPoint>";
  const cognitiveServiceCredentials = new CognitiveServicesCredentials(formRecognizerKey);
  const client = new FormRecognizerClient(cognitiveServiceCredentials, endPoint);

  client
    .batchReadReceipt(
      "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/contoso-receipt.png"
    )
    .then((result) => {
      console.log(result);
    })
    .catch((err) => {
      console.log("An error occurred:");
      console.error(err);
    });
}

main();

browser - Authentication, client creation and getExtractedKeys as an example written in JavaScript.

Sample code
  • index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>@azure/cognitiveservices-formrecognizer sample</title>
    <script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
    <script src="node_modules/@azure/cognitiveservices-formrecognizer/dist/cognitiveservices-formrecognizer.js"></script>
    <script type="text/javascript">
      const formRecognizerKey = "<YOUR_FORM_RECOGNIZER_KEY>";
      const endPoint = "<YOUR_FORM_RECOGNIZER_ENDPOINT>";
      const cognitiveServiceCredentials = new msRest.ApiKeyCredentials({
        inHeader: {
          "Ocp-Apim-Subscription-Key": formRecognizerKey
        }
      });
      const client = new Azure.CognitiveservicesFormrecognizer.FormRecognizerClient(
        cognitiveServiceCredentials,
        endPoint
      );
      client
        .batchReadReceipt(
          "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/contoso-receipt.png"
        )
        .then((result) => {
          console.log(result);
        })
        .catch((err) => {
          console.log("An error occurred:");
          console.error(err);
        });
    </script>
  </head>
  <body></body>
</html>

Related projects

Impressions

Package Sidebar

Install

npm i @azure/cognitiveservices-formrecognizer

Weekly Downloads

23

Version

2.0.1

License

MIT

Unpacked Size

328 kB

Total Files

34

Last publish

Collaborators

  • microsoft1es
  • azure-sdk