Tutorial: Calling DocParse Asynchronously
See how you can call DocParse asynchronously
The following functions can be used together to send files to DocParse to partition asynchronously:
partition_file_async_submit
- function that makes a request to partition the file and returns a task_id that you can use to keep track of your request to partition the file
partition_file_async_result
- function that you can call to get the result of the partition_file task you just sent. It will return a dict that indicates a status (“done”
or “pending”
)
Here’s an example of how you can process multiple files at the same time:
It is important to note that sending multiple asynchronous partitioning tasks at the same time does not guarantee that they will run simultaneously.
Using a webHook
Optionally, you can also set a webhook for Aryn’s services to call when your task is completed:
Aryn will POST a request containing a body like the below to the webhook URL:
If you want to list all the asynchronous partition_file tasks that are running and not yet completed in your account, you can call the following function:
If you want to cancel a particular asynchronous partition_file task you can call the following function:
Using cURL
You can also call the async APIs directly without python through cURL:
You can poll your result with the command below. Use the call id the command returned as output.
To list pending tasks use the command below:
You can cancel a pending task with the command below:
Was this page helpful?