Lazarus RikAI2-6.222.1100
Input (Requirement)
- orgId
- authKey
- Image File (PDF, jpeg, png, and Tiff
- Question (one or more)
Input (Optional for additional infomation)
- Questions with File (.txt) - multiple questions can be separated by new line (line feed)
- JSON
- YAML
- Encode for special charactors
Return Value
- Question and answers in a CSV format with headers [question,answer]
Return Code
- 0 Success
- 1 Invalid Org ID or Auth Key
- 2 Invalid input image file format
- 99 misc. errors
Parameter Setting samples
The new API specification
- About the new API
The new API does not return answers to questions in response.
Answers are now sent per process via webhook.
For more information, please check the following :
https://docs.lazarusforms.com/docs/rikai-2/rikai2-overview
- How to use
For information on how to use the API, check the documentation at the following URL.
https://docs.lazarusforms.com/docs/rikai-2/rikai2/operations/create-a-rikai-bulk
The following is one sample using API Requests.
Set the Headers as follows
- "orgId": "your_org_id"
- "authKey": "your_auth_key"
- "Content-Type": "application/json"
Set the JSON data file as follows(Sample)
JSON to send
{ "inputUrl": ["---your_input_url_of_the_image---"], "question": ["---question---"], "returnOCR": "True", "language": "en", "settings": { "advanced_vision": "True", "sendFile": "True" }, "metadata": {"docId": "---doc-id---"}, // Freely create in JSON format "webhook": "---your_whbhook_url---", "webhookSendFull": "True", "forceOCR": "True", "outputURL": "---your_output_url---" }
- How to receive Webhook
The next method is to set up a server in Python to receive webhooks.
A sample script for a server to receive webhooks in Python looks like this :
import http.server import socketserver import datetime import base64 import json class MyHandler(http.server.BaseHTTPRequestHandler): def do_POST(self): content_length = int(self.headers['content-length']) # Get Body now = datetime.datetime.now() req_body = self.rfile.read(content_length).decode("utf-8") json_body = json.loads(req_body) if json_body["status"] == "SUCCESS": # Processing docId doc_id = json_body["metadata"]["docId"] doc_id_dec = base64.b64decode(doc_id).decode('utf-8') pam_id = str(doc_id_dec).split('+')[0] # Create Output JSON file_name = pam_id + '_' + str(doc_id) + '_' + now.strftime('%Y%m%d%H%M%S') + '.json' with open(file_name, 'w', encoding='utf-8') as f: json.dump(json_body, f, indent=3, ensure_ascii=False) # Response self.send_response(200) self.send_header('Content-Type', 'text/plain; charset=utf-8') self.end_headers() with socketserver.TCPServer(("", 80), MyHandler) as httpd: httpd.serve_forever()
Can download it from the following link :
Here, the ”docId” is set in the ”metadata” above, and a process is built in to disassemble and process it.
The ”docId” is set to “PAMID” + “Requests sent date and time” encoded in Base64.
Running this as a server will allow you to receive webhooks.
All that remains is to set the published URL or IP address as the WebhookURL.