Skip to content

start_document_analysis

start_document_analysis(
    document_location: DocumentLocation,
    feature_types: FeatureTypes,
    *,
    config_overrides: Optional[TextractClientConfig] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    job_tag: Optional[JobTag] = None,
    notification_channel: Optional[NotificationChannel] = None,
    output_config: Optional[OutputConfig] = None,
    kms_key_id: Optional[KMSKeyId] = None,
    queries_config: Optional[QueriesConfig] = None,
    adapters_config: Optional[AdaptersConfig] = None,
) -> StartDocumentAnalysisResponse

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.

Parameters:

  • document_location (DocumentLocation) –

    The location of the document to be processed.

  • feature_types (FeatureTypes) –

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

  • client_request_token (Optional[ClientRequestToken], default: None ) –

    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.

  • job_tag (Optional[JobTag], default: None ) –

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

  • notification_channel (Optional[NotificationChannel], default: None ) –

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

  • output_config (Optional[OutputConfig], default: None ) –

    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.

  • kms_key_id (Optional[KMSKeyId], default: None ) –

    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.

  • adapters_config (Optional[AdaptersConfig], default: None ) –

    Specifies the adapter to be used when analyzing a document.

Raises:

  • AccessDeniedException –

    You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) of an authorized user or IAM role to perform the operation.

  • BadDocumentException –

    Amazon Textract isn't able to read the document. For more information on the document limits in Amazon Textract, see Hard limits.

  • DocumentTooLargeException –

    The document can't be processed because it's too large. The maximum document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is 500 MB for PDF files.

  • IdempotentParameterMismatchException –

    A ClientRequestToken input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation.

  • InternalServerError –

    Amazon Textract experienced a service issue. Try your call again.

  • InvalidKMSKeyException –

    Indicates you do not have decrypt permissions with the KMS key entered, or the KMS key was entered incorrectly.

  • InvalidParameterException –

    An input parameter violated a constraint. For example, in synchronous operations, an InvalidParameterException exception occurs when neither of the S3Object or Bytes values are supplied in the Document request parameter. Validate your parameter before calling the API operation again.

  • InvalidS3ObjectException –

    Amazon Textract is unable to access the S3 object that's specified in the request. for more information, Configure Access to Amazon S3 For troubleshooting information, see Troubleshooting Amazon S3

  • LimitExceededException –

    An Amazon Textract service limit was exceeded. For example, if you start too many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Textract service limit.

  • ProvisionedThroughputExceededException –

    The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Textract.

  • ThrottlingException –

    Amazon Textract is temporarily unable to process the request. Try your call again.

  • UnsupportedDocumentException –

    The format of the input document isn't supported. Documents for operations can be in PNG, JPEG, PDF, or TIFF format.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_textract/_services/textract.py
def start_document_analysis(
    self,
    document_location: "capo_textract.types.document_location.DocumentLocation",
    feature_types: "capo_textract.types.feature_types.FeatureTypes",
    *,
    config_overrides: Optional[TextractClientConfig] = None,
    client_request_token: Optional[
        "capo_textract.types.client_request_token.ClientRequestToken"
    ] = None,
    job_tag: Optional["capo_textract.types.job_tag.JobTag"] = None,
    notification_channel: Optional[
        "capo_textract.types.notification_channel.NotificationChannel"
    ] = None,
    output_config: Optional[
        "capo_textract.types.output_config.OutputConfig"
    ] = None,
    kms_key_id: Optional["capo_textract.types.kms_key_id.KMSKeyId"] = None,
    queries_config: Optional[
        "capo_textract.types.queries_config.QueriesConfig"
    ] = None,
    adapters_config: Optional[
        "capo_textract.types.adapters_config.AdaptersConfig"
    ] = None,
) -> "capo_textract.types.start_document_analysis_response.StartDocumentAnalysisResponse":
    """<p>Starts the asynchronous analysis of an input document for relationships between detected items such as key-value pairs, tables, and selection elements.</p> <p> <code>StartDocumentAnalysis</code> can analyze text in documents that are in JPEG, PNG, TIFF, and PDF format. The documents are stored in an Amazon S3 bucket. Use <a>DocumentLocation</a> to specify the bucket name and file name of the document. </p> <p> <code>StartDocumentAnalysis</code> returns a job identifier (<code>JobId</code>) 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 <code>NotificationChannel</code>. To get the results of the text analysis operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetDocumentAnalysis</a>, and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartDocumentAnalysis</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html">Document Text Analysis</a>.</p>

    Args:
        document_location: <p>The location of the document to be processed.</p>
        feature_types: <p>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 <code>FeatureTypes</code>. All lines and words detected in the document are included in the response (including text that isn't related to the value of <code>FeatureTypes</code>). </p>
        client_request_token: <p>The idempotent token that you use to identify the start request. If you use the same token with multiple <code>StartDocumentAnalysis</code> requests, the same <code>JobId</code> is returned. Use <code>ClientRequestToken</code> to prevent the same job from being accidentally started more than once. For more information, see <a href="https://docs.aws.amazon.com/textract/latest/dg/api-async.html">Calling Amazon Textract Asynchronous Operations</a>.</p>
        job_tag: <p>An identifier that you specify that's included in the completion notification published to the Amazon SNS topic. For example, you can use <code>JobTag</code> to identify the type of document that the completion notification corresponds to (such as a tax form or a receipt).</p>
        notification_channel: <p>The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to. </p>
        output_config: <p>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.</p>
        kms_key_id: <p>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.</p>
        adapters_config: <p>Specifies the adapter to be used when analyzing a document.</p>

    Raises:
        capo_textract.errors.access_denied_exception.AccessDeniedException: <p>You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) of an authorized user or IAM role to perform the operation.</p>
        capo_textract.errors.bad_document_exception.BadDocumentException: <p>Amazon Textract isn't able to read the document. For more information on the document limits in Amazon Textract, see <a href="https://docs.aws.amazon.com/textract/latest/dg/limits.html">Hard limits</a>.</p>
        capo_textract.errors.document_too_large_exception.DocumentTooLargeException: <p>The document can't be processed because it's too large. The maximum document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is 500 MB for PDF files.</p>
        capo_textract.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>A <code>ClientRequestToken</code> input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation. </p>
        capo_textract.errors.internal_server_error.InternalServerError: <p>Amazon Textract experienced a service issue. Try your call again.</p>
        capo_textract.errors.invalid_kms_key_exception.InvalidKMSKeyException: <p> Indicates you do not have decrypt permissions with the KMS key entered, or the KMS key was entered incorrectly. </p>
        capo_textract.errors.invalid_parameter_exception.InvalidParameterException: <p>An input parameter violated a constraint. For example, in synchronous operations, an <code>InvalidParameterException</code> exception occurs when neither of the <code>S3Object</code> or <code>Bytes</code> values are supplied in the <code>Document</code> request parameter. Validate your parameter before calling the API operation again.</p>
        capo_textract.errors.invalid_s3_object_exception.InvalidS3ObjectException: <p>Amazon Textract is unable to access the S3 object that's specified in the request. for more information, <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-access-control.html">Configure Access to Amazon S3</a> For troubleshooting information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/troubleshooting.html">Troubleshooting Amazon S3</a> </p>
        capo_textract.errors.limit_exceeded_exception.LimitExceededException: <p>An Amazon Textract service limit was exceeded. For example, if you start too many asynchronous jobs concurrently, calls to start operations (<code>StartDocumentTextDetection</code>, for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Textract service limit. </p>
        capo_textract.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Textract.</p>
        capo_textract.errors.throttling_exception.ThrottlingException: <p>Amazon Textract is temporarily unable to process the request. Try your call again.</p>
        capo_textract.errors.unsupported_document_exception.UnsupportedDocumentException: <p>The format of the input document isn't supported. Documents for operations can be in PNG, JPEG, PDF, or TIFF format.</p>
        capo_textract.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_textract.types.start_document_analysis_request.StartDocumentAnalysisRequest]",
    ) -> OperationResponse[
        "capo_textract.types.start_document_analysis_response.StartDocumentAnalysisResponse"
    ]:
        import capo_textract._operations.textract.start_document_analysis

        output, http_response = (
            capo_textract._operations.textract.start_document_analysis.start_document_analysis(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartDocumentAnalysis")
    )
    input_: capo_textract.types.start_document_analysis_request.StartDocumentAnalysisRequest = {
        "document_location": document_location,
        "feature_types": feature_types,
    }
    if client_request_token is not None:
        input_["client_request_token"] = client_request_token
    if job_tag is not None:
        input_["job_tag"] = job_tag
    if notification_channel is not None:
        input_["notification_channel"] = notification_channel
    if output_config is not None:
        input_["output_config"] = output_config
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if queries_config is not None:
        input_["queries_config"] = queries_config
    if adapters_config is not None:
        input_["adapters_config"] = adapters_config

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output