Extract a document
| Method | POST |
|---|---|
| Endpoint | https://api.oerena.com/v1/documents/extract |
| Authentication | Bearer OERENA API key |
| Content-Type | multipart/form-data |
| Form field | file (exactly one file) |
| Supported MIME types | application/pdf, image/jpeg, image/png |
| Maximum upload | 10 MiB (10,485,760 bytes) |
| Current page ceiling | 10 pages per document |
| Image validation | JPEG/PNG magic bytes and a 25-million-pixel maximum are checked |
The service rejects malformed multipart bodies, extra fields or files, unsupported MIME types, disguised file content, encrypted PDFs, oversized uploads, and documents above the enforced page limit.
cURL
curl -X POST "https://api.oerena.com/v1/documents/extract" \
-H "Authorization: Bearer YOUR_OERENA_API_KEY" \
-F "file=@document.pdf"Node.js
import { readFile } from "node:fs/promises";
const file = await readFile("./document.pdf");
const form = new FormData();
form.append("file", new Blob([file], { type: "application/pdf" }), "document.pdf");
const response = await fetch("https://api.oerena.com/v1/documents/extract", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.OERENA_API_KEY}` },
body: form,
});
const result = await response.json();
if (!response.ok) throw new Error(`${result.request_id}: ${result.error?.message}`);
console.log(result.data.document.text);Python
import os
import requests
with open("document.pdf", "rb") as document:
response = requests.post(
"https://api.oerena.com/v1/documents/extract",
headers={"Authorization": f"Bearer {os.environ['OERENA_API_KEY']}"},
files={"file": ("document.pdf", document, "application/pdf")},
timeout=60,
)
result = response.json()
if not response.ok:
raise RuntimeError(f"{result.get('request_id')}: {result['error']['message']}")
print(result["data"]["document"]["text"])