Install the package
Install from npm. You need Node 22 or newer, npm, version 0.18.19 or newer of the SDK, and a Transform API key. Run this command from your project directory:Set your API key
In zsh, export your key before running a script:Parse a document synchronously
SetUNSTRUCTURED_API_KEY to your API key and save your input as document.pdf. Use Node 22 or newer.
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.
Save this example as parse.mjs. These examples use JavaScript syntax with the TypeScript SDK, so Node can run them directly.
node parse.mjs from the project directory in the shell where you exported your key.
The call waits for processing to finish and prints the returned response. A completed Parse contains Markdown by default; no output options are required.
If you omit apiKey, the TypeScript SDK reads UNSTRUCTURED_API_KEY from the environment.
The client defaults to https://transform.unstructured.io. Pass serverUrl only when you target a different deployment.
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
If you omitwaitSeconds, the call waits for the result in the original request. Set waitSeconds to request a bounded wait, or use zero to return a pending job without waiting. See wait behavior and request progress for HTTP 200, HTTP 202, and timeout handling.
Retrieve an asynchronous Parse
SetwaitSeconds: 0 on client.parse.run to receive a pending job handle. Server-side asynchronous processing is separate from JavaScript promises: await waits for that response, not for the document to finish processing.
Save this complete example as parse-async.mjs and run node parse-async.mjs with your API key set and document.pdf in the project directory:
output: "elements", pass it to jobs.get too and read job.result.elements after success.
Poll an accepted extraction
Use the current Transform SDK release. Replaceyour-completed-parse-id with a completed Parse ID. The example schema requests an invoice number; adapt it using the schema guide.
job.result.extractedData.
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: false 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.
