Quickstart

Make your first request to the OCR & Markdown API.

1. Get access

Subscribe to the listing for your endpoint. Your marketplace provides credentials and billing.

RRapidAPI
Complete APIGet access
aApyHub
Images & PDF pages to MarkdownGet access

2. Set your credentials

Set RAPIDAPI_KEY or APY_TOKEN on your server. Python examples require httpx; Node.js examples use built-in fetch.

python -m pip install httpx

export RAPIDAPI_KEY="YOUR_RAPIDAPI_KEY"
# or
export APY_TOKEN="YOUR_APYHUB_TOKEN"

3. Send a request

Replace the base64 placeholder with your file’s bytes. The tutorial includes a complete upload example.

Replace the base64 placeholder with your file. See the tutorial for an upload example.

import os
import httpx

base_url = "https://ocr-pdf-to-markdown-api.p.rapidapi.com"
headers = {
    "X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"],
    "X-RapidAPI-Host": "ocr-pdf-to-markdown-api.p.rapidapi.com",
}
payload = {
    "page": 1,
    "format": "json",
    "document": {
        "base64": "BASE64_PDF",
    },
}
response = httpx.post(
    base_url + "/v1/ocr/document",
    headers=headers, json=payload, timeout=120
)
response.raise_for_status()
print(response.json())

4. Check the result

Check the JSON fields your application needs before using the result.

One image or PDF page per request. The demo processes one selected page from a PDF of up to 20 pages. Recognition and reading order can be imperfect; review important text, numbers and tables.

Task tutorial

Errors and retries

  • 401 / 403: check your credentials, subscription and feature access.
  • 422: correct the input before retrying. Application errors include a detail object with a code and message.
  • 429: check your rate limit or plan allowance.
  • 502 / 503 / 504: use bounded retries with backoff and honor Retry-After. Retries may consume allowance.

Marketplace errors may use a different format. Keep the status and request identifier for diagnostics; avoid logging API keys or customer files.