Skip to main content

Asynchronous

For ease of use we recommend using the sync requests. However, if you have large documents or if you want to avoid timeouts, you can use asynchronous requests.

Setting up Asynchronous Requests​

To use asynchronous requests, set the asynchronous parameter to True in the payload:

{
"analyse_type": ["risk"],
"asynchronous": true
}

Retrieving Results​

After the document is submitted for analysis, a verification token will be returned in the response. This token can be used to retrieve the analysis results later.

The results are available at the following endpoint:

note

The results are available after the document has been processed, and are deleted after 60 minutes.

Example​

warning

If the response is not ready to be retrieved, you will receive an error message. We recommend fetching the results every 30 seconds until you receive a successful response.

import requests
import json
import time

# Configuration
API_KEY = "YOUR_API_KEY_HERE"
FILE_PATH = "sample.pdf"

# Step 1: Submit document for async analysis
url_analyse = "https://api-v2.finovox.com/analyse"
headers = {"api-key": API_KEY}

payload = {
"analyse_type": ["risk"],
"asynchronous": True # Enable async mode
}

with open(FILE_PATH, "rb") as f:
files = [("file", ("sample.pdf", f.read()))]
data = {"payload": json.dumps(payload)}
response = requests.post(url_analyse, headers=headers, files=files, data=data, timeout=150)
result = response.json()

print("Document submitted. Token:", result["retrieve_token"])

# Step 2: Poll for results every 30 seconds
url_retrieve = "https://api-v2.finovox.com/retrieve"
retrieve_data = {"retrieve_token": result["retrieve_token"]}

while True:
response = requests.post(url_retrieve, headers=headers, json=retrieve_data, timeout=150)

if response.status_code == 200:
# Analysis complete
results = response.json()
print("Analysis complete:", results)
break
else:
# Still processing, wait 30 seconds
print("Processing... checking again in 30s")
time.sleep(30)