# Receipt OCR API (`happitap/receipt-ocr-api`) Actor

Receipt OCR API - Multi-Model Text Extraction :
Extract structured data from receipt images using advanced OCR technology with support for multiple AI models including Google Vision, OpenAI, Azure, AWS Textract, Gemini, Hugging Face, DeepSeek, and Native OCR.

- **URL**: https://apify.com/happitap/receipt-ocr-api.md
- **Developed by:** [HappiTap](https://apify.com/happitap) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 28 total users, 2 monthly users, 100.0% runs succeeded, 7 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.01 / 1,000 results

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Receipt OCR API - Multi-Model Text Extraction

Extract structured data from receipt images using advanced OCR technology with support for multiple AI models including Google Vision, OpenAI, Azure, AWS Textract, Gemini, Hugging Face, DeepSeek, and Native OCR.

### 🌟 Features

#### Multi-Model OCR Support

Choose from 8 different OCR engines based on your needs:

- **Google Vision API** - High accuracy, excellent for printed receipts
- **DeepSeek OCR** - Advanced AI-powered text extraction
- **Amazon Textract** - Specialized for document and receipt analysis
- **Azure AI Vision** - Microsoft's computer vision service
- **OpenAI GPT-4 Vision** - State-of-the-art vision model
- **Hugging Face** - Open-source OCR models
- **Google Gemini** - Latest Google multimodal AI
- **Native (Tesseract.js)** - Free, no API key required

#### Intelligent Data Extraction

- **Merchant Information**: Name, address, contact details
- **Transaction Details**: Date, time, receipt number
- **Financial Data**: Total amount, subtotal, tax, currency
- **Line Items**: Individual items with prices
- **Payment Method**: Credit card, cash, etc.

#### Advanced Features

- ✅ **Automatic Calculation Verification** - Validates totals and tax amounts
- 📊 **Batch Processing** - Process multiple receipts simultaneously
- 🔄 **Multi-Format Support** - JPG, PNG, PDF files
- 📋 **Structured JSON Output** - Machine-readable data format
- 🎯 **High Accuracy** - Advanced parsing algorithms

### 🚀 Quick Start

#### Input Configuration

```json
{
  "ocrModel": "native",
  "receiptUrls": [
    "https://example.com/receipt1.jpg",
    "https://example.com/receipt2.png"
  ],
  "extractLineItems": true,
  "verifyCalculations": true,
  "outputFormat": "detailed"
}
```

#### Required API Keys by Model

| Model | Required Fields |
|-------|----------------|
| Google Vision | `googleVisionApiKey` |
| DeepSeek OCR | `deepseekApiKey` |
| Amazon Textract | `awsAccessKeyId`, `awsSecretAccessKey`, `awsRegion` |
| Azure AI Vision | `azureEndpoint`, `azureApiKey` |
| OpenAI | `openaiApiKey` |
| Hugging Face | `huggingfaceApiKey` |
| Gemini | `geminiApiKey` |
| Native | None (uses Tesseract.js) |

### 📋 Input Parameters

#### Required Parameters

- **ocrModel** (string) - OCR model to use
  - Options: `google-vision`, `deepseek-ocr`, `amazon-textract`, `azure-vision`, `openai`, `huggingface`, `gemini`, `native`
  - Default: `native`

- **receiptUrls** (array) - Array of receipt image URLs
  - Supports: HTTP/HTTPS URLs, data URLs, Apify key-value store URLs
  - Formats: JPG, PNG, PDF

#### Optional Parameters

- **extractLineItems** (boolean) - Extract individual line items
  - Default: `true`

- **verifyCalculations** (boolean) - Verify totals and tax calculations
  - Default: `true`

- **outputFormat** (string) - Output data format
  - Options: `json` (compact), `detailed` (with metadata)
  - Default: `detailed`

#### API Keys (Model-Specific)

Configure the appropriate API keys based on your selected OCR model. See the table above for required fields.

### 📤 Output Format

#### Detailed Output Example

```json
{
  "receiptUrl": "https://example.com/receipt.jpg",
  "ocrModel": "google-vision",
  "success": true,
  "extractedAt": "2024-01-15T10:30:00.000Z",
  "merchantName": "SuperMart Store",
  "merchantAddress": "123 Main Street, City, State 12345",
  "date": "01/15/2024",
  "time": "10:25 AM",
  "receiptNumber": "TXN-12345",
  "currency": "USD",
  "subtotal": 45.50,
  "tax": 3.64,
  "totalAmount": 49.14,
  "paymentMethod": "Credit Card",
  "lineItems": [
    {
      "name": "Product A",
      "price": 15.99
    },
    {
      "name": "Product B",
      "price": 29.51
    }
  ],
  "calculationVerification": {
    "isValid": true,
    "errors": []
  },
  "metadata": {
    "confidence": 0.95,
    "processingTime": 1234,
    "imageSize": 524288
  },
  "rawText": "SuperMart Store\n123 Main Street..."
}
```

### 🎯 Use Cases

#### Expense Management

- Automate receipt data entry for expense reports
- Track business expenses in real-time
- Integrate with accounting software

#### Accounting & Bookkeeping

- Digitize paper receipts for record keeping
- Verify transaction details automatically
- Generate financial reports from receipt data

#### E-commerce & Retail

- Receipt verification systems
- Customer purchase tracking
- Warranty and return management

#### Fintech Applications

- Personal finance tracking apps
- Budget management tools
- Tax preparation software

### 🔧 Model Comparison

| Model | Speed | Accuracy | Cost | Best For |
|-------|-------|----------|------|----------|
| Native | ⚡⚡⚡ | ⭐⭐⭐ | Free | Testing, low volume |
| Google Vision | ⚡⚡ | ⭐⭐⭐⭐⭐ | $$ | High accuracy needs |
| Amazon Textract | ⚡⚡ | ⭐⭐⭐⭐⭐ | $$ | Receipt-specific |
| OpenAI | ⚡ | ⭐⭐⭐⭐⭐ | $$$ | Complex receipts |
| Azure Vision | ⚡⚡ | ⭐⭐⭐⭐ | $$ | Microsoft ecosystem |
| Gemini | ⚡⚡ | ⭐⭐⭐⭐ | $$ | Latest AI tech |
| DeepSeek | ⚡⚡ | ⭐⭐⭐⭐ | $$ | Alternative to OpenAI |
| Hugging Face | ⚡⚡ | ⭐⭐⭐ | $ | Open-source models |

### 🔐 Security & Privacy

- All API keys are stored securely as secrets
- Images are processed in memory and not permanently stored
- Supports private/internal image URLs
- GDPR and data privacy compliant

### 💡 Tips for Best Results

1. **Image Quality**: Use high-resolution, well-lit images
2. **Format**: Straight, unfolded receipts work best
3. **Contrast**: Ensure good contrast between text and background
4. **Model Selection**:
   - Use Native for testing and low-volume processing
   - Use Google Vision or Textract for production workloads
   - Use OpenAI for complex or damaged receipts

### 🐛 Error Handling

The actor handles various error scenarios:

- Invalid or unreachable image URLs
- OCR processing failures
- Missing or invalid API keys
- Malformed receipt data

Each result includes a `success` field and `error` message when applicable.

### 📊 Batch Processing

Process multiple receipts in a single run:

```json
{
  "ocrModel": "google-vision",
  "receiptUrls": [
    "https://example.com/receipt1.jpg",
    "https://example.com/receipt2.jpg",
    "https://example.com/receipt3.jpg"
  ]
}
```

The actor will process all receipts and provide individual results for each.

### 🔗 Integration

#### API Integration

```javascript
const Apify = require('apify-client');

const client = new Apify.ApifyClient({
    token: 'YOUR_API_TOKEN',
});

const run = await client.actor('YOUR_ACTOR_ID').call({
    ocrModel: 'google-vision',
    googleVisionApiKey: 'YOUR_GOOGLE_API_KEY',
    receiptUrls: ['https://example.com/receipt.jpg'],
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

#### Webhook Integration

Configure webhooks to receive results automatically when processing completes.

### 📈 Performance

- **Processing Speed**: 2-10 seconds per receipt (varies by model)
- **Concurrent Processing**: Up to 10 receipts simultaneously
- **Maximum Image Size**: 50MB per image
- **Supported Formats**: JPG, PNG, PDF

### 🆘 Support

For issues, questions, or feature requests:

- Check the [Apify documentation](https://docs.apify.com)
- Review the input schema for parameter details
- Ensure API keys are valid and have sufficient quota

### 🔄 Version History

#### v1.0.0

- Initial release
- Support for 8 OCR models
- Intelligent receipt parsing
- Batch processing
- Calculation verification
- Multi-format image support

***

Built with ❤️ using Apify Platform

# Actor input Schema

## `ocrModel` (type: `string`):

Select the OCR model to use for text extraction

## `receiptUrls` (type: `array`):

Array of receipt image URLs to process (supports JPG, PNG, PDF)

## `googleVisionApiKey` (type: `string`):

Required if using Google Vision API

## `deepseekApiKey` (type: `string`):

Required if using DeepSeek OCR

## `awsAccessKeyId` (type: `string`):

Required if using Amazon Textract

## `awsSecretAccessKey` (type: `string`):

Required if using Amazon Textract

## `awsRegion` (type: `string`):

AWS region for Textract (e.g., us-east-1)

## `azureEndpoint` (type: `string`):

Required if using Azure AI Vision

## `azureApiKey` (type: `string`):

Required if using Azure AI Vision

## `openaiApiKey` (type: `string`):

Required if using OpenAI GPT-4 Vision

## `huggingfaceApiKey` (type: `string`):

Required if using Hugging Face models

## `geminiApiKey` (type: `string`):

Required if using Gemini API

## `extractLineItems` (type: `boolean`):

Extract individual line items from receipt

## `verifyCalculations` (type: `boolean`):

Verify totals and tax calculations

## `outputFormat` (type: `string`):

Format for extracted data

## Actor input object example

```json
{
  "ocrModel": "native",
  "receiptUrls": [
    "https://images.rawpixel.com/dark_image_png_800/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDI1LTA1L3NyLWltYWdlLTE1MDUyMDI1LWF1LXMtMTM3XzIucG5n.png"
  ],
  "awsRegion": "us-east-1",
  "extractLineItems": true,
  "verifyCalculations": true,
  "outputFormat": "detailed"
}
```

# Actor output Schema

## `overview` (type: `string`):

Quick overview of extracted receipt data with key fields

## `allReceipts` (type: `string`):

Complete dataset with all extracted receipt information

## `summary` (type: `string`):

Summary of the OCR processing run with success/failure counts

# 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 = {
    "ocrModel": "native",
    "receiptUrls": [
        "https://images.rawpixel.com/dark_image_png_800/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDI1LTA1L3NyLWltYWdlLTE1MDUyMDI1LWF1LXMtMTM3XzIucG5n.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("happitap/receipt-ocr-api").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 = {
    "ocrModel": "native",
    "receiptUrls": ["https://images.rawpixel.com/dark_image_png_800/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDI1LTA1L3NyLWltYWdlLTE1MDUyMDI1LWF1LXMtMTM3XzIucG5n.png"],
}

# Run the Actor and wait for it to finish
run = client.actor("happitap/receipt-ocr-api").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 '{
  "ocrModel": "native",
  "receiptUrls": [
    "https://images.rawpixel.com/dark_image_png_800/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDI1LTA1L3NyLWltYWdlLTE1MDUyMDI1LWF1LXMtMTM3XzIucG5n.png"
  ]
}' |
apify call happitap/receipt-ocr-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,happitap/receipt-ocr-api"
        }
    }
}

```

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/uZb64NCPnYOObjR0R/builds/tfrgnTFgvO0Bih0Ap/openapi.json
