Ruby for Exporting Data from Rossum API

This Ruby code shows how to download XML data captured in a given Rossum queue for the previous calendar day.

This Ruby 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.

require 'date'
require 'faraday'
require 'json'
require 'nokogiri'

def authorize(username, password)
  response =
  {"username": username, "password": password}.to_json,
  {'Content-Type': 'application/json'})
  auth_token = JSON.parse(response.body)['key']
  return auth_token

def export(queue_id, date_start, date_end, auth_token)
  export_url = "{queue_id}/export?format=xml&exported_at_after=#{date_start}&exported_at_before=#{date_end}&page_size=100&page=1"
  response = Faraday.get(export_url) do |req|
      req.headers['Authorization'] = "token #{auth_token}"
  return Nokogiri::XML(response.body)

username = "[email protected]"
password = "some.secret.password"
queue_id = 12345
today =
date_start = today.strftime("%Y-%m-%d")
date_end = today.prev_day.strftime("%Y-%m-%d")
auth_token = authorize(username, password)
documents = export(queue_id, date_start, date_end, auth_token)

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).