You are viewing the documentation for an older major version of the AWS SDK for JavaScript.
The modular AWS SDK for JavaScript (v3), the latest major version of AWS SDK for JavaScript, is now stable and recommended for general use. For more information, see the Migration Guide and API Reference.

Class: AWS.Textract

Inherits:
AWS.Service show all
Identifier:
textract
API Version:
2018-06-27
Defined in:
(unknown)

Overview

Constructs a service interface object. Each API operation is exposed as a function on service.

Service Description

Amazon Textract detects and analyzes text in documents and converts it into machine-readable text. This is the API reference documentation for Amazon Textract.

Sending a Request Using Textract

var textract = new AWS.Textract();
textract.analyzeDocument(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Locking the API Version

In order to ensure that the Textract object uses this specific API, you can construct the object by passing the apiVersion option to the constructor:

var textract = new AWS.Textract({apiVersion: '2018-06-27'});

You can also set the API version globally in AWS.config.apiVersions using the textract service identifier:

AWS.config.apiVersions = {
  textract: '2018-06-27',
  // other service API versions
};

var textract = new AWS.Textract();

Version:

  • 2018-06-27

Constructor Summary collapse

Property Summary collapse

Properties inherited from AWS.Service

apiVersions

Method Summary collapse

Methods inherited from AWS.Service

makeRequest, makeUnauthenticatedRequest, waitFor, setupRequestListeners, defineService

Constructor Details

new AWS.Textract(options = {}) ⇒ Object

Constructs a service object. This object has one method for each API operation.

Examples:

Constructing a Textract object

var textract = new AWS.Textract({apiVersion: '2018-06-27'});

Options Hash (options):

  • params (map)

    An optional map of parameters to bind to every request sent by this service object. For more information on bound parameters, see "Working with Services" in the Getting Started Guide.

  • endpoint (String|AWS.Endpoint)

    The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like 'https://{service}.{region}.amazonaws.com' or an Endpoint object.

  • accessKeyId (String)

    your AWS access key ID.

  • secretAccessKey (String)

    your AWS secret access key.

  • sessionToken (AWS.Credentials)

    the optional AWS session token to sign requests with.

  • credentials (AWS.Credentials)

    the AWS credentials to sign requests with. You can either specify this object, or specify the accessKeyId and secretAccessKey options directly.

  • credentialProvider (AWS.CredentialProviderChain)

    the provider chain used to resolve credentials if no static credentials property is set.

  • region (String)

    the region to send service requests to. See AWS.Textract.region for more information.

  • maxRetries (Integer)

    the maximum amount of retries to attempt with a request. See AWS.Textract.maxRetries for more information.

  • maxRedirects (Integer)

    the maximum amount of redirects to follow with a request. See AWS.Textract.maxRedirects for more information.

  • sslEnabled (Boolean)

    whether to enable SSL for requests.

  • paramValidation (Boolean|map)

    whether input parameters should be validated against the operation description before sending the request. Defaults to true. Pass a map to enable any of the following specific validation features:

    • min [Boolean] — Validates that a value meets the min constraint. This is enabled by default when paramValidation is set to true.
    • max [Boolean] — Validates that a value meets the max constraint.
    • pattern [Boolean] — Validates that a string value matches a regular expression.
    • enum [Boolean] — Validates that a string value matches one of the allowable enum values.
  • computeChecksums (Boolean)

    whether to compute checksums for payload bodies when the service accepts it (currently supported in S3 only)

  • convertResponseTypes (Boolean)

    whether types are converted when parsing response data. Currently only supported for JSON based services. Turning this off may improve performance on large response payloads. Defaults to true.

  • correctClockSkew (Boolean)

    whether to apply a clock skew correction and retry requests that fail because of an skewed client clock. Defaults to false.

  • s3ForcePathStyle (Boolean)

    whether to force path style URLs for S3 objects.

  • s3BucketEndpoint (Boolean)

    whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint). Note that setting this configuration option requires an endpoint to be provided explicitly to the service constructor.

  • s3DisableBodySigning (Boolean)

    whether S3 body signing should be disabled when using signature version v4. Body signing can only be disabled when using https. Defaults to true.

  • s3UsEast1RegionalEndpoint ('legacy'|'regional')

    when region is set to 'us-east-1', whether to send s3 request to global endpoints or 'us-east-1' regional endpoints. This config is only applicable to S3 client. Defaults to legacy

  • s3UseArnRegion (Boolean)

    whether to override the request region with the region inferred from requested resource's ARN. Only available for S3 buckets Defaults to true

  • retryDelayOptions (map)

    A set of options to configure the retry delay on retryable errors. Currently supported options are:

    • base [Integer] — The base number of milliseconds to use in the exponential backoff for operation retries. Defaults to 100 ms for all services except DynamoDB, where it defaults to 50ms.
    • customBackoff [function] — A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds. If the result is a non-zero negative value, no further retry attempts will be made. The base option will be ignored if this option is supplied. The function is only called for retryable errors.
  • httpOptions (map)

    A set of options to pass to the low-level HTTP request. Currently supported options are:

    • proxy [String] — the URL to proxy requests through
    • agent [http.Agent, https.Agent] — the Agent object to perform HTTP requests with. Used for connection pooling. Defaults to the global agent (http.globalAgent) for non-SSL connections. Note that for SSL connections, a special Agent object is used in order to enable peer certificate verification. This feature is only available in the Node.js environment.
    • connectTimeout [Integer] — Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds. This timeout has no effect once a socket connection has been established.
    • timeout [Integer] — Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000).
    • xhrAsync [Boolean] — Whether the SDK will send asynchronous HTTP requests. Used in the browser environment only. Set to false to send requests synchronously. Defaults to true (async on).
    • xhrWithCredentials [Boolean] — Sets the "withCredentials" property of an XMLHttpRequest object. Used in the browser environment only. Defaults to false.
  • apiVersion (String, Date)

    a String in YYYY-MM-DD format (or a date) that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify 'latest' to use the latest possible version.

  • apiVersions (map<String, String|Date>)

    a map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version.

  • logger (#write, #log)

    an object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests

  • systemClockOffset (Number)

    an offset value in milliseconds to apply to all signing times. Use this to compensate for clock skew when your system may be out of sync with the service time. Note that this configuration option can only be applied to the global AWS.config object and cannot be overridden in service-specific configuration. Defaults to 0 milliseconds.

  • signatureVersion (String)

    the signature version to sign requests with (overriding the API configuration). Possible values are: 'v2', 'v3', 'v4'.

  • signatureCache (Boolean)

    whether the signature to sign requests with (overriding the API configuration) is cached. Only applies to the signature version 'v4'. Defaults to true.

  • dynamoDbCrc32 (Boolean)

    whether to validate the CRC32 checksum of HTTP response bodies returned by DynamoDB. Default: true.

  • useAccelerateEndpoint (Boolean)

    Whether to use the S3 Transfer Acceleration endpoint with the S3 service. Default: false.

  • clientSideMonitoring (Boolean)

    whether to collect and publish this client's performance metrics of all its API requests.

  • endpointDiscoveryEnabled (Boolean|undefined)

    whether to call operations with endpoints given by service dynamically. Setting this

  • endpointCacheSize (Number)

    the size of the global cache storing endpoints from endpoint discovery operations. Once endpoint cache is created, updating this setting cannot change existing cache size. Defaults to 1000

  • hostPrefixEnabled (Boolean)

    whether to marshal request parameters to the prefix of hostname. Defaults to true.

  • stsRegionalEndpoints ('legacy'|'regional')

    whether to send sts request to global endpoints or regional endpoints. Defaults to 'legacy'.

Property Details

endpointAWS.Endpoint (readwrite)

Returns an Endpoint object representing the endpoint URL for service requests.

Returns:

  • (AWS.Endpoint)

    an Endpoint object representing the endpoint URL for service requests.

Method Details

analyzeDocument(params = {}, callback) ⇒ AWS.Request

Analyzes an input document for relationships between detected items.

The types of information returned are as follows:

  • Form data (key-value pairs). The related information is returned in two Block objects, each of type KEY_VALUE_SET: a KEY Block object and a VALUE Block object. For example, Name: Ana Silva Carolina contains a key and value. Name: is the key. Ana Silva Carolina is the value.

  • Table and table cell data. A TABLE Block object contains information about a detected table. A CELL Block object is returned for each cell in a table.

  • Lines and words of text. A LINE Block object contains one or more WORD Block objects. All lines and words that are detected in the document are returned (including text that doesn't have a relationship with the value of FeatureTypes).

Selection elements such as check boxes and option buttons (radio buttons) can be detected in form data and in tables. A SELECTION_ELEMENT Block object contains information about a selection element, including the selection status.

You can choose which type of analysis to perform by specifying the FeatureTypes list.

The output is returned in a list of Block objects.

AnalyzeDocument is a synchronous operation. To analyze documents asynchronously, use StartDocumentAnalysis.

For more information, see Document Text Analysis.

Service Reference:

Examples:

Calling the analyzeDocument operation

var params = {
  Document: { /* required */
    Bytes: Buffer.from('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */,
    S3Object: {
      Bucket: 'STRING_VALUE',
      Name: 'STRING_VALUE',
      Version: 'STRING_VALUE'
    }
  },
  FeatureTypes: [ /* required */
    TABLES | FORMS,
    /* more items */
  ],
  HumanLoopConfig: {
    FlowDefinitionArn: 'STRING_VALUE', /* required */
    HumanLoopName: 'STRING_VALUE', /* required */
    DataAttributes: {
      ContentClassifiers: [
        FreeOfPersonallyIdentifiableInformation | FreeOfAdultContent,
        /* more items */
      ]
    }
  }
};
textract.analyzeDocument(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • Document — (map)

      The input document as base64-encoded bytes or an Amazon S3 object. If you use the AWS CLI to call Amazon Textract operations, you can't pass image bytes. The document must be an image in JPEG or PNG format.

      If you're using an AWS SDK to call Amazon Textract, you might not need to base64-encode image bytes that are passed using the Bytes field.

      • Bytes — (Buffer, Typed Array, Blob, String)

        A blob of base64-encoded document bytes. The maximum size of a document that's provided in a blob of bytes is 5 MB. The document bytes must be in PNG or JPEG format.

        If you're using an AWS SDK to call Amazon Textract, you might not need to base64-encode image bytes passed using the Bytes field.

      • S3Object — (map)

        Identifies an S3 object as the document source. The maximum size of a document that's stored in an S3 bucket is 5 MB.

        • Bucket — (String)

          The name of the S3 bucket. Note that the # character is not valid in the file name.

        • Name — (String)

          The file name of the input document. Synchronous operations can use image files that are in JPEG or PNG format. Asynchronous operations also support PDF and TIFF format files.

        • Version — (String)

          If the bucket has versioning enabled, you can specify the object version.

    • FeatureTypes — (Array<String>)

      A list of the types of analysis to perform. Add TABLES to the list to return information about the tables that are detected in the input document. Add FORMS to return detected form data. To perform both types of analysis, add TABLES and FORMS to FeatureTypes. All lines and words detected in the document are included in the response (including text that isn't related to the value of FeatureTypes).

    • HumanLoopConfig — (map)

      Sets the configuration for the human in the loop workflow for analyzing documents.

      • HumanLoopNamerequired — (String)

        The name of the human workflow used for this image. This should be kept unique within a region.

      • FlowDefinitionArnrequired — (String)

        The Amazon Resource Name (ARN) of the flow definition.

      • DataAttributes — (map)

        Sets attributes of the input data.

        • ContentClassifiers — (Array<String>)

          Sets whether the input image is free of personally identifiable information or adult content.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • DocumentMetadata — (map)

        Metadata about the analyzed document. An example is the number of pages.

        • Pages — (Integer)

          The number of pages that are detected in the document.

      • Blocks — (Array<map>)

        The items that are detected and analyzed by AnalyzeDocument.

        • BlockType — (String)

          The type of text item that's recognized. In operations for text detection, the following types are returned:

          • PAGE - Contains a list of the LINE Block objects that are detected on a document page.

          • WORD - A word detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          In text analysis operations, the following types are returned:

          • PAGE - Contains a list of child Block objects that are detected on a document page.

          • KEY_VALUE_SET - Stores the KEY and VALUE Block objects for linked text that's detected on a document page. Use the EntityType field to determine if a KEY_VALUE_SET object is a KEY Block object or a VALUE Block object.

          • WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          • TABLE - A table that's detected on a document page. A table is grid-based information with two or more rows or columns, with a cell span of one row and one column each.

          • CELL - A cell within a detected table. The cell is the parent of the block that contains the text in the cell.

          • SELECTION_ELEMENT - A selection element such as an option button (radio button) or a check box that's detected on a document page. Use the value of SelectionStatus to determine the status of the selection element.

          Possible values include:
          • "KEY_VALUE_SET"
          • "PAGE"
          • "LINE"
          • "WORD"
          • "TABLE"
          • "CELL"
          • "SELECTION_ELEMENT"
        • Confidence — (Float)

          The confidence score that Amazon Textract has in the accuracy of the recognized text and the accuracy of the geometry points around the recognized text.

        • Text — (String)

          The word or line of text that's recognized by Amazon Textract.

        • TextType — (String)

          The kind of text that Amazon Textract has detected. Can check for handwritten text and printed text.

          Possible values include:
          • "HANDWRITING"
          • "PRINTED"
        • RowIndex — (Integer)

          The row in which a table cell is located. The first row position is 1. RowIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnIndex — (Integer)

          The column in which a table cell appears. The first column position is 1. ColumnIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • RowSpan — (Integer)

          The number of rows that a table cell spans. Currently this value is always 1, even if the number of rows spanned is greater than 1. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. Currently this value is always 1, even if the number of columns spanned is greater than 1. ColumnSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • Geometry — (map)

          The location of the recognized text on the image. It includes an axis-aligned, coarse bounding box that surrounds the text, and a finer-grain polygon for more accurate spatial information.

          • BoundingBox — (map)

            An axis-aligned coarse representation of the location of the recognized item on the document page.

            • Width — (Float)

              The width of the bounding box as a ratio of the overall document page width.

            • Height — (Float)

              The height of the bounding box as a ratio of the overall document page height.

            • Left — (Float)

              The left coordinate of the bounding box as a ratio of overall document page width.

            • Top — (Float)

              The top coordinate of the bounding box as a ratio of overall document page height.

          • Polygon — (Array<map>)

            Within the bounding box, a fine-grained polygon around the recognized item.

            • X — (Float)

              The value of the X coordinate for a point on a Polygon.

            • Y — (Float)

              The value of the Y coordinate for a point on a Polygon.

        • Id — (String)

          The identifier for the recognized text. The identifier is only unique for a single operation.

        • Relationships — (Array<map>)

          A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text. There aren't Relationship objects in the list for relationships that don't exist, such as when the current block has no child blocks. The list size can be the following:

          • 0 - The block has no child blocks.

          • 1 - The block has child blocks.

          • Type — (String)

            The type of relationship that the blocks in the IDs array have with the current block. The relationship can be VALUE or CHILD. A relationship of type VALUE is a list that contains the ID of the VALUE block that's associated with the KEY of a key-value pair. A relationship of type CHILD is a list of IDs that identify WORD blocks in the case of lines Cell blocks in the case of Tables, and WORD blocks in the case of Selection Elements.

            Possible values include:
            • "VALUE"
            • "CHILD"
            • "COMPLEX_FEATURES"
          • Ids — (Array<String>)

            An array of IDs for related blocks. You can get the type of the relationship from the Type element.

        • EntityTypes — (Array<String>)

          The type of entity. The following can be returned:

          • KEY - An identifier for a field on the document.

          • VALUE - The field text.

          EntityTypes isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • SelectionStatus — (String)

          The selection status of a selection element, such as an option button or check box.

          Possible values include:
          • "SELECTED"
          • "NOT_SELECTED"
        • Page — (Integer)

          The page on which a block was detected. Page is returned by asynchronous operations. Page values greater than 1 are only returned for multipage documents that are in PDF or TIFF format. A scanned image (JPEG/PNG), even if it contains multiple document pages, is considered to be a single-page document. The value of Page is always 1. Synchronous operations don't return Page because every input document is considered to be a single-page document.

      • HumanLoopActivationOutput — (map)

        Shows the results of the human in the loop evaluation.

        • HumanLoopArn — (String)

          The Amazon Resource Name (ARN) of the HumanLoop created.

        • HumanLoopActivationReasons — (Array<String>)

          Shows if and why human review was needed.

        • HumanLoopActivationConditionsEvaluationResults — (String)

          Shows the result of condition evaluations, including those conditions which activated a human review.

      • AnalyzeDocumentModelVersion — (String)

        The version of the model used to analyze the document.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

analyzeExpense(params = {}, callback) ⇒ AWS.Request

Analyzes an input document for financially related relationships between text.

Information is returned as ExpenseDocuments and seperated as follows.

  • LineItemGroups- A data set containing LineItems which store information about the lines of text, such as an item purchased and its price on a receipt.

  • SummaryFields- Contains all other information a receipt, such as header information or the vendors name.

Service Reference:

Examples:

Calling the analyzeExpense operation

var params = {
  Document: { /* required */
    Bytes: Buffer.from('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */,
    S3Object: {
      Bucket: 'STRING_VALUE',
      Name: 'STRING_VALUE',
      Version: 'STRING_VALUE'
    }
  }
};
textract.analyzeExpense(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • Document — (map)

      The input document, either as bytes or as an S3 object.

      You pass image bytes to an Amazon Textract API operation by using the Bytes property. For example, you would use the Bytes property to pass a document loaded from a local file system. Image bytes passed by using the Bytes property must be base64 encoded. Your code might not need to encode document file bytes if you're using an AWS SDK to call Amazon Textract API operations.

      You pass images stored in an S3 bucket to an Amazon Textract API operation by using the S3Object property. Documents stored in an S3 bucket don't need to be base64 encoded.

      The AWS Region for the S3 bucket that contains the S3 object must match the AWS Region that you use for Amazon Textract operations.

      If you use the AWS CLI to call Amazon Textract operations, passing image bytes using the Bytes property isn't supported. You must first upload the document to an Amazon S3 bucket, and then call the operation using the S3Object property.

      For Amazon Textract to process an S3 object, the user must have permission to access the S3 object.

      • Bytes — (Buffer, Typed Array, Blob, String)

        A blob of base64-encoded document bytes. The maximum size of a document that's provided in a blob of bytes is 5 MB. The document bytes must be in PNG or JPEG format.

        If you're using an AWS SDK to call Amazon Textract, you might not need to base64-encode image bytes passed using the Bytes field.

      • S3Object — (map)

        Identifies an S3 object as the document source. The maximum size of a document that's stored in an S3 bucket is 5 MB.

        • Bucket — (String)

          The name of the S3 bucket. Note that the # character is not valid in the file name.

        • Name — (String)

          The file name of the input document. Synchronous operations can use image files that are in JPEG or PNG format. Asynchronous operations also support PDF and TIFF format files.

        • Version — (String)

          If the bucket has versioning enabled, you can specify the object version.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • DocumentMetadata — (map)

        Information about the input document.

        • Pages — (Integer)

          The number of pages that are detected in the document.

      • ExpenseDocuments — (Array<map>)

        The expenses detected by Amazon Textract.

        • ExpenseIndex — (Integer)

          Denotes which invoice or receipt in the document the information is coming from. First document will be 1, the second 2, and so on.

        • SummaryFields — (Array<map>)

          Any information found outside of a table by Amazon Textract.

          • Type — (map)

            The implied label of a detected element. Present alongside LabelDetection for explicit elements.

            • Text — (String)

              The word or line of text detected by Amazon Textract.

            • Confidence — (Float)

              The confidence of accuracy, as a percentage.

          • LabelDetection — (map)

            The explicitly stated label of a detected element.

            • Text — (String)

              The word or line of text recognized by Amazon Textract

            • Geometry — (map)

              Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

              • BoundingBox — (map)

                An axis-aligned coarse representation of the location of the recognized item on the document page.

                • Width — (Float)

                  The width of the bounding box as a ratio of the overall document page width.

                • Height — (Float)

                  The height of the bounding box as a ratio of the overall document page height.

                • Left — (Float)

                  The left coordinate of the bounding box as a ratio of overall document page width.

                • Top — (Float)

                  The top coordinate of the bounding box as a ratio of overall document page height.

              • Polygon — (Array<map>)

                Within the bounding box, a fine-grained polygon around the recognized item.

                • X — (Float)

                  The value of the X coordinate for a point on a Polygon.

                • Y — (Float)

                  The value of the Y coordinate for a point on a Polygon.

            • Confidence — (Float)

              The confidence in detection, as a percentage

          • ValueDetection — (map)

            The value of a detected element. Present in explicit and implicit elements.

            • Text — (String)

              The word or line of text recognized by Amazon Textract

            • Geometry — (map)

              Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

              • BoundingBox — (map)

                An axis-aligned coarse representation of the location of the recognized item on the document page.

                • Width — (Float)

                  The width of the bounding box as a ratio of the overall document page width.

                • Height — (Float)

                  The height of the bounding box as a ratio of the overall document page height.

                • Left — (Float)

                  The left coordinate of the bounding box as a ratio of overall document page width.

                • Top — (Float)

                  The top coordinate of the bounding box as a ratio of overall document page height.

              • Polygon — (Array<map>)

                Within the bounding box, a fine-grained polygon around the recognized item.

                • X — (Float)

                  The value of the X coordinate for a point on a Polygon.

                • Y — (Float)

                  The value of the Y coordinate for a point on a Polygon.

            • Confidence — (Float)

              The confidence in detection, as a percentage

          • PageNumber — (Integer)

            The page number the value was detected on.

        • LineItemGroups — (Array<map>)

          Information detected on each table of a document, seperated into LineItems.

          • LineItemGroupIndex — (Integer)

            The number used to identify a specific table in a document. The first table encountered will have a LineItemGroupIndex of 1, the second 2, etc.

          • LineItems — (Array<map>)

            The breakdown of information on a particular line of a table.

            • LineItemExpenseFields — (Array<map>)

              ExpenseFields used to show information from detected lines on a table.

              • Type — (map)

                The implied label of a detected element. Present alongside LabelDetection for explicit elements.

                • Text — (String)

                  The word or line of text detected by Amazon Textract.

                • Confidence — (Float)

                  The confidence of accuracy, as a percentage.

              • LabelDetection — (map)

                The explicitly stated label of a detected element.

                • Text — (String)

                  The word or line of text recognized by Amazon Textract

                • Geometry — (map)

                  Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

                  • BoundingBox — (map)

                    An axis-aligned coarse representation of the location of the recognized item on the document page.

                    • Width — (Float)

                      The width of the bounding box as a ratio of the overall document page width.

                    • Height — (Float)

                      The height of the bounding box as a ratio of the overall document page height.

                    • Left — (Float)

                      The left coordinate of the bounding box as a ratio of overall document page width.

                    • Top — (Float)

                      The top coordinate of the bounding box as a ratio of overall document page height.

                  • Polygon — (Array<map>)

                    Within the bounding box, a fine-grained polygon around the recognized item.

                    • X — (Float)

                      The value of the X coordinate for a point on a Polygon.

                    • Y — (Float)

                      The value of the Y coordinate for a point on a Polygon.

                • Confidence — (Float)

                  The confidence in detection, as a percentage

              • ValueDetection — (map)

                The value of a detected element. Present in explicit and implicit elements.

                • Text — (String)

                  The word or line of text recognized by Amazon Textract

                • Geometry — (map)

                  Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

                  • BoundingBox — (map)

                    An axis-aligned coarse representation of the location of the recognized item on the document page.

                    • Width — (Float)

                      The width of the bounding box as a ratio of the overall document page width.

                    • Height — (Float)

                      The height of the bounding box as a ratio of the overall document page height.

                    • Left — (Float)

                      The left coordinate of the bounding box as a ratio of overall document page width.

                    • Top — (Float)

                      The top coordinate of the bounding box as a ratio of overall document page height.

                  • Polygon — (Array<map>)

                    Within the bounding box, a fine-grained polygon around the recognized item.

                    • X — (Float)

                      The value of the X coordinate for a point on a Polygon.

                    • Y — (Float)

                      The value of the Y coordinate for a point on a Polygon.

                • Confidence — (Float)

                  The confidence in detection, as a percentage

              • PageNumber — (Integer)

                The page number the value was detected on.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

detectDocumentText(params = {}, callback) ⇒ AWS.Request

Detects text in the input document. Amazon Textract can detect lines of text and the words that make up a line of text. The input document must be an image in JPEG or PNG format. DetectDocumentText returns the detected text in an array of Block objects.

Each document page has as an associated Block of type PAGE. Each PAGE Block object is the parent of LINE Block objects that represent the lines of detected text on a page. A LINE Block object is a parent for each word that makes up the line. Words are represented by Block objects of type WORD.

DetectDocumentText is a synchronous operation. To analyze documents asynchronously, use StartDocumentTextDetection.

For more information, see Document Text Detection.

Service Reference:

Examples:

Calling the detectDocumentText operation

var params = {
  Document: { /* required */
    Bytes: Buffer.from('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */,
    S3Object: {
      Bucket: 'STRING_VALUE',
      Name: 'STRING_VALUE',
      Version: 'STRING_VALUE'
    }
  }
};
textract.detectDocumentText(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • Document — (map)

      The input document as base64-encoded bytes or an Amazon S3 object. If you use the AWS CLI to call Amazon Textract operations, you can't pass image bytes. The document must be an image in JPEG or PNG format.

      If you're using an AWS SDK to call Amazon Textract, you might not need to base64-encode image bytes that are passed using the Bytes field.

      • Bytes — (Buffer, Typed Array, Blob, String)

        A blob of base64-encoded document bytes. The maximum size of a document that's provided in a blob of bytes is 5 MB. The document bytes must be in PNG or JPEG format.

        If you're using an AWS SDK to call Amazon Textract, you might not need to base64-encode image bytes passed using the Bytes field.

      • S3Object — (map)

        Identifies an S3 object as the document source. The maximum size of a document that's stored in an S3 bucket is 5 MB.

        • Bucket — (String)

          The name of the S3 bucket. Note that the # character is not valid in the file name.

        • Name — (String)

          The file name of the input document. Synchronous operations can use image files that are in JPEG or PNG format. Asynchronous operations also support PDF and TIFF format files.

        • Version — (String)

          If the bucket has versioning enabled, you can specify the object version.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • DocumentMetadata — (map)

        Metadata about the document. It contains the number of pages that are detected in the document.

        • Pages — (Integer)

          The number of pages that are detected in the document.

      • Blocks — (Array<map>)

        An array of Block objects that contain the text that's detected in the document.

        • BlockType — (String)

          The type of text item that's recognized. In operations for text detection, the following types are returned:

          • PAGE - Contains a list of the LINE Block objects that are detected on a document page.

          • WORD - A word detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          In text analysis operations, the following types are returned:

          • PAGE - Contains a list of child Block objects that are detected on a document page.

          • KEY_VALUE_SET - Stores the KEY and VALUE Block objects for linked text that's detected on a document page. Use the EntityType field to determine if a KEY_VALUE_SET object is a KEY Block object or a VALUE Block object.

          • WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          • TABLE - A table that's detected on a document page. A table is grid-based information with two or more rows or columns, with a cell span of one row and one column each.

          • CELL - A cell within a detected table. The cell is the parent of the block that contains the text in the cell.

          • SELECTION_ELEMENT - A selection element such as an option button (radio button) or a check box that's detected on a document page. Use the value of SelectionStatus to determine the status of the selection element.

          Possible values include:
          • "KEY_VALUE_SET"
          • "PAGE"
          • "LINE"
          • "WORD"
          • "TABLE"
          • "CELL"
          • "SELECTION_ELEMENT"
        • Confidence — (Float)

          The confidence score that Amazon Textract has in the accuracy of the recognized text and the accuracy of the geometry points around the recognized text.

        • Text — (String)

          The word or line of text that's recognized by Amazon Textract.

        • TextType — (String)

          The kind of text that Amazon Textract has detected. Can check for handwritten text and printed text.

          Possible values include:
          • "HANDWRITING"
          • "PRINTED"
        • RowIndex — (Integer)

          The row in which a table cell is located. The first row position is 1. RowIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnIndex — (Integer)

          The column in which a table cell appears. The first column position is 1. ColumnIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • RowSpan — (Integer)

          The number of rows that a table cell spans. Currently this value is always 1, even if the number of rows spanned is greater than 1. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. Currently this value is always 1, even if the number of columns spanned is greater than 1. ColumnSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • Geometry — (map)

          The location of the recognized text on the image. It includes an axis-aligned, coarse bounding box that surrounds the text, and a finer-grain polygon for more accurate spatial information.

          • BoundingBox — (map)

            An axis-aligned coarse representation of the location of the recognized item on the document page.

            • Width — (Float)

              The width of the bounding box as a ratio of the overall document page width.

            • Height — (Float)

              The height of the bounding box as a ratio of the overall document page height.

            • Left — (Float)

              The left coordinate of the bounding box as a ratio of overall document page width.

            • Top — (Float)

              The top coordinate of the bounding box as a ratio of overall document page height.

          • Polygon — (Array<map>)

            Within the bounding box, a fine-grained polygon around the recognized item.

            • X — (Float)

              The value of the X coordinate for a point on a Polygon.

            • Y — (Float)

              The value of the Y coordinate for a point on a Polygon.

        • Id — (String)

          The identifier for the recognized text. The identifier is only unique for a single operation.

        • Relationships — (Array<map>)

          A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text. There aren't Relationship objects in the list for relationships that don't exist, such as when the current block has no child blocks. The list size can be the following:

          • 0 - The block has no child blocks.

          • 1 - The block has child blocks.

          • Type — (String)

            The type of relationship that the blocks in the IDs array have with the current block. The relationship can be VALUE or CHILD. A relationship of type VALUE is a list that contains the ID of the VALUE block that's associated with the KEY of a key-value pair. A relationship of type CHILD is a list of IDs that identify WORD blocks in the case of lines Cell blocks in the case of Tables, and WORD blocks in the case of Selection Elements.

            Possible values include:
            • "VALUE"
            • "CHILD"
            • "COMPLEX_FEATURES"
          • Ids — (Array<String>)

            An array of IDs for related blocks. You can get the type of the relationship from the Type element.

        • EntityTypes — (Array<String>)

          The type of entity. The following can be returned:

          • KEY - An identifier for a field on the document.

          • VALUE - The field text.

          EntityTypes isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • SelectionStatus — (String)

          The selection status of a selection element, such as an option button or check box.

          Possible values include:
          • "SELECTED"
          • "NOT_SELECTED"
        • Page — (Integer)

          The page on which a block was detected. Page is returned by asynchronous operations. Page values greater than 1 are only returned for multipage documents that are in PDF or TIFF format. A scanned image (JPEG/PNG), even if it contains multiple document pages, is considered to be a single-page document. The value of Page is always 1. Synchronous operations don't return Page because every input document is considered to be a single-page document.

      • DetectDocumentTextModelVersion — (String)

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

getDocumentAnalysis(params = {}, callback) ⇒ AWS.Request

Gets the results for an Amazon Textract asynchronous operation that analyzes text in a document.

You start asynchronous text analysis by calling StartDocumentAnalysis, which returns a job identifier (JobId). When the text analysis operation finishes, Amazon Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that's registered in the initial call to StartDocumentAnalysis. To get the results of the text-detection operation, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetDocumentAnalysis, and pass the job identifier (JobId) from the initial call to StartDocumentAnalysis.

GetDocumentAnalysis returns an array of Block objects. The following types of information are returned:

  • Form data (key-value pairs). The related information is returned in two Block objects, each of type KEY_VALUE_SET: a KEY Block object and a VALUE Block object. For example, Name: Ana Silva Carolina contains a key and value. Name: is the key. Ana Silva Carolina is the value.

  • Table and table cell data. A TABLE Block object contains information about a detected table. A CELL Block object is returned for each cell in a table.

  • Lines and words of text. A LINE Block object contains one or more WORD Block objects. All lines and words that are detected in the document are returned (including text that doesn't have a relationship with the value of the StartDocumentAnalysis FeatureTypes input parameter).

Selection elements such as check boxes and option buttons (radio buttons) can be detected in form data and in tables. A SELECTION_ELEMENT Block object contains information about a selection element, including the selection status.

Use the MaxResults parameter to limit the number of blocks that are returned. If there are more results than specified in MaxResults, the value of NextToken in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call GetDocumentAnalysis, and populate the NextToken request parameter with the token value that's returned from the previous call to GetDocumentAnalysis.

For more information, see Document Text Analysis.

Service Reference:

Examples:

Calling the getDocumentAnalysis operation

var params = {
  JobId: 'STRING_VALUE', /* required */
  MaxResults: 'NUMBER_VALUE',
  NextToken: 'STRING_VALUE'
};
textract.getDocumentAnalysis(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • JobId — (String)

      A unique identifier for the text-detection job. The JobId is returned from StartDocumentAnalysis. A JobId value is only valid for 7 days.

    • MaxResults — (Integer)

      The maximum number of results to return per paginated call. The largest value that you can specify is 1,000. If you specify a value greater than 1,000, a maximum of 1,000 results is returned. The default value is 1,000.

    • NextToken — (String)

      If the previous response was incomplete (because there are more blocks to retrieve), Amazon Textract returns a pagination token in the response. You can use this pagination token to retrieve the next set of blocks.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • DocumentMetadata — (map)

        Information about a document that Amazon Textract processed. DocumentMetadata is returned in every page of paginated responses from an Amazon Textract video operation.

        • Pages — (Integer)

          The number of pages that are detected in the document.

      • JobStatus — (String)

        The current status of the text detection job.

        Possible values include:
        • "IN_PROGRESS"
        • "SUCCEEDED"
        • "FAILED"
        • "PARTIAL_SUCCESS"
      • NextToken — (String)

        If the response is truncated, Amazon Textract returns this token. You can use this token in the subsequent request to retrieve the next set of text detection results.

      • Blocks — (Array<map>)

        The results of the text-analysis operation.

        • BlockType — (String)

          The type of text item that's recognized. In operations for text detection, the following types are returned:

          • PAGE - Contains a list of the LINE Block objects that are detected on a document page.

          • WORD - A word detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          In text analysis operations, the following types are returned:

          • PAGE - Contains a list of child Block objects that are detected on a document page.

          • KEY_VALUE_SET - Stores the KEY and VALUE Block objects for linked text that's detected on a document page. Use the EntityType field to determine if a KEY_VALUE_SET object is a KEY Block object or a VALUE Block object.

          • WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          • TABLE - A table that's detected on a document page. A table is grid-based information with two or more rows or columns, with a cell span of one row and one column each.

          • CELL - A cell within a detected table. The cell is the parent of the block that contains the text in the cell.

          • SELECTION_ELEMENT - A selection element such as an option button (radio button) or a check box that's detected on a document page. Use the value of SelectionStatus to determine the status of the selection element.

          Possible values include:
          • "KEY_VALUE_SET"
          • "PAGE"
          • "LINE"
          • "WORD"
          • "TABLE"
          • "CELL"
          • "SELECTION_ELEMENT"
        • Confidence — (Float)

          The confidence score that Amazon Textract has in the accuracy of the recognized text and the accuracy of the geometry points around the recognized text.

        • Text — (String)

          The word or line of text that's recognized by Amazon Textract.

        • TextType — (String)

          The kind of text that Amazon Textract has detected. Can check for handwritten text and printed text.

          Possible values include:
          • "HANDWRITING"
          • "PRINTED"
        • RowIndex — (Integer)

          The row in which a table cell is located. The first row position is 1. RowIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnIndex — (Integer)

          The column in which a table cell appears. The first column position is 1. ColumnIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • RowSpan — (Integer)

          The number of rows that a table cell spans. Currently this value is always 1, even if the number of rows spanned is greater than 1. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. Currently this value is always 1, even if the number of columns spanned is greater than 1. ColumnSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • Geometry — (map)

          The location of the recognized text on the image. It includes an axis-aligned, coarse bounding box that surrounds the text, and a finer-grain polygon for more accurate spatial information.

          • BoundingBox — (map)

            An axis-aligned coarse representation of the location of the recognized item on the document page.

            • Width — (Float)

              The width of the bounding box as a ratio of the overall document page width.

            • Height — (Float)

              The height of the bounding box as a ratio of the overall document page height.

            • Left — (Float)

              The left coordinate of the bounding box as a ratio of overall document page width.

            • Top — (Float)

              The top coordinate of the bounding box as a ratio of overall document page height.

          • Polygon — (Array<map>)

            Within the bounding box, a fine-grained polygon around the recognized item.

            • X — (Float)

              The value of the X coordinate for a point on a Polygon.

            • Y — (Float)

              The value of the Y coordinate for a point on a Polygon.

        • Id — (String)

          The identifier for the recognized text. The identifier is only unique for a single operation.

        • Relationships — (Array<map>)

          A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text. There aren't Relationship objects in the list for relationships that don't exist, such as when the current block has no child blocks. The list size can be the following:

          • 0 - The block has no child blocks.

          • 1 - The block has child blocks.

          • Type — (String)

            The type of relationship that the blocks in the IDs array have with the current block. The relationship can be VALUE or CHILD. A relationship of type VALUE is a list that contains the ID of the VALUE block that's associated with the KEY of a key-value pair. A relationship of type CHILD is a list of IDs that identify WORD blocks in the case of lines Cell blocks in the case of Tables, and WORD blocks in the case of Selection Elements.

            Possible values include:
            • "VALUE"
            • "CHILD"
            • "COMPLEX_FEATURES"
          • Ids — (Array<String>)

            An array of IDs for related blocks. You can get the type of the relationship from the Type element.

        • EntityTypes — (Array<String>)

          The type of entity. The following can be returned:

          • KEY - An identifier for a field on the document.

          • VALUE - The field text.

          EntityTypes isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • SelectionStatus — (String)

          The selection status of a selection element, such as an option button or check box.

          Possible values include:
          • "SELECTED"
          • "NOT_SELECTED"
        • Page — (Integer)

          The page on which a block was detected. Page is returned by asynchronous operations. Page values greater than 1 are only returned for multipage documents that are in PDF or TIFF format. A scanned image (JPEG/PNG), even if it contains multiple document pages, is considered to be a single-page document. The value of Page is always 1. Synchronous operations don't return Page because every input document is considered to be a single-page document.

      • Warnings — (Array<map>)

        A list of warnings that occurred during the document-analysis operation.

        • ErrorCode — (String)

          The error code for the warning.

        • Pages — (Array<Integer>)

          A list of the pages that the warning applies to.

      • StatusMessage — (String)

        Returns if the detection job could not be completed. Contains explanation for what error occured.

      • AnalyzeDocumentModelVersion — (String)

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

getDocumentTextDetection(params = {}, callback) ⇒ AWS.Request

Gets the results for an Amazon Textract asynchronous operation that detects text in a document. Amazon Textract can detect lines of text and the words that make up a line of text.

You start asynchronous text detection by calling StartDocumentTextDetection, which returns a job identifier (JobId). When the text detection operation finishes, Amazon Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that's registered in the initial call to StartDocumentTextDetection. To get the results of the text-detection operation, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetDocumentTextDetection, and pass the job identifier (JobId) from the initial call to StartDocumentTextDetection.

GetDocumentTextDetection returns an array of Block objects.

Each document page has as an associated Block of type PAGE. Each PAGE Block object is the parent of LINE Block objects that represent the lines of detected text on a page. A LINE Block object is a parent for each word that makes up the line. Words are represented by Block objects of type WORD.

Use the MaxResults parameter to limit the number of blocks that are returned. If there are more results than specified in MaxResults, the value of NextToken in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call GetDocumentTextDetection, and populate the NextToken request parameter with the token value that's returned from the previous call to GetDocumentTextDetection.

For more information, see Document Text Detection.

Service Reference:

Examples:

Calling the getDocumentTextDetection operation

var params = {
  JobId: 'STRING_VALUE', /* required */
  MaxResults: 'NUMBER_VALUE',
  NextToken: 'STRING_VALUE'
};
textract.getDocumentTextDetection(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • JobId — (String)

      A unique identifier for the text detection job. The JobId is returned from StartDocumentTextDetection. A JobId value is only valid for 7 days.

    • MaxResults — (Integer)

      The maximum number of results to return per paginated call. The largest value you can specify is 1,000. If you specify a value greater than 1,000, a maximum of 1,000 results is returned. The default value is 1,000.

    • NextToken — (String)

      If the previous response was incomplete (because there are more blocks to retrieve), Amazon Textract returns a pagination token in the response. You can use this pagination token to retrieve the next set of blocks.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • DocumentMetadata — (map)

        Information about a document that Amazon Textract processed. DocumentMetadata is returned in every page of paginated responses from an Amazon Textract video operation.

        • Pages — (Integer)

          The number of pages that are detected in the document.

      • JobStatus — (String)

        The current status of the text detection job.

        Possible values include:
        • "IN_PROGRESS"
        • "SUCCEEDED"
        • "FAILED"
        • "PARTIAL_SUCCESS"
      • NextToken — (String)

        If the response is truncated, Amazon Textract returns this token. You can use this token in the subsequent request to retrieve the next set of text-detection results.

      • Blocks — (Array<map>)

        The results of the text-detection operation.

        • BlockType — (String)

          The type of text item that's recognized. In operations for text detection, the following types are returned:

          • PAGE - Contains a list of the LINE Block objects that are detected on a document page.

          • WORD - A word detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          In text analysis operations, the following types are returned:

          • PAGE - Contains a list of child Block objects that are detected on a document page.

          • KEY_VALUE_SET - Stores the KEY and VALUE Block objects for linked text that's detected on a document page. Use the EntityType field to determine if a KEY_VALUE_SET object is a KEY Block object or a VALUE Block object.

          • WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.

          • LINE - A string of tab-delimited, contiguous words that are detected on a document page.

          • TABLE - A table that's detected on a document page. A table is grid-based information with two or more rows or columns, with a cell span of one row and one column each.

          • CELL - A cell within a detected table. The cell is the parent of the block that contains the text in the cell.

          • SELECTION_ELEMENT - A selection element such as an option button (radio button) or a check box that's detected on a document page. Use the value of SelectionStatus to determine the status of the selection element.

          Possible values include:
          • "KEY_VALUE_SET"
          • "PAGE"
          • "LINE"
          • "WORD"
          • "TABLE"
          • "CELL"
          • "SELECTION_ELEMENT"
        • Confidence — (Float)

          The confidence score that Amazon Textract has in the accuracy of the recognized text and the accuracy of the geometry points around the recognized text.

        • Text — (String)

          The word or line of text that's recognized by Amazon Textract.

        • TextType — (String)

          The kind of text that Amazon Textract has detected. Can check for handwritten text and printed text.

          Possible values include:
          • "HANDWRITING"
          • "PRINTED"
        • RowIndex — (Integer)

          The row in which a table cell is located. The first row position is 1. RowIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnIndex — (Integer)

          The column in which a table cell appears. The first column position is 1. ColumnIndex isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • RowSpan — (Integer)

          The number of rows that a table cell spans. Currently this value is always 1, even if the number of rows spanned is greater than 1. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. Currently this value is always 1, even if the number of columns spanned is greater than 1. ColumnSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • Geometry — (map)

          The location of the recognized text on the image. It includes an axis-aligned, coarse bounding box that surrounds the text, and a finer-grain polygon for more accurate spatial information.

          • BoundingBox — (map)

            An axis-aligned coarse representation of the location of the recognized item on the document page.

            • Width — (Float)

              The width of the bounding box as a ratio of the overall document page width.

            • Height — (Float)

              The height of the bounding box as a ratio of the overall document page height.

            • Left — (Float)

              The left coordinate of the bounding box as a ratio of overall document page width.

            • Top — (Float)

              The top coordinate of the bounding box as a ratio of overall document page height.

          • Polygon — (Array<map>)

            Within the bounding box, a fine-grained polygon around the recognized item.

            • X — (Float)

              The value of the X coordinate for a point on a Polygon.

            • Y — (Float)

              The value of the Y coordinate for a point on a Polygon.

        • Id — (String)

          The identifier for the recognized text. The identifier is only unique for a single operation.

        • Relationships — (Array<map>)

          A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text. There aren't Relationship objects in the list for relationships that don't exist, such as when the current block has no child blocks. The list size can be the following:

          • 0 - The block has no child blocks.

          • 1 - The block has child blocks.

          • Type — (String)

            The type of relationship that the blocks in the IDs array have with the current block. The relationship can be VALUE or CHILD. A relationship of type VALUE is a list that contains the ID of the VALUE block that's associated with the KEY of a key-value pair. A relationship of type CHILD is a list of IDs that identify WORD blocks in the case of lines Cell blocks in the case of Tables, and WORD blocks in the case of Selection Elements.

            Possible values include:
            • "VALUE"
            • "CHILD"
            • "COMPLEX_FEATURES"
          • Ids — (Array<String>)

            An array of IDs for related blocks. You can get the type of the relationship from the Type element.

        • EntityTypes — (Array<String>)

          The type of entity. The following can be returned:

          • KEY - An identifier for a field on the document.

          • VALUE - The field text.

          EntityTypes isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • SelectionStatus — (String)

          The selection status of a selection element, such as an option button or check box.

          Possible values include:
          • "SELECTED"
          • "NOT_SELECTED"
        • Page — (Integer)

          The page on which a block was detected. Page is returned by asynchronous operations. Page values greater than 1 are only returned for multipage documents that are in PDF or TIFF format. A scanned image (JPEG/PNG), even if it contains multiple document pages, is considered to be a single-page document. The value of Page is always 1. Synchronous operations don't return Page because every input document is considered to be a single-page document.

      • Warnings — (Array<map>)

        A list of warnings that occurred during the text-detection operation for the document.

        • ErrorCode — (String)

          The error code for the warning.

        • Pages — (Array<Integer>)

          A list of the pages that the warning applies to.

      • StatusMessage — (String)

        Returns if the detection job could not be completed. Contains explanation for what error occured.

      • DetectDocumentTextModelVersion — (String)

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

getExpenseAnalysis(params = {}, callback) ⇒ AWS.Request

Gets the results for an Amazon Textract asynchronous operation that analyzes invoices and receipts. Amazon Textract finds contact information, items purchased, and vendor name, from input invoices and receipts.

You start asynchronous invoice/receipt analysis by calling StartExpenseAnalysis, which returns a job identifier (JobId). Upon completion of the invoice/receipt analysis, Amazon Textract publishes the completion status to the Amazon Simple Notification Service (Amazon SNS) topic. This topic must be registered in the initial call to StartExpenseAnalysis. To get the results of the invoice/receipt analysis operation, first ensure that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetExpenseAnalysis, and pass the job identifier (JobId) from the initial call to StartExpenseAnalysis.

Use the MaxResults parameter to limit the number of blocks that are returned. If there are more results than specified in MaxResults, the value of NextToken in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call GetExpenseAnalysis, and populate the NextToken request parameter with the token value that's returned from the previous call to GetExpenseAnalysis.

For more information, see Analyzing Invoices and Receipts.

Service Reference:

Examples:

Calling the getExpenseAnalysis operation

var params = {
  JobId: 'STRING_VALUE', /* required */
  MaxResults: 'NUMBER_VALUE',
  NextToken: 'STRING_VALUE'
};
textract.getExpenseAnalysis(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • JobId — (String)

      A unique identifier for the text detection job. The JobId is returned from StartExpenseAnalysis. A JobId value is only valid for 7 days.

    • MaxResults — (Integer)

      The maximum number of results to return per paginated call. The largest value you can specify is 20. If you specify a value greater than 20, a maximum of 20 results is returned. The default value is 20.

    • NextToken — (String)

      If the previous response was incomplete (because there are more blocks to retrieve), Amazon Textract returns a pagination token in the response. You can use this pagination token to retrieve the next set of blocks.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • DocumentMetadata — (map)

        Information about a document that Amazon Textract processed. DocumentMetadata is returned in every page of paginated responses from an Amazon Textract operation.

        • Pages — (Integer)

          The number of pages that are detected in the document.

      • JobStatus — (String)

        The current status of the text detection job.

        Possible values include:
        • "IN_PROGRESS"
        • "SUCCEEDED"
        • "FAILED"
        • "PARTIAL_SUCCESS"
      • NextToken — (String)

        If the response is truncated, Amazon Textract returns this token. You can use this token in the subsequent request to retrieve the next set of text-detection results.

      • ExpenseDocuments — (Array<map>)

        The expenses detected by Amazon Textract.

        • ExpenseIndex — (Integer)

          Denotes which invoice or receipt in the document the information is coming from. First document will be 1, the second 2, and so on.

        • SummaryFields — (Array<map>)

          Any information found outside of a table by Amazon Textract.

          • Type — (map)

            The implied label of a detected element. Present alongside LabelDetection for explicit elements.

            • Text — (String)

              The word or line of text detected by Amazon Textract.

            • Confidence — (Float)

              The confidence of accuracy, as a percentage.

          • LabelDetection — (map)

            The explicitly stated label of a detected element.

            • Text — (String)

              The word or line of text recognized by Amazon Textract

            • Geometry — (map)

              Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

              • BoundingBox — (map)

                An axis-aligned coarse representation of the location of the recognized item on the document page.

                • Width — (Float)

                  The width of the bounding box as a ratio of the overall document page width.

                • Height — (Float)

                  The height of the bounding box as a ratio of the overall document page height.

                • Left — (Float)

                  The left coordinate of the bounding box as a ratio of overall document page width.

                • Top — (Float)

                  The top coordinate of the bounding box as a ratio of overall document page height.

              • Polygon — (Array<map>)

                Within the bounding box, a fine-grained polygon around the recognized item.

                • X — (Float)

                  The value of the X coordinate for a point on a Polygon.

                • Y — (Float)

                  The value of the Y coordinate for a point on a Polygon.

            • Confidence — (Float)

              The confidence in detection, as a percentage

          • ValueDetection — (map)

            The value of a detected element. Present in explicit and implicit elements.

            • Text — (String)

              The word or line of text recognized by Amazon Textract

            • Geometry — (map)

              Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

              • BoundingBox — (map)

                An axis-aligned coarse representation of the location of the recognized item on the document page.

                • Width — (Float)

                  The width of the bounding box as a ratio of the overall document page width.

                • Height — (Float)

                  The height of the bounding box as a ratio of the overall document page height.

                • Left — (Float)

                  The left coordinate of the bounding box as a ratio of overall document page width.

                • Top — (Float)

                  The top coordinate of the bounding box as a ratio of overall document page height.

              • Polygon — (Array<map>)

                Within the bounding box, a fine-grained polygon around the recognized item.

                • X — (Float)

                  The value of the X coordinate for a point on a Polygon.

                • Y — (Float)

                  The value of the Y coordinate for a point on a Polygon.

            • Confidence — (Float)

              The confidence in detection, as a percentage

          • PageNumber — (Integer)

            The page number the value was detected on.

        • LineItemGroups — (Array<map>)

          Information detected on each table of a document, seperated into LineItems.

          • LineItemGroupIndex — (Integer)

            The number used to identify a specific table in a document. The first table encountered will have a LineItemGroupIndex of 1, the second 2, etc.

          • LineItems — (Array<map>)

            The breakdown of information on a particular line of a table.

            • LineItemExpenseFields — (Array<map>)

              ExpenseFields used to show information from detected lines on a table.

              • Type — (map)

                The implied label of a detected element. Present alongside LabelDetection for explicit elements.

                • Text — (String)

                  The word or line of text detected by Amazon Textract.

                • Confidence — (Float)

                  The confidence of accuracy, as a percentage.

              • LabelDetection — (map)

                The explicitly stated label of a detected element.

                • Text — (String)

                  The word or line of text recognized by Amazon Textract

                • Geometry — (map)

                  Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

                  • BoundingBox — (map)

                    An axis-aligned coarse representation of the location of the recognized item on the document page.

                    • Width — (Float)

                      The width of the bounding box as a ratio of the overall document page width.

                    • Height — (Float)

                      The height of the bounding box as a ratio of the overall document page height.

                    • Left — (Float)

                      The left coordinate of the bounding box as a ratio of overall document page width.

                    • Top — (Float)

                      The top coordinate of the bounding box as a ratio of overall document page height.

                  • Polygon — (Array<map>)

                    Within the bounding box, a fine-grained polygon around the recognized item.

                    • X — (Float)

                      The value of the X coordinate for a point on a Polygon.

                    • Y — (Float)

                      The value of the Y coordinate for a point on a Polygon.

                • Confidence — (Float)

                  The confidence in detection, as a percentage

              • ValueDetection — (map)

                The value of a detected element. Present in explicit and implicit elements.

                • Text — (String)

                  The word or line of text recognized by Amazon Textract

                • Geometry — (map)

                  Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements.

                  • BoundingBox — (map)

                    An axis-aligned coarse representation of the location of the recognized item on the document page.

                    • Width — (Float)

                      The width of the bounding box as a ratio of the overall document page width.

                    • Height — (Float)

                      The height of the bounding box as a ratio of the overall document page height.

                    • Left — (Float)

                      The left coordinate of the bounding box as a ratio of overall document page width.

                    • Top — (Float)

                      The top coordinate of the bounding box as a ratio of overall document page height.

                  • Polygon — (Array<map>)

                    Within the bounding box, a fine-grained polygon around the recognized item.

                    • X — (Float)

                      The value of the X coordinate for a point on a Polygon.

                    • Y — (Float)

                      The value of the Y coordinate for a point on a Polygon.

                • Confidence — (Float)

                  The confidence in detection, as a percentage

              • PageNumber — (Integer)

                The page number the value was detected on.

      • Warnings — (Array<map>)

        A list of warnings that occurred during the text-detection operation for the document.

        • ErrorCode — (String)

          The error code for the warning.

        • Pages — (Array<Integer>)

          A list of the pages that the warning applies to.

      • StatusMessage — (String)

        Returns if the detection job could not be completed. Contains explanation for what error occured.

      • AnalyzeExpenseModelVersion — (String)

        The current model version of AnalyzeExpense.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

startDocumentAnalysis(params = {}, callback) ⇒ AWS.Request

Starts the asynchronous analysis of an input document for relationships between detected items such as key-value pairs, tables, and selection elements.

StartDocumentAnalysis can analyze text in documents that are in JPEG, PNG, TIFF, and PDF format. The documents are stored in an Amazon S3 bucket. Use DocumentLocation to specify the bucket name and file name of the document.

StartDocumentAnalysis returns a job identifier (JobId) that you use to get the results of the operation. When text analysis is finished, Amazon Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that you specify in NotificationChannel. To get the results of the text analysis operation, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetDocumentAnalysis, and pass the job identifier (JobId) from the initial call to StartDocumentAnalysis.

For more information, see Document Text Analysis.

Service Reference:

Examples:

Calling the startDocumentAnalysis operation

var params = {
  DocumentLocation: { /* required */
    S3Object: {
      Bucket: 'STRING_VALUE',
      Name: 'STRING_VALUE',
      Version: 'STRING_VALUE'
    }
  },
  FeatureTypes: [ /* required */
    TABLES | FORMS,
    /* more items */
  ],
  ClientRequestToken: 'STRING_VALUE',
  JobTag: 'STRING_VALUE',
  KMSKeyId: 'STRING_VALUE',
  NotificationChannel: {
    RoleArn: 'STRING_VALUE', /* required */
    SNSTopicArn: 'STRING_VALUE' /* required */
  },
  OutputConfig: {
    S3Bucket: 'STRING_VALUE', /* required */
    S3Prefix: 'STRING_VALUE'
  }
};
textract.startDocumentAnalysis(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • DocumentLocation — (map)

      The location of the document to be processed.

      • S3Object — (map)

        The Amazon S3 bucket that contains the input document.

        • Bucket — (String)

          The name of the S3 bucket. Note that the # character is not valid in the file name.

        • Name — (String)

          The file name of the input document. Synchronous operations can use image files that are in JPEG or PNG format. Asynchronous operations also support PDF and TIFF format files.

        • Version — (String)

          If the bucket has versioning enabled, you can specify the object version.

    • FeatureTypes — (Array<String>)

      A list of the types of analysis to perform. Add TABLES to the list to return information about the tables that are detected in the input document. Add FORMS to return detected form data. To perform both types of analysis, add TABLES and FORMS to FeatureTypes. All lines and words detected in the document are included in the response (including text that isn't related to the value of FeatureTypes).

    • ClientRequestToken — (String)

      The idempotent token that you use to identify the start request. If you use the same token with multiple StartDocumentAnalysis requests, the same JobId is returned. Use ClientRequestToken to prevent the same job from being accidentally started more than once. For more information, see Calling Amazon Textract Asynchronous Operations.

    • JobTag — (String)

      An identifier that you specify that's included in the completion notification published to the Amazon SNS topic. For example, you can use JobTag to identify the type of document that the completion notification corresponds to (such as a tax form or a receipt).

    • NotificationChannel — (map)

      The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to.

      • SNSTopicArnrequired — (String)

        The Amazon SNS topic that Amazon Textract posts the completion status to.

      • RoleArnrequired — (String)

        The Amazon Resource Name (ARN) of an IAM role that gives Amazon Textract publishing permissions to the Amazon SNS topic.

    • OutputConfig — (map)

      Sets if the output will go to a customer defined bucket. By default, Amazon Textract will save the results internally to be accessed by the GetDocumentAnalysis operation.

      • S3Bucketrequired — (String)

        The name of the bucket your output will go to.

      • S3Prefix — (String)

        The prefix of the object key that the output will be saved to. When not enabled, the prefix will be “textract_output".

    • KMSKeyId — (String)

      The KMS key used to encrypt the inference results. This can be in either Key ID or Key Alias format. When a KMS key is provided, the KMS key will be used for server-side encryption of the objects in the customer bucket. When this parameter is not enabled, the result will be encrypted server side,using SSE-S3.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • JobId — (String)

        The identifier for the document text detection job. Use JobId to identify the job in a subsequent call to GetDocumentAnalysis. A JobId value is only valid for 7 days.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

startDocumentTextDetection(params = {}, callback) ⇒ AWS.Request

Starts the asynchronous detection of text in a document. Amazon Textract can detect lines of text and the words that make up a line of text.

StartDocumentTextDetection can analyze text in documents that are in JPEG, PNG, TIFF, and PDF format. The documents are stored in an Amazon S3 bucket. Use DocumentLocation to specify the bucket name and file name of the document.

StartTextDetection returns a job identifier (JobId) that you use to get the results of the operation. When text detection is finished, Amazon Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that you specify in NotificationChannel. To get the results of the text detection operation, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetDocumentTextDetection, and pass the job identifier (JobId) from the initial call to StartDocumentTextDetection.

For more information, see Document Text Detection.

Service Reference:

Examples:

Calling the startDocumentTextDetection operation

var params = {
  DocumentLocation: { /* required */
    S3Object: {
      Bucket: 'STRING_VALUE',
      Name: 'STRING_VALUE',
      Version: 'STRING_VALUE'
    }
  },
  ClientRequestToken: 'STRING_VALUE',
  JobTag: 'STRING_VALUE',
  KMSKeyId: 'STRING_VALUE',
  NotificationChannel: {
    RoleArn: 'STRING_VALUE', /* required */
    SNSTopicArn: 'STRING_VALUE' /* required */
  },
  OutputConfig: {
    S3Bucket: 'STRING_VALUE', /* required */
    S3Prefix: 'STRING_VALUE'
  }
};
textract.startDocumentTextDetection(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • DocumentLocation — (map)

      The location of the document to be processed.

      • S3Object — (map)

        The Amazon S3 bucket that contains the input document.

        • Bucket — (String)

          The name of the S3 bucket. Note that the # character is not valid in the file name.

        • Name — (String)

          The file name of the input document. Synchronous operations can use image files that are in JPEG or PNG format. Asynchronous operations also support PDF and TIFF format files.

        • Version — (String)

          If the bucket has versioning enabled, you can specify the object version.

    • ClientRequestToken — (String)

      The idempotent token that's used to identify the start request. If you use the same token with multiple StartDocumentTextDetection requests, the same JobId is returned. Use ClientRequestToken to prevent the same job from being accidentally started more than once. For more information, see Calling Amazon Textract Asynchronous Operations.

    • JobTag — (String)

      An identifier that you specify that's included in the completion notification published to the Amazon SNS topic. For example, you can use JobTag to identify the type of document that the completion notification corresponds to (such as a tax form or a receipt).

    • NotificationChannel — (map)

      The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to.

      • SNSTopicArnrequired — (String)

        The Amazon SNS topic that Amazon Textract posts the completion status to.

      • RoleArnrequired — (String)

        The Amazon Resource Name (ARN) of an IAM role that gives Amazon Textract publishing permissions to the Amazon SNS topic.

    • OutputConfig — (map)

      Sets if the output will go to a customer defined bucket. By default Amazon Textract will save the results internally to be accessed with the GetDocumentTextDetection operation.

      • S3Bucketrequired — (String)

        The name of the bucket your output will go to.

      • S3Prefix — (String)

        The prefix of the object key that the output will be saved to. When not enabled, the prefix will be “textract_output".

    • KMSKeyId — (String)

      The KMS key used to encrypt the inference results. This can be in either Key ID or Key Alias format. When a KMS key is provided, the KMS key will be used for server-side encryption of the objects in the customer bucket. When this parameter is not enabled, the result will be encrypted server side,using SSE-S3.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • JobId — (String)

        The identifier of the text detection job for the document. Use JobId to identify the job in a subsequent call to GetDocumentTextDetection. A JobId value is only valid for 7 days.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

startExpenseAnalysis(params = {}, callback) ⇒ AWS.Request

Starts the asynchronous analysis of invoices or receipts for data like contact information, items purchased, and vendor names.

StartExpenseAnalysis can analyze text in documents that are in JPEG, PNG, and PDF format. The documents must be stored in an Amazon S3 bucket. Use the DocumentLocation parameter to specify the name of your S3 bucket and the name of the document in that bucket.

StartExpenseAnalysis returns a job identifier (JobId) that you will provide to GetExpenseAnalysis to retrieve the results of the operation. When the analysis of the input invoices/receipts is finished, Amazon Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that you provide to the NotificationChannel. To obtain the results of the invoice and receipt analysis operation, ensure that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetExpenseAnalysis, and pass the job identifier (JobId) that was returned by your call to StartExpenseAnalysis.

For more information, see Analyzing Invoices and Receipts.

Service Reference:

Examples:

Calling the startExpenseAnalysis operation

var params = {
  DocumentLocation: { /* required */
    S3Object: {
      Bucket: 'STRING_VALUE',
      Name: 'STRING_VALUE',
      Version: 'STRING_VALUE'
    }
  },
  ClientRequestToken: 'STRING_VALUE',
  JobTag: 'STRING_VALUE',
  KMSKeyId: 'STRING_VALUE',
  NotificationChannel: {
    RoleArn: 'STRING_VALUE', /* required */
    SNSTopicArn: 'STRING_VALUE' /* required */
  },
  OutputConfig: {
    S3Bucket: 'STRING_VALUE', /* required */
    S3Prefix: 'STRING_VALUE'
  }
};
textract.startExpenseAnalysis(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • DocumentLocation — (map)

      The location of the document to be processed.

      • S3Object — (map)

        The Amazon S3 bucket that contains the input document.

        • Bucket — (String)

          The name of the S3 bucket. Note that the # character is not valid in the file name.

        • Name — (String)

          The file name of the input document. Synchronous operations can use image files that are in JPEG or PNG format. Asynchronous operations also support PDF and TIFF format files.

        • Version — (String)

          If the bucket has versioning enabled, you can specify the object version.

    • ClientRequestToken — (String)

      The idempotent token that's used to identify the start request. If you use the same token with multiple StartDocumentTextDetection requests, the same JobId is returned. Use ClientRequestToken to prevent the same job from being accidentally started more than once. For more information, see Calling Amazon Textract Asynchronous Operations

    • JobTag — (String)

      An identifier you specify that's included in the completion notification published to the Amazon SNS topic. For example, you can use JobTag to identify the type of document that the completion notification corresponds to (such as a tax form or a receipt).

    • NotificationChannel — (map)

      The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to.

      • SNSTopicArnrequired — (String)

        The Amazon SNS topic that Amazon Textract posts the completion status to.

      • RoleArnrequired — (String)

        The Amazon Resource Name (ARN) of an IAM role that gives Amazon Textract publishing permissions to the Amazon SNS topic.

    • OutputConfig — (map)

      Sets if the output will go to a customer defined bucket. By default, Amazon Textract will save the results internally to be accessed by the GetExpenseAnalysis operation.

      • S3Bucketrequired — (String)

        The name of the bucket your output will go to.

      • S3Prefix — (String)

        The prefix of the object key that the output will be saved to. When not enabled, the prefix will be “textract_output".

    • KMSKeyId — (String)

      The KMS key used to encrypt the inference results. This can be in either Key ID or Key Alias format. When a KMS key is provided, the KMS key will be used for server-side encryption of the objects in the customer bucket. When this parameter is not enabled, the result will be encrypted server side,using SSE-S3.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • JobId — (String)

        A unique identifier for the text detection job. The JobId is returned from StartExpenseAnalysis. A JobId value is only valid for 7 days.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.