Understanding the Features of KlearStack API

Understanding the Features of KlearStack API

Application Programming Interfaces (API) have been of utmost importance over the past two decades or so for developers. APIs have given the freedom to developers to create applications no one can imagine and connect the application seamlessly on various devices.  

 API has provided flexibility to integrate one software with another by using parts of the software’s code. This provides developers to use the best of all worlds and create applications that are beneficial not only to end-users but also to enterprises. Enterprises do not need to create entire applications from scratch and therefore, APIs help companies reduce their overall development costs of software. 

APIs have been an integral part of the process of digitization of documents. Be it data extraction or complete end-to-end document automation, APIs have been created in such a way that enterprises can feel free to use them as per their document and data organization needs.  

KlearStack AI is a platform that helps in data extraction from unstructured documents with ease. It extracts unstructured data and by leveraging artificial intelligence, it structures the data and the documents.  Following are the API endpoints that can be integrated with your software. These API features are for the latest version of KlearStack, v 7.5.1. Please note that only the most important API modules are covered. To view the entire API documentation, click here. 

User Registration 

The user registration endpoint is used to register a user in the database.

Method URL
POST URL/access/klearstack/register

Request Body Parameters:

  • Username, password, company name, user role are mandatory parameters for registration.
  • Processing preference is another mandatory parameter. It helps to choose between speed or accuracy while registering a user.
  • Password expiration is an optional parameter. By default it is set for 90 days, however, days are configurable. You can choose “None” if no expiration date needs to be set for the password.

API Response:

Status code  Response 
200  If all details are filled in, the user is successfully registered or the user already exists. 
500  If details are missing while registration, an error will pop up with the missing field highlighted, eg: error “Company Name” 

User Authentication 

User authentication is the login endpoint for the user. 

Method  URL 
POST  URL/access/klearstack/login 

Request Body Parameters:

Username, password, and company name are mandatory parameters for user authentication. 

API Response:

Status code  Example Response 
200  { 

    “Result”: [ 

        { 

            “username”: “example”, 

            “company_name”: “example”, 

            “role”: “example”, 

            “is_blocked”: 0, 

            “processing_pref”: “speed”, 

            “document_type”: “{\”document_type\”: \”invoices\”}”, 

            “_id”: 1 

        } 

    ] 

} 

 

500  If details are missing while registration, an error will pop up with the missing field highlighted, eg: error “Company Name” 

Generating Access Token 

Access token endpoint is used to provide an access token as well as refresh the token. The validity of the access token will be valid for a few minutes and the new token will be made available in a few days. 

Method  URL 
POST  URL/access/klearstack/get_access_token 

 Request Body Parameters:

Username, password and company name are required to get access token. 

API Response:

Status code  Example Response 
200  { 

    “refresh_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY1NjU3NjA5OCwiaWF0IjoxNjU2NTcdGkiOiI1ZmEzNGM4YjUyOGI0OWM3OWQzNjk5ZWJlNDRlYzUwZiIsInVzZXJfaWQiOjI2fQ.kvpMWPuxenw2c55nucfQCxHLipiO4DhK2TC5NKpJZEk”, 

    “access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjU2NTc2MDM4LCJpYTY1NzU5MTgsImp0aSI6IjQwMWZlYmJhODg4NDQ1MmRhN2Q3ZTA5ZjEwZmYwOWFkIiwidXNlcl9pZCI6MjZ9.sjU6iVbRRp7dTDt-l4rj7K7tKpPpaL7yskjstAUn2Zs” 

} 

 

500  If details are missing while registration, an error will pop up with the missing field highlighted, eg: error “Company Name” 

Uploading a Single Invoice 

This API is used to generate the batch id for a single invoice, either an image or a PDF, that is uploaded by the user.  

Method  URL 
POST  URL/access/klearstack/uploadinvoice 

 Request Body Parameters:

  • Company name, username, and password are required while uploading the single invoice. 
  • The document is required to be uploaded. PDF, JPEG and PNG formats are supported. 
  • A processing preference field needs to be added. Speed and Accuracy are two options added in this field type. 
  • The document type field needs to be added as well. Options in this field are Invoices, Receipts and Purchase Orders.  
  • An invoice type field is required as well. B2B (business-to-business) and B2C (business-to-consumer) are two options in this field. 

 API Response:

Status  Example Response 
200  { 

 

“Function successfully executed!”: “169a4df0-52c4-4835-8bb4-10296c8e5e3a” 

 

} 

400  If the username is not entered, error will pop-up “Please provide username” 
400  If the password is not entered, error will pop-up “Please provide password” 

Uploading Multiple Invoices 

This API is used to generate a single batch id for all the invoices uploaded in the form of a zip folder by the user.  

Method  URL 
POST  URL/access/klearstack/uploadbatch 

 Request Body Parameters:

  • Company name, username, and password are required while uploading the single invoice. 
  • The document is required to be uploaded. ZIP folders containing images or PDF formats are supported. 
  • A processing preference field needs to be added. Speed and Accuracy are two options added in this field type. 
  • The document type field needs to be added as well. Options in this field are Invoices, Receipts and Purchase Orders.  
  • An invoice type field is required as well. B2B (business-to-business) and B2C (business-to-consumer) are two options in this field. 

 API Response: 

Status  Example Response 
200  { 

 

“Function successfully executed!”: “169a4df0-52c4-4835-8bb4-10296c8e5e3a” 

 

} 

400  If the username is not entered, error will pop-up “Please provide username” 
400  If the password is not entered, error will pop-up “Please provide password” 
401  If the password is entered is incorrect, error will pop-up “Incorrect username or password.” 
500  If an unknown error has occurred, pop-up message will appear “Something went wrong. Please try again later.” 

Results of Approved Invoices 

This API is used to generate results of invoices that are approved by the concerned authority of a company using a date range filter, query by example (QBE) status filter and username list. 

Method  URL 
POST  URL/access/klearstack/getapproveinvoices 

 Request Body Parameters:

  • Company name, username, and password are required while uploading the single invoice. 
  • The document type field needs to be added as well. Options in this field are Invoices, Receipts and Purchase Orders. By default, the invoice option is chosen. 
  • From and to date are required parameters to get a list of approved invoices. The date is required in DD/MM/YYYY format. 
  • The name of users of whose invoices are required is an optional parameter. By default, all users are considered.  
  • QBE status parameter is also added. Success or Failed are only two values considered for this parameter. 

 API Response:

Status  Example Response 
200  { 

    “result”: [ 

        { 

            “Document_id”: “5e9ebf7c1ed959c4bb4dc214”, 

            “is_approved”: 0, 

           “approved_date”: “Wed Apr 14 2021”, 

            “file_name”: “tata capital west bengal 5712.pdf”, 

            “overall_confidence”: 0.917829326729445, 

           “AccountsData”: { 

                “Supplier GL Account #”: “1200021”, 

                “Supplier ID”: 1001, 

                “Supplier name”: “Tatiana Henderson LLP”, 

                “CGST”: “450002, Central Input GST”, 

                “SGST”: “450001, State Input GST”, 

                “IGST”: “420003, Inter State Input GST”, 

                “PurchaseAc”: “980001, Printing & Stationery”, 

                “SplitFlag”: “false”, 

                “LineItemAccounts”: [ 

                    “LineItem1, 980001, Printing & Stationery, 49,357.00” 

                ], 

                “SplitAccounts”: [], 

                “individualQuickBookAc”: [], 

                “individualQbItemType”: [], 

                “sgstv”: “”, 

                “cgstv”: “”, 

                “igstv”: “8,884.26”, 

                “qbItemName”: “”, 

                “qbItemType”: “” 

            }, 

            “Inv_Date”: { 

                “value”: “23 February, 2020”, 

                “confidence”: 0.566981644843936, 

                “page_index”: 1 

            }, 

            “Inv_Number”: { 

                “value”: “MATTB-2331”, 

                “confidence”: 0.946715178008698, 

                “page_index”: 1, 

                “coordinate”: [ 

                    1283, 

                    383, 

                    1409, 

                    409 

                ] 

            }, 

            “Inv_PO”: { 

                “value”: “P6060”, 

                “confidence”: 0.998517162654257, 

                “page_index”: 1, 

                “coordinate”: [ 

                    1287, 

                    443, 

                    1349, 

                    468 

                ] 

            }, 

            “Inv_Total”: { 

                “value”: “30199”, 

                “confidence”: 0.970878755401809, 

                “page_index”: 1, 

                “coordinate”: [ 

                    0, 

                    0, 

                    0, 

                    0 

                ] 

            }, 

            “Inv_CGST_Value”: { 

                “value”: “1661”, 

                “confidence”: 0.822383355941637, 

                “page_index”: 1 

            }, 

            “Inv_SGST_Value”: { 

                “value”: “1661”, 

                “confidence”: 0.881396053757078, 

                “page_index”: 1 

            }, 

            “Inv_CGST_Percent”: { 

                “value”: “5”, 

                “confidence”: 0.827240639155472, 

                “page_index”: 1 

            }, 

            “Inv_SGST_Percent”: { 

                “value”: “5”, 

                “confidence”: 0.823984961348311, 

                “page_index”: 1 

            }, 

            “Inv_Supplier”: { 

                “value”: “Pai International Electronics Ltd”, 

                “page_index”: 1, 

                “coordinate”: [ 

                    0, 

                    0, 

                    0, 

                    0 

                ], 

                “confidence”: 0.805663607700772 

            }, 

            “Inv_Customer”: { 

                “value”: “Pai, INTERNATIONAL,”, 

                “page_index”: 1, 

                “coordinate”: [ 

                    406, 

                    58, 

                    795, 

                    105 

                ], 

                “confidence”: 0.954218689055312 

            }, 

            “Inv_Type”: { 

                “value”: “Tax Invoice”, 

                “confidence”: 0.981186005027941, 

                “page_index”: 1 

            }, 

            “Inv_Currency”: { 

                “value”: “INR”, 

                “confidence”: 0.978, 

                “page_index”: 1 

            }, 

            “Inv_Origin”: { 

                “value”: “India”, 

                “confidence”: 0.978, 

                “page_index”: 1 

            }, 

            “Inv_Supplier_Address”: { 

                “value”: “GST INVOICE , PAI INTERNATIONAL ELECTRONICS LTD. , Corporate Office: # 28/1A, 100 Feet Road, Indiranagar, Bangalore-560 – 560038.”, 

                “page_index”: 1, 

                “coordinate”: [ 

                    406, 

                    3, 

                    1179, 

                    157 

                ], 

                “confidence”: 0.962132237592736 

            }, 

            “Inv_Supplier_State”: { 

                “value”: “Karnataka”, 

                “confidence”: 0.95, 

                “page_index”: 1 

            }, 

            “Inv_Supplier_City”: { 

                “value”: “Bengaluru”, 

                “confidence”: 0.981349645091967, 

                “page_index”: 1 

            }, 

            “Inv_Supplier_Pincode”: { 

                “value”: “560038”, 

                “confidence”: 0.981349645091967, 

                “page_index”: 1 

            }, 

           “line_items”: [ 

                { 

                    “row”: { 

                        “Description”: “Dell Latitude 3400 C15 Intel Core I5 8265 U 8 Gb Ddr4 /512 Gb Ssd 14” Screen(1366×768) Intel Uhd Graphic 620 10/100/1000 Ehernate Port Window 10 Pro With Bag Pack”, 

                        “of Goods”: “”, 

                        “HSN Code”: “8471”, 

                        “Quantity”: “1 NOS”, 

                        “Rate”: “49,357.00”, 

                        “per”: “NOS”, 

                        “Line_Item_Total”: “49,357.00” 

                    }, 

                    “page_index”: 1, 

                    “coordinate”: [ 

                        95, 

                        776, 

                        1343, 

                        892 

                    ] 

                }, 

                { 

                    “row”: { 

                        “Description”: “3 year warranty Output IGST 18%”, 

                        “HSN Code”: “”, 

                        “Quantity”: “”, 

                        “Rate”: “18”, 

                        “per”: “%”, 

                        “Line_Item_Total”: “8,884.26” 

                    }, 

                    “page_index”: 2, 

                    “coordinate”: [ 

                        92, 

                        777, 

                        1325, 

                        812 

                    ] 

                } 

            ], 

            “data_items”: [ 

                { 

                    “row”: { 

                        “Description”: “APPLE IPHONE732GB 7 BLACK”, 

                        “serial_number”: “MOBIP63”, 

                        “imei_number”: “356642080262057”, 

                        “Line_Item_Total”: “29900” 

                    }, 

                    “page_index”: 1, 

                    “coordinate”: [ 

                        153, 

                        593, 

                        342, 

                        657 

                    ], 

                    “confidence”: 0.973677977720621 

                }, 

                { 

                    “row”: { 

                        “Description”: “2 2 BOAT NECKLACE STYLE IN EAR SPORTS BT HEADSET ROCKERZ 255RBL”, 

                        “serial_number”: “8904130843761/5314”, 

                        “imei_number”: “”, 

                        “Line_Item_Total”: “1899” 

                    }, 

                    “page_index”: 1, 

                    “coordinate”: [ 

                        152, 

                        754, 

                        374, 

                        781 

                    ], 

                    “confidence”: 0.973677977720621 

                }, 

                { 

                    “row”: { 

                        “Description”: “3 3 MOBILE CARRY BAG (PAPER)”, 

                        “serial_number”: “BAG04”, 

                        “imei_number”: “”, 

                        “Line_Item_Total”: “” 

                    }, 

                    “page_index”: 1, 

                    “coordinate”: [ 

                        152, 

                        835, 

                        224, 

                        859 

                    ], 

                    “confidence”: 0.973677977720621 

                } 

            ] 

        } 

    ], 

    “status”: “complete” 

} 

400  If the username is not entered, error will pop-up “Please provide username” 
400  If the password is not entered, error will pop-up “Please provide password” 
401  If the password is entered is incorrect, error will pop-up “Incorrect username or password.” 
500  If an unknown error has occurred, pop-up message will appear “Something went wrong. Please try again later.” 

Updated Results of Approved Invoices  

his API is used to generate updated results of invoices that are approved by the concerned authority of a company using a date range filter, query by example (QBE) status filter and username list.  

Method  URL 
POST  URL/access/klearstack/updateqbestatus 

 Request Body Parameters:

  • Company name, username, and password are required while uploading the single invoice. 
  • The document type field needs to be added as well. Options in this field are Invoices, Receipts and Purchase Orders. By default, the invoice option is chosen. 
  • QBE response parameter is a response of QuickBooks to a particular invoice. 

 API Response: 

Status  Example Response 
200  “QBE status updated successfully” 

 

200  if document id is not found. 

“Document ID not found” 

KlearStack: Revolutionizing Document Automation 

KlearStack API and web platform enable enterprises to extract, structure and automate the entire documentation process. The need for manual intervention is eliminated or reduced significantly if KlearStack is implemented at your enterprise. This makes KlearStack a leading document automation platform and we are bringing a paradigm shift for enterprises regarding document automation solutions. To know more about KlearStack AI API, click here to get in touch with our experts.  

Ashutosh Saitwal
Ashutosh Saitwal
www.klearstack.com/

Ashutosh is the founder and director of the award winning KlearStack AI platform. You can catch him speaking at NASSCOM events around the world where he speaks and is an evangelist for RPA, AI, Machine Learning and Intelligent Document Processing.