Python for Exporting Data from Rossum API
This Python code shows how to download XML data captured in a given Rossum queue for the previous calendar day.
This Python code shows how to download XML data captured in a given queue for the previous calendar day – as part of the regular export routine. Update the parameters at the beginning based on your scenario.
The export API is more powerful - you can filter by different criteria or download the data e.g. as a JSON instead - see the full docs.
#!/usr/bin/env python3
#
# Prints all the data mined by Rossum and validated and exported by a controlee from the previous day in the given
# queue. The format is XML and the number of documents is limited to 100.
#
# Usage: export_rossum.py
import datetime
from rossum.lib.api_client import RossumClient
queue_id = 28984
username = "your1_username"
password = "your_password"
endpoint = "https://example.rossum.app/api/v1"
with RossumClient(context=None, user=username, password=password, url=endpoint) as client:
date_today = datetime.date.today()
date_end = date_today
date_start = date_today - datetime.timedelta(days=1)
response = client.get(
f"queues/{queue_id}/export?format=xml&"
f"exported_at_after={date_start.isoformat()}&"
f"exported_at_before={date_end.isoformat()}&"
f"ordering=exported_at&"
f"page_size=100&page=1"
)
if not response.ok:
raise ValueError(f"Failed to export: {response.status_code}")
print(response.content)
This example will export at most 100 documents. To export more documents, you need to modify the code download multiple pages one by one, until it reaches the page count (or it can simply stop when an empty set of results is finally downloaded).
Updated 12 months ago
What’s Next