FormRecognizerClient class

Client class for interacting with the Azure Form Recognizer service.

Constructors

FormRecognizerClient(string, TokenCredential | KeyCredential, FormRecognizerClientOptions)

Creates an instance of FormRecognizerClient. Example usage:

import { FormRecognizerClient, AzureKeyCredential } from "@azure/ai-form-recognizer";

const client = new FormRecognizerClient(
   "<service endpoint>",
   new AzureKeyCredential("<api key>")
);

Properties

endpointUrl

URL to an Azure Form Recognizer service endpoint

Methods

beginRecognizeBusinessCards(FormRecognizerRequestBody, BeginRecognizeBusinessCardsOptions)

Recognizes data from business cards using a pre-built business card model, enabling you to extract structured data from business cards such as name, job title, phone numbers, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/businesscardfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./business-card-english.png";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeBusinessCards(readStream, {
  contentType: "image/png",
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [businessCard] = await poller.pollUntilDone();

Recognizes business card information from a given document

beginRecognizeBusinessCardsFromUrl(string, BeginRecognizeBusinessCardsOptions)

Recognizes business card information from a url using a pre-built business card model, enabling you to extract structured data from business cards such as name, job title, phone numbers, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/businesscardfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the business card document>";
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeBusinessCardsFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});
const [businessCard] = await poller.pollUntilDone();

Recognizes business card information from a given accessible url to a document

beginRecognizeContent(FormRecognizerRequestBody, BeginRecognizeContentOptions)

Recognizes content, including text and table structure from a form document. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./Invoice_7.pdf";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeContent(readStream, "application/pdf", {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const pages = await poller.pollUntilDone();

Recognizes content/layout information from a given document

beginRecognizeContentFromUrl(string, BeginRecognizeContentOptions)

Recognizes content, including text and table structure from a url to a form document. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<form document url>";

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeContentFromUrl(url, {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const pages = await poller.pollUntilDone();

Recognizes content/layout information from a url to a form document

beginRecognizeCustomForms(string, FormRecognizerRequestBody, BeginRecognizeCustomFormsOptions)

Recognizes forms from a given document using a custom form model from training. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./Invoice_6.pdf";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeCustomForms(modelId, readStream, "application/pdf", {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});
const forms = await poller.pollUntilDone();

Recognizes form information from a given document using a custom form model.

beginRecognizeCustomFormsFromUrl(string, string, BeginRecognizeCustomFormsOptions)

Recognizes forms from a URL to a document using a custom form model from training. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<form document url>";

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeCustomFormsFromUrl(modelId, url, {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});
const forms = await poller.pollUntilDone();

Recognizes form information from a url to a document using a custom form model.

beginRecognizeIdentityDocuments(FormRecognizerRequestBody, BeginRecognizeIdentityDocumentsOptions)

Recognizes data from identification documents using a pre-built ID document model, enabling you to extract structured data from ID documents such as first/last name, document number, expiration date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/iddocumentfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./license.jpg";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeIdentityDocuments(readStream, {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [identityDocument] = await poller.pollUntilDone();
beginRecognizeIdentityDocumentsFromUrl(string, BeginRecognizeIdentityDocumentsOptions)

Recognizes identity document information from a url using pre-built ID document model, enabling you to extract structured data from ID documents such as first/last name, document number, expiration date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/iddocumentfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the identity document>";

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeIdentityDocumentsFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});

const [identityDocument] = await poller.pollUntilDone();
beginRecognizeInvoices(FormRecognizerRequestBody, BeginRecognizeInvoicesOptions)

Recognizes data from invoices using a pre-built invoice model, enabling you to extract structured data from invoices such as customer address, vendor address, purchase order ID, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/invoicefields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./Invoice_1.pdf";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeInvoices(readStream, {
  contentType: "application/pdf",
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [invoice] = await poller.pollUntilDone();

Recognizes invoice information from a given document

beginRecognizeInvoicesFromUrl(string, BeginRecognizeInvoicesOptions)

Recognizes invoice information from a URL using a pre-built invoice model, enabling you to extract structured data from invoices such as customer address, vendor address, purchase order ID, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/invoicefields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the invoice document>";
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeInvoicesFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});
const [invoice] = await poller.pollUntilDone();

Recognizes invoice information from a given accessible url to a document

beginRecognizeReceipts(FormRecognizerRequestBody, BeginRecognizeReceiptsOptions)

Recognizes data from receipts using a pre-built receipt model, enabling you to extract structured data from receipts such as merchant name, merchant phone number, transaction date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/receiptfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./contoso-allinone.jpg";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeReceipts(readStream, {
  contentType: "image/jpeg",
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [receipt] = await poller.pollUntilDone();

Recognizes receipt information from a given document

beginRecognizeReceiptsFromUrl(string, BeginRecognizeReceiptsOptions)

Recognizes receipt information from a url using pre-built receipt model, enabling you to extract structure data from receipts such as merchant name, merchant phone number, transaction date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/receiptfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the receipt document>";
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeReceiptsFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});
const [receipt] = await poller.pollUntilDone();

Recognizes receipt information from a given accessible url to a document

Constructor Details

FormRecognizerClient(string, TokenCredential | KeyCredential, FormRecognizerClientOptions)

Creates an instance of FormRecognizerClient. Example usage:

import { FormRecognizerClient, AzureKeyCredential } from "@azure/ai-form-recognizer";

const client = new FormRecognizerClient(
   "<service endpoint>",
   new AzureKeyCredential("<api key>")
);
new FormRecognizerClient(endpointUrl: string, credential: TokenCredential | KeyCredential, options?: FormRecognizerClientOptions)

Parameters

endpointUrl

string

Url to an Azure Form Recognizer service endpoint

credential

TokenCredential | KeyCredential

Used to authenticate requests to the service.

options
FormRecognizerClientOptions

Used to configure the Form Recognizer client.

Property Details

endpointUrl

URL to an Azure Form Recognizer service endpoint

endpointUrl: string

Property Value

string

Method Details

beginRecognizeBusinessCards(FormRecognizerRequestBody, BeginRecognizeBusinessCardsOptions)

Recognizes data from business cards using a pre-built business card model, enabling you to extract structured data from business cards such as name, job title, phone numbers, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/businesscardfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./business-card-english.png";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeBusinessCards(readStream, {
  contentType: "image/png",
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [businessCard] = await poller.pollUntilDone();

Recognizes business card information from a given document

function beginRecognizeBusinessCards(businessCard: FormRecognizerRequestBody, options?: BeginRecognizeBusinessCardsOptions)

Parameters

businessCard
FormRecognizerRequestBody

Input document

options
BeginRecognizeBusinessCardsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeBusinessCardsFromUrl(string, BeginRecognizeBusinessCardsOptions)

Recognizes business card information from a url using a pre-built business card model, enabling you to extract structured data from business cards such as name, job title, phone numbers, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/businesscardfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the business card document>";
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeBusinessCardsFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});
const [businessCard] = await poller.pollUntilDone();

Recognizes business card information from a given accessible url to a document

function beginRecognizeBusinessCardsFromUrl(businessCardUrl: string, options?: BeginRecognizeBusinessCardsOptions)

Parameters

businessCardUrl

string

Url to a business card document that is accessible from the service. Must be a valid, encoded URL to a document of a supported content type.

options
BeginRecognizeBusinessCardsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeContent(FormRecognizerRequestBody, BeginRecognizeContentOptions)

Recognizes content, including text and table structure from a form document. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./Invoice_7.pdf";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeContent(readStream, "application/pdf", {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const pages = await poller.pollUntilDone();

Recognizes content/layout information from a given document

function beginRecognizeContent(form: FormRecognizerRequestBody, options?: BeginRecognizeContentOptions)

Parameters

form
FormRecognizerRequestBody

Input document

options
BeginRecognizeContentOptions

Options to start content recognition operation

Returns

beginRecognizeContentFromUrl(string, BeginRecognizeContentOptions)

Recognizes content, including text and table structure from a url to a form document. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<form document url>";

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeContentFromUrl(url, {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const pages = await poller.pollUntilDone();

Recognizes content/layout information from a url to a form document

function beginRecognizeContentFromUrl(formUrl: string, options?: BeginRecognizeContentOptions)

Parameters

formUrl

string

Url to a document that is accessible from the service. Must be a valid, encoded URL to a document of a supported content type.

options
BeginRecognizeContentOptions

Options for the content recognition operation

Returns

beginRecognizeCustomForms(string, FormRecognizerRequestBody, BeginRecognizeCustomFormsOptions)

Recognizes forms from a given document using a custom form model from training. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./Invoice_6.pdf";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeCustomForms(modelId, readStream, "application/pdf", {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});
const forms = await poller.pollUntilDone();

Recognizes form information from a given document using a custom form model.

function beginRecognizeCustomForms(modelId: string, form: FormRecognizerRequestBody, options?: BeginRecognizeCustomFormsOptions)

Parameters

modelId

string

Id of the custom form model to use

form
FormRecognizerRequestBody

Input form document

options
BeginRecognizeCustomFormsOptions

Options to start the form recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeCustomFormsFromUrl(string, string, BeginRecognizeCustomFormsOptions)

Recognizes forms from a URL to a document using a custom form model from training. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<form document url>";

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeCustomFormsFromUrl(modelId, url, {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});
const forms = await poller.pollUntilDone();

Recognizes form information from a url to a document using a custom form model.

function beginRecognizeCustomFormsFromUrl(modelId: string, formUrl: string, options?: BeginRecognizeCustomFormsOptions)

Parameters

modelId

string

Id of the custom form model to use

formUrl

string

Url to a document that is accessible from the service. Must be a valid, encoded URL to a document of a supported content type.

options
BeginRecognizeCustomFormsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeIdentityDocuments(FormRecognizerRequestBody, BeginRecognizeIdentityDocumentsOptions)

Recognizes data from identification documents using a pre-built ID document model, enabling you to extract structured data from ID documents such as first/last name, document number, expiration date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/iddocumentfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./license.jpg";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeIdentityDocuments(readStream, {
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [identityDocument] = await poller.pollUntilDone();
function beginRecognizeIdentityDocuments(identityDocument: FormRecognizerRequestBody, options?: BeginRecognizeIdentityDocumentsOptions)

Parameters

identityDocument
FormRecognizerRequestBody

Input document

options
BeginRecognizeIdentityDocumentsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeIdentityDocumentsFromUrl(string, BeginRecognizeIdentityDocumentsOptions)

Recognizes identity document information from a url using pre-built ID document model, enabling you to extract structured data from ID documents such as first/last name, document number, expiration date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/iddocumentfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the identity document>";

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeIdentityDocumentsFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});

const [identityDocument] = await poller.pollUntilDone();
function beginRecognizeIdentityDocumentsFromUrl(identityDocumentUrl: string, options?: BeginRecognizeIdentityDocumentsOptions)

Parameters

identityDocumentUrl

string

Url to an identity document that is accessible from the service. Must be a valid, encoded URL to a document of a supported content type.

options
BeginRecognizeIdentityDocumentsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeInvoices(FormRecognizerRequestBody, BeginRecognizeInvoicesOptions)

Recognizes data from invoices using a pre-built invoice model, enabling you to extract structured data from invoices such as customer address, vendor address, purchase order ID, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/invoicefields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./Invoice_1.pdf";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeInvoices(readStream, {
  contentType: "application/pdf",
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [invoice] = await poller.pollUntilDone();

Recognizes invoice information from a given document

function beginRecognizeInvoices(invoice: FormRecognizerRequestBody, options?: BeginRecognizeInvoicesOptions)

Parameters

invoice
FormRecognizerRequestBody

Input document

options
BeginRecognizeInvoicesOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeInvoicesFromUrl(string, BeginRecognizeInvoicesOptions)

Recognizes invoice information from a URL using a pre-built invoice model, enabling you to extract structured data from invoices such as customer address, vendor address, purchase order ID, etc. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/invoicefields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the invoice document>";
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeInvoicesFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});
const [invoice] = await poller.pollUntilDone();

Recognizes invoice information from a given accessible url to a document

function beginRecognizeInvoicesFromUrl(invoiceUrl: string, options?: BeginRecognizeInvoicesOptions)

Parameters

invoiceUrl

string

Url to an invoice document that is accessible from the service. Must be a valid, encoded URL to a document of a supported content type.

options
BeginRecognizeInvoicesOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeReceipts(FormRecognizerRequestBody, BeginRecognizeReceiptsOptions)

Recognizes data from receipts using a pre-built receipt model, enabling you to extract structured data from receipts such as merchant name, merchant phone number, transaction date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/receiptfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const path = "./contoso-allinone.jpg";
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeReceipts(readStream, {
  contentType: "image/jpeg",
  onProgress: (state) => { console.log(`status: ${state.status}`); }
});

const [receipt] = await poller.pollUntilDone();

Recognizes receipt information from a given document

function beginRecognizeReceipts(receipt: FormRecognizerRequestBody, options?: BeginRecognizeReceiptsOptions)

Parameters

receipt
FormRecognizerRequestBody

Input document

options
BeginRecognizeReceiptsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>

beginRecognizeReceiptsFromUrl(string, BeginRecognizeReceiptsOptions)

Recognizes receipt information from a url using pre-built receipt model, enabling you to extract structure data from receipts such as merchant name, merchant phone number, transaction date, and more. For a list of fields that are contained in the response, please refer to the documentation at the following link: https://aka.ms/formrecognizer/receiptfields

This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed.

Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

Example usage:

const url = "<url to the receipt document>";
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeReceiptsFromUrl(url, {
  includeFieldElements: true,
  onProgress: (state) => {
    console.log(`analyzing status: ${state.status}`);
  }
});
const [receipt] = await poller.pollUntilDone();

Recognizes receipt information from a given accessible url to a document

function beginRecognizeReceiptsFromUrl(receiptUrl: string, options?: BeginRecognizeReceiptsOptions)

Parameters

receiptUrl

string

Url to a receipt document that is accessible from the service. Must be a valid, encoded URL to a document of a supported content type.

options
BeginRecognizeReceiptsOptions

Options for the recognition operation

Returns

Promise<FormPollerLike>