Install the package
Install from PyPI. You need Python 3.12 or newer,uv, version 0.18.18 or newer of the SDK, and a Transform API key.
The shell examples use zsh. Run these commands from your project directory:
Set your API key
Export your key in the zsh session where you will run the script. Replace the placeholder with your key:Parse a document synchronously
A synchronous call waits for processing to finish and returns the result in the same request. Multi-page documents can take about a minute or longer. That wait is expected. Save the code asparse.py and put document.pdf in the same project directory.
To try the example without your own file, download the ACME Corp Annual Report sample PDF and save it as document.pdf in your project directory.
markdown. Markdown is the default output; no output or profile options are required.
If you omit api_key, the client reads UNSTRUCTURED_API_KEY from the environment.
The client defaults to https://transform.unstructured.io. Pass server_url only when you target a different deployment.
If you omit wait_seconds, the call waits for the result in the original request. Client and network timeouts can still interrupt the request.
Extract fields next
To extract structured fields, follow Chain Parse and Extract. That guide defines a schema and reuses a completed Parse ID.Handle long-running requests
Asynchronous processing lets the server continue working after the submission returns. You retrieve the result in a later request. This is separate from Python’sasync/await: the client methods below are ordinary synchronous Python calls.
The SDK sends
wait_seconds as the HTTP Prefer: wait=N header. The server can cap the requested duration. See wait behavior and request progress for HTTP 200, HTTP 202, and timeout handling.
Retrieve an asynchronous Parse
Set your API key as shown above and save your document asdocument.pdf. Save this complete example as parse_async.py and run .venv/bin/python parse_async.py from the project directory. It submits the document and polls until processing finishes:
output="elements", pass that option on retrieval too and read job.result.elements after success.
Poll an accepted extraction
Use the SDK version installed above. Replaceyour-completed-parse-id with a completed Parse ID. The example schema requests an invoice number; adapt it using the schema guide.
job.result.extracted_data.
Iterate over jobs
iterate follows cursors and yields individual jobs. Use jobs.list() when you need one page at a time.
Configure retries
Addretries when creating your client:
retries=None to disable retries. The client uses backoff for eligible transient failures. A submission that might already have created a job is not retried after a read timeout or server response, to avoid duplicate jobs.
See Chain Parse and Extract for a complete sequence that passes the Parse ID into Extract.
