FormRecognizerClient class
Client class for interacting with the Azure Form Recognizer service.
Constructors
| Form |
Creates an instance of FormRecognizerClient. Example usage:
|
Properties
| endpoint |
URL to an Azure Form Recognizer service endpoint |
Methods
| begin |
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:
Recognizes business card information from a given document |
| begin |
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:
Recognizes business card information from a given accessible url to a document |
| begin |
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:
Recognizes content/layout information from a given document |
| begin |
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:
Recognizes content/layout information from a url to a form document |
| begin |
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:
Recognizes form information from a given document using a custom form model. |
| begin |
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:
Recognizes form information from a url to a document using a custom form model. |
| begin |
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:
|
| begin |
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:
|
| begin |
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:
Recognizes invoice information from a given document |
| begin |
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:
Recognizes invoice information from a given accessible url to a document |
| begin |
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:
Recognizes receipt information from a given document |
| begin |
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:
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): Promise<FormPollerLike>
Parameters
- businessCard
- FormRecognizerRequestBody
Input document
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): Promise<FormPollerLike>
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 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): Promise<ContentPollerLike>
Parameters
Input document
- options
- BeginRecognizeContentOptions
Options to start content recognition operation
Returns
Promise<ContentPollerLike>
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): Promise<ContentPollerLike>
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
Promise<ContentPollerLike>
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): Promise<FormPollerLike>
Parameters
- modelId
-
string
Id of the custom form model to use
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): Promise<FormPollerLike>
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): Promise<FormPollerLike>
Parameters
- identityDocument
- FormRecognizerRequestBody
Input document
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): Promise<FormPollerLike>
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 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): Promise<FormPollerLike>
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): Promise<FormPollerLike>
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): Promise<FormPollerLike>
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): Promise<FormPollerLike>
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>