apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Extract Text from Image & PDF API

What it does

The OCR API reads text from scanned documents and images. Send the file as file_base64 with its file_name, and get back the extracted text and the number of pages.

It handles photos and scans as well as clean images. In our tests it read rotated, blurred and low-quality JPG images correctly. Supported files are PDF, PNG, JPG, TIFF, WEBP, BMP and GIF, up to 20 MB. Each request can contain up to 2 pages, so split longer PDFs and send the parts separately. An image with no text returns an empty text field.

The response is plain text with line breaks kept, ready for search, classification or storage.

Teams use the OCR API to digitize scanned records and read text from uploaded photos and screenshots. It also feeds document pipelines that need text first.

To translate the text, use the Text Translation API. To remove names and phone numbers before you store it, use the Text Anonymization API.

POST
Extract Text from Image or PDF
https://api.eu.apyhub.com/skavio/extract-text-from-image-pdf

QUICKSTART

GUIDE

Quickstart

Read the text from a PNG image.

curl -X POST "https://api.eu.apyhub.com/skavio/extract-text-from-image-pdf" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "scan.png",
    "file_base64": "iVBORw0KGgo..."
  }'

What you'll get back

A real response for an image with the text "Hello World 12345":

{
  "text": "Hello World 12345",
  "pages": 1,
  "status": "completed",
  "usage": { "atoms": 800, "units": 1, "unit": "page" },
  "request_id": "4f19fa68-8586-440f-8d84-ed0656f305ac-8f54b458"
}
TRY ITLIVE · 1600 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*
File name with extension (pdf, png, jpg, jpeg, tif, tiff, webp, bmp, gif, txt).
Base64-encoded file (max 20 MB decoded).

About this endpoint

What it does

Reads the text in a scanned PDF or image and returns it as plain text, with line breaks kept.

Limits

  • Maximum 2 pages per request. A PDF with more pages returns 413 with input_too_large. Split longer documents and send the parts separately.
  • Maximum file size is 20 MB.
  • Supported files: PDF, PNG, JPG, JPEG, TIF, TIFF, WEBP, BMP, GIF.
  • An image with no text returns an empty text string.

Request Body

ParameterTypeMandatoryDescription
file_base64StringYesThe file, base64-encoded. Maximum decoded size is 20 MB.
file_nameStringYesFile name with extension, e.g. scan.png. The extension tells the API how to read the file.

Response

ParameterTypeDescription
textStringThe extracted text. Line breaks are kept as \n.
pagesIntegerPages processed.
statusStringcompleted on success.
usageObjectunits and unit (page) counted for the request, plus atoms.
request_idStringID for support requests.

Errors

StatusCodeWhen
400missing_filefile_base64 is empty or missing.
400invalid_base64file_base64 is not valid base64.
413file_too_largeThe decoded file is over 20 MB.
422unprocessable_fileThe file cannot be read, e.g. a corrupt PDF or a file whose content does not match its extension.
422processing_failedThe file was read but could not be processed.
429busyToo many requests are in progress. Retry after a short wait.
413input_too_largeThe file has more than 2 pages.
▣ 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.