apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Extract Text from Bulk Images & Scanned PDFs API

What it does

The Scanned PDF OCR API turns images and PDFs into machine-readable text. Send up to 100 public file links in urls (PNG, JPG, WEBP, TIFF, BMP, GIF or PDF) and get back a JSON object with a count, a billed page total and an items array holding one result per image or PDF page, in the order you sent them.

Choose outputMode lines for text lines or words for single words, each with a confidence score and a bounding box. PDF pages that already contain a text layer are read directly, which is exact and fast; set forceOcr to true to run OCR on every page instead. Use languages to pick the OCR language (English, German, French, Spanish, Italian, Portuguese, Bulgarian, Russian, or a mix), and maxPagesPerPdf to cap how many pages are read from each PDF.

Use it to digitise scanned contracts, archived forms, receipts and exported reports, or to feed document text into search, review and RAG pipelines. You pay per page read; blank pages and files that cannot be read are not charged.

POST
Image to Text OCR - Scanned PDF OCR
https://api.eu.apyhub.com/martin10291/extract-text-from-bulk-images-and-pdfs

QUICKSTART

GUIDE

Quickstart

Send one public image or PDF URL to get its text back line by line.

curl -X POST "https://api.eu.apyhub.com/<provider-slug>/image-to-text-ocr-scanned-pdf-ocr-per-line" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"],"forceOcr":true}'

What you'll get back

Returns a JSON object with billed, count and an items array. Each item holds the text of one image or PDF page, how it was read (ocr or text-layer), a mean confidence score, and the lines (or words) with their own confidence and bounding box.

{
  "billed": 1,
  "count": 1,
  "items": [
    {
      "sourceUrl": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
      "page": 1,
      "method": "ocr",
      "text": "Dummy PDF file",
      "meanConfidence": 95.3,
      "width": 1653,
      "height": 2339,
      "lines": [
        {
          "text": "Dummy PDF file",
          "confidence": 95.3,
          "bbox": [161, 200, 338, 43]
        }
      ]
    }
  ]
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
urls*
Direct public links to images (png, jpg, webp, tiff, bmp, gif) or PDF files. One result per image and per PDF page. Max 100 items; private and local addresses are rejected.
Run OCR on every PDF page, even pages that already have a text layer.
languages
Languages of the text, used only for pages read by OCR. Send several for mixed text.
lines: every text line with confidence and bounding box. words: every word with confidence and bounding box (OCR pages only).

About this endpoint

What it does

Reads text from one or more public image or PDF URLs and returns one result per image and per PDF page. PDF pages that have a text layer are read directly unless forceOcr is true; every other page is read with OCR in the languages you choose.

Request Body

ParameterTypeDescription
urlsString ArrayRequired. Direct public links to images (png, jpg, webp, tiff, bmp, gif) or PDF files. Min 1, max 100 items. Must be http or https; private and local addresses are rejected. Duplicate URLs are processed once.
forceOcrBooleanRun OCR on every PDF page, even pages that already have a text layer. Use it when the text layer is wrong or missing. Default: false.
languagesENUM ArrayLanguages of the text, used only for pages read by OCR. Allowed values: eng, deu, fra, spa, ita, por, bul, rus. Send several for mixed text (a little slower). Default: ["eng"].
outputModeENUMLevel of detail for OCR pages. Allowed values: lines, words. lines returns each text line; words returns each word. Both include confidence and bounding box. Default: lines.
maxPagesPerPdfIntegerRead at most this many pages from each PDF, starting at page 1. Range: 1 to 500. Omit to read all pages.

Response

Returns a JSON object with billed, count and an items array. Each item is either a page result (one per image or PDF page) or a not-found row for a file that could not be read.

ParameterTypeDescription
billedIntegerNumber of pages charged for this call. Blank pages and unreadable files are not charged.
countIntegerNumber of items returned.
itemsObject ArrayOne object per image or PDF page, in the order of urls.
items[].sourceUrlStringURL the result came from.
items[].pageIntegerPage number inside the PDF. 1 for images.
items[].methodENUMHow the page was read. Allowed values: ocr, text-layer.
items[].textStringFull text of the page, with lines separated by \n.
items[].meanConfidenceNumberAverage OCR confidence from 0 to 100. null for text-layer pages.
items[].widthIntegerWidth of the page or image in pixels (points for text-layer pages).
items[].heightIntegerHeight of the page or image in pixels (points for text-layer pages).
items[].linesObject ArrayText lines, returned when outputMode is lines and for all text-layer pages.
items[].lines[].textStringText of the line.
items[].lines[].confidenceNumberLine confidence from 0 to 100. null for text-layer pages.
items[].lines[].bboxInteger ArrayBounding box as [x, y, width, height] in pixels. null for text-layer pages.
items[].wordsObject ArraySingle words with text, confidence and bbox, returned when outputMode is words on OCR pages.
items[].foundBooleanfalse when nothing could be read from the file (blank image, unreachable link, unsupported file). Only present on not-found rows.
items[].statusStringReason for a not-found row. Only present when found is false.
items[].inputObjectEcho of the input that produced a not-found row.

Notes

At most 100 URLs per call and 500 pages per PDF. Links must point straight to the file; HTML pages are not read. Text-layer PDF pages always return lines without confidence or bounding boxes. OCR does not auto-rotate pages, so send upright scans for best results. Each call has a time limit of about 35 seconds, so split very large batches.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.