apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Extract PDF Content API

What it does

PDF Text Extractor turns a PDF into plain text or page-by-page text. Send a PDF file, a public PDF URL, or a base64-encoded PDF, and get the extracted text back in the response.

Use the structured flag when you need page boundaries preserved. With structured: false, the response contains a single text field with all content in reading order. With structured: true, the response returns page_count and a pages array, where each entry is the text from one page.

This is useful when you need to index uploaded documents, feed contract or report text into downstream parsing, or extract content from PDFs stored in object storage or fetched from external links. The API handles the transport format; you decide whether you want one continuous string or page-aware output.

Choose the file upload endpoint for direct uploads, the URL endpoint for remote PDFs, or the base64 endpoint when your application already has the document encoded in JSON.

▣ ENDPOINT 01 / 03
POST
Extract text from uploaded PDF file
https://api.eu.apyhub.com/sarvasoft/extract-pdf-content/file

QUICKSTART

GUIDE

Quickstart

Upload a PDF file to extract its text.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/extract-pdf-content/file" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/document.pdf"

What you'll get back

Returns a JSON object in one of two shapes: either a text string with all extracted text in reading order, or a page_count integer plus a pages array of strings when structured extraction is enabled.

{
  "text": "Extracted text from the PDF..."
}
TRY ITLIVE · 12 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.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
The PDF file to upload and extract text from.
Return the text page by page instead of one string.

About this endpoint

What it does

Uploads a PDF file and extracts its text. Returns the text as one string, or page by page when structured is true.

Request Body (multipart/form-data)

ParameterTypeDescription
fileFileRequired. The PDF file to upload.
structuredBooleanReturn the text page by page instead of one string. Default: false.

Response

Returns a JSON object. The shape depends on structured.

ParameterTypeDescription
textStringReturned when structured is false. All text in reading order.
page_countIntegerReturned when structured is true. Number of pages.
pagesString ArrayReturned when structured is true. Text of each page, in order.

Notes

  • A non-PDF file returns a 422 error.
  • Password-protected PDFs are not supported and return an error.

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 02 / 03
POST
Extract text from PDF at remote URL
https://api.eu.apyhub.com/sarvasoft/extract-pdf-content/url

QUICKSTART

GUIDE

Quickstart

Extract text from a PDF at a public URL.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/extract-pdf-content/url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pdf_url":"https://assets.apyhub.com/samples/sample.pdf"}'

What you'll get back

Returns a JSON object in one of two shapes:

  • {"text": string} when extraction is plain text.
  • {"page_count": integer, "pages": string[]} when extraction is structured per page.
{"text":"..."}
TRY ITLIVE · 5 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*
Public URL of the PDF to extract text from. Must be http or https.
Return the text page by page instead of one string.

About this endpoint

What it does

Extracts text from a PDF hosted at a public URL. Returns the text as one string, or page by page when structured is true.

Request Body

ParameterTypeDescription
pdf_urlStringRequired. Public URL of the PDF. Must be http or https.
structuredBooleanReturn the text page by page instead of one string. Default: false.

Response

Returns a JSON object. The shape depends on structured.

ParameterTypeDescription
textStringReturned when structured is false. All text in reading order.
page_countIntegerReturned when structured is true. Number of pages.
pagesString ArrayReturned when structured is true. Text of each page, in order.

Notes

  • A URL that is unreachable or does not point to a PDF returns a 422 error.
  • Password-protected PDFs are not supported and return an error.
▣ ENDPOINT 03 / 03
POST
Extract text from base64 PDF in JSON
https://api.eu.apyhub.com/sarvasoft/extract-pdf-content/base64

QUICKSTART

GUIDE

Quickstart

Extract text from a PDF provided as base64 in the request body.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/extract-pdf-content/base64" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "pdf_base64": "JVBERi0xLjQKJc..."
  }'

What you'll get back

Returns a JSON object in one of two shapes:

  • A plain-text response with a text string containing all extracted text in reading order, or
  • A structured response with page_count as an integer and pages as an array of page text strings.
{
  "text": "Extracted PDF text here."
}
{
  "page_count": 2,
  "pages": [
    "Text from page 1.",
    "Text from page 2."
  ]
}
TRY ITLIVE · 11 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*
Base64-encoded PDF to extract text from.
Return the text page by page instead of one string.

About this endpoint

What it does

Extracts text from a Base64-encoded PDF sent in a JSON body. Returns the text as one string, or page by page when structured is true.

Request Body

ParameterTypeDescription
pdf_base64StringRequired. Base64-encoded PDF.
structuredBooleanReturn the text page by page instead of one string. Default: false.

Response

Returns a JSON object. The shape depends on structured.

ParameterTypeDescription
textStringReturned when structured is false. All text in reading order.
page_countIntegerReturned when structured is true. Number of pages.
pagesString ArrayReturned when structured is true. Text of each page, in order.

Notes

  • A non-PDF payload or invalid Base64 returns a 422 error.
  • Password-protected PDFs are not supported and return an error.
▣ 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.