Call DocuOCR from JavaScript with the built-in fetch: POST a PDF or image, start extraction, and read structured JSON back with named fields, tables and confidence scores. No OCR engine to bundle, no npm SDK to wire.
The same endpoint reads digital and scanned PDFs, so one code path handles both. Copy the Node.js below and run it against your own document. Last updated July 2026.
Upload a document to extract
Drop files here or click to upload
Up to 50 files
Uploading...
See the JSON your fetch call would receive, right in the browser.
To use an OCR API in JavaScript, you send a document to an HTTPS endpoint and read the recognized data back as JSON, all through the fetch that ships with Node.js 18 and up and every browser. There is no OCR engine to bundle, no model to train, and with a REST API like DocuOCR no npm SDK to add. You authenticate with a Bearer API key, POST the file as FormData to get a file_id, start an extraction job, then poll or receive a webhook for the result. Because the response is JSON, await response.json() turns it into a plain object of named fields, table rows and confidence scores you can drop straight into a database, a spreadsheet export or an accounting workflow. The same three calls work for a native PDF, a scanned PDF or a photo, so your code does not branch on how the document was made.
Three fetch calls, from a file on disk to structured JSON. Runs on Node 18+ with no dependencies. Swap in your API key from the dashboard and point it at any PDF or image.
import { readFile } from "node:fs/promises";
const API_KEY = "YOUR_API_KEY";
const BASE = "https://docuocr.com/api/documents";
const auth = { Authorization: `Bearer ${API_KEY}` };
// 1. Upload the PDF or image, get a file_id
const form = new FormData();
form.append("file", new Blob([await readFile("invoice.pdf")]), "invoice.pdf");
const up = await fetch(`${BASE}/upload`, { method: "POST", headers: auth, body: form });
const { file_id } = await up.json();
// 2. Start extraction, get a job hash
const job = await fetch(`${BASE}/extract`, {
method: "POST",
headers: { ...auth, "Content-Type": "application/json" },
body: JSON.stringify({ file_id }),
});
const { extraction_hash } = await job.json();
// 3. Poll until the JSON is ready
let res;
do {
await new Promise(r => setTimeout(r, 2000));
res = await (await fetch(`${BASE}/extraction/${extraction_hash}`, { headers: auth })).json();
} while (res.status !== "completed");
// res.fields and res.tables are ready to use
for (const field of res.fields) {
console.log(field.name, field.value, field.confidence);
}
That is the whole integration. For a production batch, wrap each call in try or catch, add exponential backoff on HTTP 429, and register a webhook instead of the polling loop so results arrive as each document finishes. The document OCR API reference covers the full request and response shape. Prefer Python? The same flow in the OCR API Python guide uses requests.
The cloud providers ship an npm SDK; a REST API needs only the built-in fetch. What you get back differs more than the language does. Package names verified July 2026.
| OCR API | npm package | What it returns | Best for |
|---|---|---|---|
| DocuOCR | fetch (built into Node 18+, no SDK) | Named fields, tables and confidence as JSON | Fields plus tables from one call, scans included |
| Google Cloud Vision | @google-cloud/vision | Text and bounding boxes, no named fields | Raw text OCR on the Google stack |
| Google Document AI | @google-cloud/documentai | Text plus entities, needs a service account | Google-native document pipelines |
| AWS Textract | @aws-sdk/client-textract | Text, forms and tables as blocks | AWS-stack teams already on the v3 SDK |
| Azure AI Document Intelligence | @azure-rest/ai-document-intelligence | Text, layout and prebuilt-model fields | Azure-stack, prebuilt invoice or receipt models |
| Mistral Document AI | @mistralai/mistralai | Markdown plus structured output | LLM-based parsing of mixed content |
| Tesseract (tesseract.js) | tesseract.js (WASM, browser + Node) | Plain text only, runs client-side | Free, low-volume, offline or in-browser |
The split that matters: raw OCR APIs like Google Cloud Vision and tesseract.js return text and coordinates, so you write the field mapping in JavaScript yourself. A document extraction API returns named fields and table rows already, which is most of the code you would otherwise maintain. See the full OCR API pricing comparison for what each costs per 1,000 pages.
Generate a key in the dashboard and send it as a Bearer token in the Authorization header.
POST a PDF, PNG, JPG, TIFF or WEBP as FormData and read the file_id from the JSON.
POST the file_id to start an async job and get an extraction_hash back.
Poll or receive a webhook, then await response.json() gives you fields, tables and confidence.
A background worker posts each incoming file, reads the JSON, and writes fields to a database with no manual entry.
A web app lets users drop a PDF, forwards it server-side to the OCR API, and returns clean fields to the front end.
A script pulls invoices from an inbox or bucket, extracts totals and line items, and posts them to QuickBooks or an ERP.
A data service turns scanned statements and reports into rows and columns for export to Excel, CSV or a warehouse.
A Lambda or edge function reads a document on upload and returns structured JSON without hosting an OCR engine.
A verification flow reads IDs and forms, checks confidence scores, and routes low-confidence values to a human.
The full endpoint reference and response shape.
The same three calls from Python with requests.
Call the API from Java with the built-in HttpClient.
An honest roundup of OCR APIs for US teams.
Pull tables from PDFs to Excel, CSV or JSON.
Per-1,000-page rates across the market.
Generate an API key, paste the three fetch calls above, and read structured JSON back in minutes. No engine to bundle, no SDK to learn, and a free tier to test the integration before you pay per page.