DocuTray

Client

Configure the Docutray Node.js client — API key, base URL, timeouts, and retries — plus the typed methods for convert, identify, and knowledge-base calls.

docutray v0.1.1-rc.0npm install docutraypnpm add docutray

DocuTray

The main client class for interacting with the DocuTray API. Provides access to all API resources through typed properties.

import DocuTray from 'docutray';

// Using environment variable (DOCUTRAY_API_KEY)
const client = new DocuTray();
import DocuTray from 'docutray';

const client = new DocuTray({ apiKey: 'dt_my-api-key' });
import DocuTray from 'docutray';

const client = new DocuTray({
  apiKey: 'dt_my-api-key',
  timeout: 30_000,
  maxRetries: 3,
});

Resources

Each property on a DocuTray instance exposes a typed resource client. Resource methods return typed promises and accept request-scoped overrides.

ClientOptions

Configuration options for the DocuTray client.

ClientOptionsinterface
apiKeystring
API key for authenticating with the DocuTray API.
baseURL?string
Base URL for API requests. Defaults to https://app.docutray.com.
timeout?number
Request timeout in milliseconds. Defaults to 60000.
maxRetries?number
Maximum number of retries on transient errors. Defaults to 2.
fetch?function
Custom fetch implementation. Defaults to globalThis.fetch.

RequestOptions

Per-request options that override client-level defaults.

RequestOptionsinterface
headers?Record<string, string>
Additional HTTP headers to include in the request.
signal?object
An AbortSignal to cancel the request.
timeout?number
Request timeout in milliseconds, overriding the client default.
maxRetries?number
Maximum retries for this specific request.
query?Record<string, union>
Query string parameters appended to the request URL.

RetryConfig

Configuration for the exponential backoff retry strategy.

RetryConfiginterface
maxRetriesnumber
Maximum number of retry attempts.
initialDelaynumber
Initial delay in milliseconds before the first retry.
maxDelaynumber
Maximum delay cap in milliseconds.
exponentialBasenumber
Base for exponential backoff calculation.
jitterMinnumber
Minimum jitter factor (0–1) added to the delay.
jitterMaxnumber
Maximum jitter factor (0–1) added to the delay.

File Input Types

FileInput

Accepted file input types for document uploads: Blob | Buffer | ArrayBuffer | FileWithMetadata.

When passing a raw Blob or Buffer without a filename, DocuTray infers the MIME type from the content. For best accuracy, prefer FileWithMetadata.

FileWithMetadata

A file with explicit filename and optional content type.

FileWithMetadatainterface
contentany
The file content as a Buffer or Blob.
filenamestring
The filename, used for content type detection and the multipart upload.
contentType?string
MIME type override. Auto-detected from filename when omitted.

On this page