Skip to content

Quickstart

Extraction is asynchronous on both tiers. Submitting returns job ids and a pending status; the result arrives once the job reaches a terminal state. The clients wrap that loop for you, so nothing rides on a single long-lived HTTP request and a large file cannot trip a request timeout.

Set XBERG_BASE_URL to your deployment origin, XBERG_API_KEY to a project key, and XBERG_TARGET to pro or enterprise. Set XBERG_DOCUMENT to the path of a text document containing Xberg SDK snippet fixture, or replace the example’s content assertion with your own expected text. The repository provides this document as test_documents/snippet.txt.

Python
import os
from pathlib import Path
from xberg_io_sdk import XbergClient
with XbergClient(
api_key=os.environ["XBERG_API_KEY"],
base_url=os.environ["XBERG_BASE_URL"],
target=os.environ["XBERG_TARGET"],
) as client:
job = client.extract_and_wait(file=Path(os.environ["XBERG_DOCUMENT"]))
result = client.get_job_result(str(job.id))
if not result.results or "Xberg SDK snippet fixture" not in result.results[0].content:
raise RuntimeError("The extracted document did not contain the expected text")
print("Extraction verified")

The helper submits and polls; the example then reads the result:

  1. Submit — POST /v1/extract returns job_ids and status: "pending", with 202.
  2. Poll — GET /v1/jobs/{id} until the status is terminal (completed, partial_success, failed or cancelled).
  3. Read — GET /v1/jobs/{id}/result returns the extracted documents.

Two timeouts are in play and they are deliberately separate: a per-request timeout of 30 seconds, and a wait timeout of 5 minutes covering the whole poll loop. Polling starts at one second and can back off exponentially. Raise the wait timeout for large documents rather than the request timeout — the request is only ever a short status read.

If the job ends failed or cancelled, the wait raises rather than returning a job you would have to inspect.