DocuTray

Node.js SDK

Official Node.js SDK for the DocuTray API — typed OCR conversion, document identification, data extraction, and knowledge bases for Node 20+.

The official Node.js library for the DocuTray API, providing access to document processing capabilities including OCR, document identification, data extraction, and knowledge bases.

Installation

npm install docutray

Requires Node.js 20+.

Quick Start

import DocuTray from 'docutray';
import { readFileSync } from 'fs';

const client = new DocuTray({ apiKey: 'your-api-key' });

// Convert a document
const result = await client.convert.run({
  file: readFileSync('invoice.pdf'),
  documentTypeCode: 'invoice',
});

console.log(result.data);

Async Conversion

For large documents, use async conversion with polling:

const status = await client.convert.runAsync({
  file: readFileSync('large_document.pdf'),
  documentTypeCode: 'invoice',
});

// Poll for completion
const final = await status.wait();
if (final.isSuccess()) {
  console.log(final.data);
}

Configuration

// Via constructor
const client = new DocuTray({ apiKey: 'your-api-key' });

// Via environment variable (DOCUTRAY_API_KEY)
const client = new DocuTray();

Resources

Client

The main entry point for the SDK:

  • DocuTray — Client class with resource properties

API Resources

  • Convert — Document conversion and data extraction
  • Identify — Automatic document type identification
  • DocumentTypes — Document type catalog and schema validation
  • Steps — Workflow step execution
  • KnowledgeBases — Knowledge base management and semantic search

Error Handling

  • Error Hierarchy — Comprehensive error classes with status-specific exceptions

Types

Response and model types:

On this page