# CJK Invoice & Receipt OCR to JSON (`robertwang/cjk-document-extractor`) Actor

Invoice OCR and receipt parser for Chinese & Japanese documents: Taiwan e-invoice (統一發票), Japanese invoice (請求書), receipts and quotes from PDF or photo to validated JSON with per-field confidence. Custom fields, no data retention.

- **URL**: https://apify.com/robertwang/cjk-document-extractor.md
- **Developed by:** [Robert Wang](https://apify.com/robertwang) (community)
- **Categories:** AI, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 document extracteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CJK Invoice & Receipt OCR to JSON

**Invoice OCR, receipt parser and document-to-JSON extractor built for Chinese and Japanese business documents.** Upload a PDF, scan or phone photo of a Taiwan e-invoice (統一發票 / 電子發票), a Japanese qualified invoice (請求書 / 適格請求書 / インボイス), a receipt (收據 / 領収書) or a quotation (報價單 / 見積書) and get clean, validated JSON back.

### Why use it

- **Chinese / Japanese OCR that understands the document**: Traditional Chinese, Japanese and English text, including scans and phone photos (deskew + upscaling).
- **Built-in templates**: Taiwan e-invoice, Japanese invoice, receipt, quotation. Or **define your own fields** with a JSON Schema or a simple field list such as `{"seller": "string", "issueDate": "date", "items": ["string"]}`.
- **Validation you can trust**: qty × unit price = amount, items sum to subtotal, subtotal + tax = total, Taiwan 5% VAT, Japanese 10% / 8% consumption tax, Taiwan 統一編號 checksum, Japanese registration number (T + 13 digits) checksum. Dates are normalised to ISO (民國 and 令和 years converted).
- **Per-field confidence** and a `needsReview` list so a human checks only what is uncertain.
- **Smart model fallback**: a fast vision LLM reads the document; when validation fails, a field is missing or confidence is low, a stronger model is tried automatically and the better result is kept. `modelUsed` and `escalationReason` tell you what happened.
- **Works without an API key** for built-in templates (OCR + rules engine). Optionally bring your own Gemini key.
- **No data retention**: files are processed in memory, never logged; uploaded inputs can be deleted after the run.

### Quick start

Click **Start** with empty input to run a free demo on two synthetic invoices. Then add your own files:

```json
{
  "fileUrls": ["https://example.com/invoice.pdf"],
  "template": "auto"
}
```

Supported files: PDF (text or scanned), PNG, JPEG, TIFF, WEBP.

### Output

One dataset item per document:

```json
{
  "source": "https://example.com/invoice.pdf",
  "template": "tw_einvoice",
  "engine": "llm+rules",
  "modelUsed": "gemini-flash-lite-latest",
  "data": {"invoiceNumber": "AB-12345678", "date": "2026-10-15", "sellerTaxId": "...", "totalAmount": 1575, "lineItems": [ ... ]},
  "confidence": {"invoiceNumber": 0.99, "totalAmount": 0.99},
  "overallConfidence": 0.99,
  "validation": {"passed": true, "checks": [ ... ]},
  "needsReview": [],
  "missingFields": []
}
```

### Use cases

Accounts-payable automation, expense and receipt scanning, bookkeeping imports, procurement (quotation comparison), RAG / data pipelines that need structured data from Chinese or Japanese PDFs.

### Tips

- For messy phone photos and custom schemas, the LLM engine gives the best accuracy.
- Check `needsReview` and `validation.passed` before posting data to your accounting system.

### Keywords

invoice OCR, receipt parser, document to JSON, Chinese OCR, Japanese OCR, Taiwan e-invoice, 統一發票, Japanese invoice, 請求書, インボイス, 領収書, 見積書, PDF to JSON, AI document extraction

# Actor input Schema

## `fileUrls` (type: `array`):

Public URLs of documents to extract. Leave empty (and no uploads) to run a free built-in demo on two synthetic invoices.

## `uploadStore` (type: `string`):

Optional. Store holding uploaded files (default: run's store)

## `uploadKeys` (type: `array`):

Record keys of uploaded files

## `template` (type: `string`):

Built-in templates work offline (rules) and better with an LLM; custom requires an LLM key

## `customSchema` (type: `object`):

Used when template=custom. Object schema with properties; descriptions help the model

## `engine` (type: `string`):

auto = vision LLM if a key is available (cross-checked with rules), else rules only

## `llmProvider` (type: `string`):

openai = any OpenAI-compatible endpoint (set base URL)

## `llmApiKey` (type: `string`):

Bring your own key (e.g. free Gemini key from aistudio.google.com/apikey). Sent only to the provider, never stored or logged

## `llmModel` (type: `string`):

Default gemini-flash-lite-latest (falls back to gemini-flash-latest) / gpt-4o-mini

## `llmBaseUrl` (type: `string`):

For OpenAI-compatible providers

## `ocrLanguages` (type: `string`):

Tesseract languages, e.g. chi_tra+jpn+eng

## `forceOcr` (type: `boolean`):

OCR even if the PDF has a text layer

## `maxPages` (type: `integer`):

Pages beyond this are ignored

## `deleteUploadsAfter` (type: `boolean`):

Remove uploaded records from the key-value store when done

## Actor input object example

```json
{
  "template": "auto",
  "engine": "auto",
  "llmProvider": "gemini",
  "ocrLanguages": "chi_tra+jpn+eng",
  "forceOcr": false,
  "maxPages": 10,
  "deleteUploadsAfter": true
}
```

# Actor output Schema

## `documents` (type: `string`):

One dataset item per document: data, confidence, validation, needsReview.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("robertwang/cjk-document-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("robertwang/cjk-document-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call robertwang/cjk-document-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,robertwang/cjk-document-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/8xyuHgumncsrSB2Dp/builds/hFNSuhtwKSdacSy1Q/openapi.json
