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

Property Summary

Properties inherited from AWS.Service

apiVersions

Method Summary

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)

    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'.

  • 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.

  • 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 returns the amount of time to delay in milliseconds. The base option will be ignored if this option is supplied.
  • 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)

    whether to enable endpoint discovery for operations that allow optionally using an endpoint returned by the service. Defaults to 'false'

  • 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.

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:

  • Words and lines that are related to nearby lines and words. 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.

  • Selectable elements such as checkboxes and radio buttons. A SELECTION_ELEMENT Block object contains information about a selectable element.

  • Lines and words of text. A LINE Block object contains one or more WORD Block objects.

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: new Buffer('...') || '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 */
  ]
};
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 JPG or PNG format.

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

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

        A blob of base-64 encoded documents 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 JPG format.

        If you are 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 stored in an S3 bucket is 5 MB.

        • Bucket — (String)

          The name of the S3 bucket.

        • Name — (String)

          The file name of the input document. It must be an image file (.JPG or .PNG format). Asynchronous operations also support PDF 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 detected in the input document. Add FORMS to return detected fields and the associated text. To perform both types of analysis, add TABLES and FORMS to FeatureTypes.

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 detected in the document.

      • Blocks — (Array<map>)

        The text that's detected and analyzed by AnalyzeDocument.

        • BlockType — (String)

          The type of text that's recognized in a block. In text-detection operations, 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's 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 a field 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 detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces that's detected on a document page.

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

          • TABLE - A table that's detected on a document page. A table is any grid-based information with 2 or more rows or columns with a cell span of 1 row and 1 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 selectable element such as a radio button or checkbox 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 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.

        • 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 spans. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. 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 text 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 text.

            • 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.

            Possible values include:
            • "VALUE"
            • "CHILD"
          • 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 selectable element such as a radio button or checkbox.

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

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

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 JPG 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: new Buffer('...') || '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 JPG or PNG format.

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

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

        A blob of base-64 encoded documents 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 JPG format.

        If you are 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 stored in an S3 bucket is 5 MB.

        • Bucket — (String)

          The name of the S3 bucket.

        • Name — (String)

          The file name of the input document. It must be an image file (.JPG or .PNG format). Asynchronous operations also support PDF 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. Contains the number of pages that are detected in the document.

        • Pages — (Integer)

          The number of pages detected in the document.

      • Blocks — (Array<map>)

        An array of Block objects containing the text detected in the document.

        • BlockType — (String)

          The type of text that's recognized in a block. In text-detection operations, 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's 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 a field 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 detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces that's detected on a document page.

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

          • TABLE - A table that's detected on a document page. A table is any grid-based information with 2 or more rows or columns with a cell span of 1 row and 1 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 selectable element such as a radio button or checkbox 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 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.

        • 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 spans. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. 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 text 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 text.

            • 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.

            Possible values include:
            • "VALUE"
            • "CHILD"
          • 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 selectable element such as a radio button or checkbox.

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

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

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:

  • Words and lines that are related to nearby lines and words. 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.

  • Selectable elements such as checkboxes and radio buttons. A SELECTION_ELEMENT Block object contains information about a selectable element.

  • Lines and words of text. A LINE Block object contains one or more WORD Block objects.

Use the MaxResults parameter to limit the number of blocks 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.

    • 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 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 that's recognized in a block. In text-detection operations, 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's 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 a field 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 detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces that's detected on a document page.

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

          • TABLE - A table that's detected on a document page. A table is any grid-based information with 2 or more rows or columns with a cell span of 1 row and 1 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 selectable element such as a radio button or checkbox 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 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.

        • 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 spans. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. 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 text 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 text.

            • 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.

            Possible values include:
            • "VALUE"
            • "CHILD"
          • 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 selectable element such as a radio button or checkbox.

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

          The page in which a block was detected. Page is returned by asynchronous operations. Page values greater than 1 are only returned for multi-page documents that are in PDF format. A scanned image (JPG/PNG), even if it contains multiple document pages, is always considered to be a single-page document and the value of Page is always 1. Synchronous operations don't return Page as 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)

        The current status of an asynchronous document analysis operation.

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.

    • 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 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 that's recognized in a block. In text-detection operations, 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's 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 a field 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 detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces that's detected on a document page.

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

          • TABLE - A table that's detected on a document page. A table is any grid-based information with 2 or more rows or columns with a cell span of 1 row and 1 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 selectable element such as a radio button or checkbox 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 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.

        • 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 spans. RowSpan isn't returned by DetectDocumentText and GetDocumentTextDetection.

        • ColumnSpan — (Integer)

          The number of columns that a table cell spans. 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 text 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 text.

            • 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.

            Possible values include:
            • "VALUE"
            • "CHILD"
          • 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 selectable element such as a radio button or checkbox.

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

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

      • Warnings — (Array<map>)

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

        • ErrorCode — (String)

          The error code for the warning.

        • Pages — (Array<Integer>)

          A list of the pages that the warning applies to.

      • StatusMessage — (String)

        The current status of an asynchronous document text-detection operation.

Returns:

  • (AWS.Request)

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

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

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

StartDocumentAnalysis can analyze text in documents that are in JPG, PNG, 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',
  NotificationChannel: {
    RoleArn: 'STRING_VALUE', /* required */
    SNSTopicArn: 'STRING_VALUE' /* required */
  }
};
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.

        • Name — (String)

          The file name of the input document. It must be an image file (.JPG or .PNG format). Asynchronous operations also support PDF 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 fields and the associated text. To perform both types of analysis, add TABLES and FORMS to FeatureTypes. All selectable elements (SELECTION_ELEMENT) that are detected are returned, whatever 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.

    • JobTag — (String)

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

    • 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.

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.

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 JPG, PNG, 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',
  NotificationChannel: {
    RoleArn: 'STRING_VALUE', /* required */
    SNSTopicArn: 'STRING_VALUE' /* required */
  }
};
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.

        • Name — (String)

          The file name of the input document. It must be an image file (.JPG or .PNG format). Asynchronous operations also support PDF 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.

    • JobTag — (String)

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

    • 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.

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 GetDocumentTextDetection.

Returns:

  • (AWS.Request)

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