# Image OCR API - Text and Word Boxes from JPG, PNG, WebP (`stas_k/image-ocr-api`) Actor

The busiest image OCR actors wrap Google Lens, so a captcha leaves you without text. This one carries its own recogniser: text, confidence and word boxes from every picture, and a picture with no text costs nothing.

- **URL**: https://apify.com/stas_k/image-ocr-api.md
- **Developed by:** [Stas K](https://apify.com/stas_k) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$6.00 / 1,000 image reads

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

## Image OCR API: text and word boxes from a picture

Point it at a list of image urls and get one row per picture: the text, the mean word
confidence, the lines, and the box of every word with its own confidence. The
recogniser (Tesseract, with eng, rus and ukr packs) ships inside the actor, so there is
no key to bring, no OCR service to pay, and no queue that belongs to somebody else.

Formats: jpeg, png, webp, gif, bmp, tiff and heic from a phone. A photo taken sideways
is turned the right way up before recognition, and the row says `rotated: true`.

### Why this exists

The biggest actors in this niche wrap Google Lens: they open a Google page, scrape the
answer and stop working the day Google answers with a captcha. That is a free service
of somebody else resold as a product. Here the engine lives in the image, and a picture
that has no text comes back **free** with the reason instead of an empty string.

### Price

A row with text on it costs $0.006. Every other row is free: a picture without text, an
html page, a broken file, a repeat, a line that is not a url, a line beyond `maxImages`,
and every line after a stop. The summary says `chargedEvents` and that is the number
the platform really charged.

### Statuses

`OK` means the picture was read and the row is billable. Everything else is free and
carries a plain reason:

- `NOT_CHECKED_NOT_AN_IMAGE`: the bytes are not a picture (an html login page, a pdf)
- `NOT_CHECKED_BROKEN_IMAGE`: the signature says jpeg, the decoder disagrees
- `NOT_CHECKED_NO_TEXT`: a real picture with no text on it
- `NOT_CHECKED_FETCH_ERROR`: the server refused or timed out
- `NOT_CHECKED_DNS_ERROR`: the host name does not resolve, or is not a name at all
- `NOT_CHECKED_PRIVATE_ADDRESS`: the url, or a redirect it leads to, points inside a
  private network
- `NOT_CHECKED_TOO_LARGE`: the file is above 25 MB
- `NOT_CHECKED_LIMIT`, `NOT_CHECKED_DUPLICATE`, `NOT_CHECKED_INVALID`: the list, not the site
- `NOT_CHECKED_TIME`, `NOT_CHECKED_CAP`, `NOT_CHECKED_BILLING`: the run stopped before this row
- `NOT_CHECKED_ERROR`: the run stopped on an unexpected error before this picture

### What this actor does not do

- It does not read pdf files. That is a separate actor in this park, pdf-ocr-api.
- It does not recognise handwriting reliably. Tesseract reads print; a handwritten note
  will come back with little text, and the row is still charged if any text came out.
- It does not read a language whose pack is not installed. Only `eng`, `rus` and `ukr`
  ship inside the image: ask for another one in `languages` and the run refuses before
  it downloads a single picture, with nothing charged. Leave the default `eng` on, say,
  a German scan and the text comes back partial and at low confidence, and the row is
  still charged if any text came out, the same as with handwriting.
- An animated gif is read from its first frame. The row says `imageFormat: gif` and the
  text is of that frame.
- It does not go into private networks: a url that resolves inside `10.0.0.0/8`,
  `127.0.0.0/8`, `100.64.0.0/10` or behind a public name that answers from a private
  address is refused before the request is sent. Redirects are followed by hand, at
  most three, and every hop passes the same guard before its own request goes out, so a
  public url that answers 302 into a private address is refused before that hop is
  requested.

### Limits

`maxImages` defaults to 10, and the run says how many it applied. A picture above
`maxPixels` (40 million by default) is scaled down before recognition, never silently.
The picture is turned to png inside the run, so a 25 MB jpeg is not held twice in
memory.

### Summary

The run writes `RUN_SUMMARY-<runId>` into the `image-ocr-api-summary` store. The bare
`RUN_SUMMARY` key lives only in the store of that run, which belongs to nobody else.
Counters close on themselves: `imagesProcessed + imagesNotChecked` equals
`imagesAttempted`, and `linesThatAreNotImages + imagesAttempted` equals `requested`.
`deliveredImages` counts every picture row that reached the buyer, paid or free, while
`chargedImages` counts only the rows that took money and `chargedEvents` is what the
platform confirms. When a paid row raises and the dataset counter shows the row did
land, it is named in `deliveredUncharged`; when the counter cannot confirm it, it is
named in `deliveredUnconfirmed` instead of being counted as delivered.

### No key, no externals

The actor only fetches the urls the buyer sent. There is no Google, no API key and no
account anywhere in the path.

# Actor input Schema

## `imageUrls` (type: `array`):

One image url per line: jpeg, png, webp, gif, bmp, tiff or heic. Each picture is read once and recognized inside the actor, so no key and no OCR service is needed. A line that is not an http url, a repeat and a line beyond maxImages come back as their own free row with the reason.

## `maxImages` (type: `integer`):

The list is cut here and the rest comes back free with status NOT_CHECKED_LIMIT. 0 means the default of 10, and the summary reports the number actually applied.

## `languages` (type: `string`):

Language packs that ship inside the actor. More than one slows recognition, so ask only for the ones your pictures really use.

## `includeWordBoxes` (type: `boolean`):

Every word with its x, y, width, height and confidence. Turn it off when only the plain text is needed: rows get much smaller.

## `maxPixels` (type: `integer`):

A picture larger than this is scaled down before recognition and the row says so in scaled. Keeps a 200 megapixel phone panorama from running the container out of memory.

## Actor input object example

```json
{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg/1280px-Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/e/e9/1917_Foto-Scan_Rechnung.jpg"
  ],
  "maxImages": 10,
  "languages": "eng",
  "includeWordBoxes": true,
  "maxPixels": 40000000
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

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

No description

# 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 = {
    "imageUrls": [
        "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg/1280px-Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg",
        "https://upload.wikimedia.org/wikipedia/commons/e/e9/1917_Foto-Scan_Rechnung.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stas_k/image-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 = { "imageUrls": [
        "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg/1280px-Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg",
        "https://upload.wikimedia.org/wikipedia/commons/e/e9/1917_Foto-Scan_Rechnung.jpg",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("stas_k/image-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 '{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg/1280px-Fish_Creek_%28AU%29%2C_Welcome_Sign_--_2019_--_150820.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/e/e9/1917_Foto-Scan_Rechnung.jpg"
  ]
}' |
apify call stas_k/image-ocr-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,stas_k/image-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/ZjhRhgxQjejdaDRZ4/builds/NwlVgJoYRle7lWX7m/openapi.json
