← Back to PDFStream AI

API documentation

Send documents from your own code and get back clean JSON: extracted text, tables, key values and the AI report. Included with Pro and Enterprise.

Authentication

Create a key on your profile page and send it as a bearer token on every request:

Authorization: Bearer pdfs_xxxxxxxxxxxxxxxxxxxxxxxx

Keys are shown once. Revoke a key at any time and it stops working immediately.

Endpoints

POST/api/public/v1/documentsUpload a document (multipart field 'file')
GET/api/public/v1/documentsList your most recent documents
GET/api/public/v1/documents/{id}Fetch status, extracted data and the report

Accepted files: PDF, DOCX, JPG, PNG, up to 20 MB. Rate limit: 60 requests per minute. Every processed document counts towards your monthly allowance, exactly like uploads in the app.

cURL

curl -X POST https://project--80784737-4ea2-4e89-acea-fda75f707986.lovable.app/api/public/v1/documents \
  -H "Authorization: Bearer $PDFSTREAM_API_KEY" \
  -F "file=@invoice.pdf"

# -> {"id":"7c2f...","status":"queued","file_name":"invoice.pdf"}

curl https://project--80784737-4ea2-4e89-acea-fda75f707986.lovable.app/api/public/v1/documents/7c2f... \
  -H "Authorization: Bearer $PDFSTREAM_API_KEY"

Node.js

const form = new FormData();
form.set("file", new File([await fs.readFile("invoice.pdf")], "invoice.pdf", {
  type: "application/pdf",
}));

const created = await fetch("https://project--80784737-4ea2-4e89-acea-fda75f707986.lovable.app/api/public/v1/documents", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PDFSTREAM_API_KEY}` },
  body: form,
}).then((res) => res.json());

// Poll until the document is completed
let result;
do {
  await new Promise((r) => setTimeout(r, 3000));
  result = await fetch(`https://project--80784737-4ea2-4e89-acea-fda75f707986.lovable.app/api/public/v1/documents/${created.id}`, {
    headers: { Authorization: `Bearer ${process.env.PDFSTREAM_API_KEY}` },
  }).then((res) => res.json());
} while (result.document.status === "queued" || result.document.status === "processing");

console.log(result.report.summary, result.extracted.key_values);

Python

import os, time, requests

BASE = "https://project--80784737-4ea2-4e89-acea-fda75f707986.lovable.app/api/public/v1"
headers = {"Authorization": f"Bearer {os.environ['PDFSTREAM_API_KEY']}"}

with open("invoice.pdf", "rb") as fh:
    created = requests.post(
        f"{BASE}/documents",
        headers=headers,
        files={"file": ("invoice.pdf", fh, "application/pdf")},
    ).json()

while True:
    result = requests.get(f"{BASE}/documents/{created['id']}", headers=headers).json()
    if result["document"]["status"] in ("completed", "error"):
        break
    time.sleep(3)

print(result["report"]["summary"])
print(result["extracted"]["key_values"])

Responses and errors

202AcceptedDocument queued for processing
401UnauthorizedMissing, revoked or invalid API key
402Limit reachedMonthly document allowance used up
413Too largeFile exceeds 20 MB
415UnsupportedFile type not supported
429Rate limitedMore than 60 requests in a minute