Local document OCR
Documents stay on your Node.js server. Only installation metadata travels to Sandbee for license checks.
1. Enable and install
Enable Document OCR in Store and create an OCR or global API key. After the npm release is published, install @sandbee/ocr. Until then, use the versioned package download from Store.
npm install ./sandbee-ocr-0.1.0.tgz2. Configure once
Save an OCR key or global key in SANDBEE_OCR_TOKEN. Generate a persistent UUID once as SANDBEE_INSTALLATION_ID. Download and pin sandbee-public.pem from your authenticated console.
node -e "console.log(require('node:crypto').randomUUID())"3. Verify at server startup
const { SandbeeOCR } = require('@sandbee/ocr');
const fs = require('node:fs');
const path = require('node:path');
const ocr = new SandbeeOCR({
token: process.env.SANDBEE_OCR_TOKEN,
installationId: process.env.SANDBEE_INSTALLATION_ID,
label: 'Production document service',
issuer: 'https://ocrapi.sandbee.in',
publicKey: fs.readFileSync('./sandbee-public.pem', 'utf8'),
});
async function startServer() {
await ocr.start(); // Verify before accepting OCR work.
// Start your HTTP server and reuse this client.
}
async function readDocument(filePath) {
return ocr.extract({ documentType: 'PAN', files: [path.resolve(filePath)] });
}
// Call ocr.close() during graceful shutdown.
startServer().catch(error => { console.error(error.code); process.exitCode = 1; });Automatic renewal
The client renews in the background every 45 seconds. Signed leases last 60 seconds. Revoke or disable stops new work within that window; already admitted jobs may finish. Network failure never extends an expired lease.
Supported environment
- Node.js 22+, Windows x64 or Linux x64 with glibc.
- No Alpine, ARM/Graviton, macOS or browser runtime in this build.
- PAN, Aadhaar, Voter ID, Driving License, Ration Card and Passport.
- One or two local files, 10 MB each; first three PDF pages.
- Review field flags and conflicts. OCR does not verify authenticity.
The hosted demo uploads files to the private Store demo worker. The package does not upload documents or extracted text. Customer-controlled code cannot provide tamper-proof licensing or independently verified remote extraction counts.
Ready to build?
Your apps, keys and setup in one workspace.