Content Management and Capture

 View Only

Automation Document Processing API Introduction

By XUE XU posted Sun March 27, 2022 06:06 AM

  

Automation Document Processing provides the capabilities that help you build an AI-powered data enrichment tool for document processing and storage.

ADP API offers document uploading, status checking, downloading JSON output or pdf file and delete document.. Customer could extract desired information from complex electronic document automatically with these APIs.

ADP API is asynchronous, user could send next request immediately without waiting response of current request. For example, when user uploads a document to ADP via API, he does not need to wait online for the progressing complete. Instead, he could continue to work on other documents. .

How to send an ADP API? Let’s talk about it. Note: this applies to CP4BA 21.0.3 and later release, which turns to Zen front door for authentication.

  • Host and URL
<zen host>/adp/aca/v1/projects/<ca project id>/<api endpoint>
For example:
https://cpd-aca.apps.hui.os.fyre.ibm.com/adp/aca/v1/projects/CDL7/analyzers
  •  Authentication header
    • A Zen API key is necessary, encode it with username using base64:
         <username>:<api key> => <Base64 encoded>
         The API key is generated from Zen home page:
 















  • Then add prefix ‘ZenApiKey:
Authorization: ZenApiKey <encoded value>

Following are API examples for uploading document, getting status, getting document json, getting document pdf and deleting document.
  • Upload document
Endpoint: /v1/projects/<project_id>/analyzers
It’s a POST request, accept multiple data in request body, here introduce 3 common fields: “responseType”, “jsonOptions” and “file”.
    • file: file path and name. For example, file=@/Users/xuxue/files/invoice/APT002.pdf
    • responseType: output file format after process, it’s multiple choices. For example, "responseType=json,pdf"
    • jsonOptions: is required if JSON is provided in “responseType”, means which options will include in output json file. If select “kvp”, “dc” must be selected too. For example, "jsonOptions=dc,kvp"
    • Sample with curl command:
Curl -k -X POST "https://cpd-aria-dev.apps.skinned.cp.fyre.ibm.com/adp/aca/v1/projects/ce3ac100-dc7e-4ee2-889e-87916b1b2a62/analyzers"\
 -H "Authorization: ZenApiKey Y2VhZG1pbjpKSFRhOUJMWVpRWWIyV0tBRnh5Y2RvdmVJS01IRTlTcDlrQlZUR0dB"\
 -F "responseType=json,pdf"\
 -F "jsonOptions=dc,kvp,hr,th,ocr,sn,mt,cb,st,ds,char"\
 -F "file=@/Users/xuxue/files/invoice/sonyinvoice.pdf"
  • Get file status
Endpoint: /v1/projects/<project_id>/analyzers/<file_id>
    • It’s GET request, after upload document, user don’t wait for complete, but use this API to get status. The file id is from response of upload document request API.
    • Sample with curl command:
curl -k -X GET "https://cpd-aria-dev.apps.skinned.cp.fyre.ibm.com/adp/aca/v1/projects/ce3ac100-dc7e-4ee2-889e-87916b1b2a62/analyzers/e96c6ffd-94e5-4493-a62c-0550446169de"\
 -H "Authorization: ZenApiKey Y2VhZG1pbjpKSFRhOUJMWVpRWWIyV0tBRnh5Y2RvdmVJS01IRTlTcDlrQlZUR0dB"
  • Get json
Endpoint: /v1/projects/<project_id>/analyzers/<file_id>/json
    • It’s GET request, if select “json” in responseType, after process complete, user could get json content with this API. Returned json content may be large, could save it to a file.
    • There are two versions of JSON output, one is verbose which is default version, another is simple which is basic version. The simple version need to add parameter 'outputJSON=basic'.
    • Sample with curl command:
curl -k -X GET "https://cpd-aria-dev.apps.skinned.cp.fyre.ibm.com/adp/aca/v1/projects/ce3ac100-dc7e-4ee2-889e-87916b1b2a62/analyzers/755d249e-2995-4bdc-a96e-743120d21159/json"\
 -H "Authorization: ZenApiKey Y2VhZG1pbjpKSFRhOUJMWVpRWWIyV0tBRnh5Y2RvdmVJS01IRTlTcDlrQlZUR0dB"
or
curl -k -X GET "https://cpd-aria-dev.apps.skinned.cp.fyre.ibm.com/adp/aca/v1/projects/ce3ac100-dc7e-4ee2-889e-87916b1b2a62/analyzers/755d249e-2995-4bdc-a96e-743120d21159/json?outputJSON=basic"\
 -H "Authorization: ZenApiKey Y2VhZG1pbjpKSFRhOUJMWVpRWWIyV0tBRnh5Y2RvdmVJS01IRTlTcDlrQlZUR0dB"

    • Delete document
    Endpoint: /v1/projects/<project_id>/analyzers
      • It’s DELETE request. Use for delete a document.
      • Sample with curl command:
    curl -k -X DELETE "https://cpd-aria-dev.apps.skinned.cp.fyre.ibm.com/adp/aca/v1/projects/ce3ac100-dc7e-4ee2-889e-87916b1b2a62/analyzers/755d249e-2995-4bdc-a96e-743120d21159"\
     -H "Authorization: ZenApiKey Y2VhZG1pbjpKSFRhOUJMWVpRWWIyV0tBRnh5Y2RvdmVJS01IRTlTcDlrQlZUR0dB"

    Guide for ADP API:
    https://www.ibm.com/docs/en/cloud-paks/cp-biz-automation/21.0.3?topic=integrations-automation-document-processing-api


    #AutomationDocumentProcessing
    0 comments
    59 views

    Permalink