API Reference/SDK & Client Libraries

SDK & Client Libraries

Official client libraries for Python and Node.js. Integrate PDF processing and AI document intelligence without writing raw HTTP calls.

npm: allpdfmagicPyPI: allpdfmagicGet your API key

Node.js / TypeScript

Works in Node 18+, Deno, Bun, and Next.js API routes

Installation

bash
npm install allpdfmagic
# or
yarn add allpdfmagic

Quick Start

typescript
import AllPDFMagic from 'allpdfmagic';
import { createReadStream } from 'fs';

const client = new AllPDFMagic('YOUR_API_KEY');

// Compress a PDF
const result = await client.pdf.compress(createReadStream('input.pdf'), {
  level: 'medium',
});
result.saveToFile('compressed.pdf');

// Extract invoice data with AI
const invoice = await client.ai.extractInvoice(createReadStream('invoice.pdf'));
console.log(invoice.vendor, invoice.total, invoice.lineItems);

// Convert Word to PDF
const pdf = await client.convert.wordToPdf(createReadStream('report.docx'));
pdf.saveToFile('report.pdf');

Batch processing & quota check

typescript
// Bulk processing with async/await
const files = ['inv1.pdf', 'inv2.pdf', 'inv3.pdf'];
const results = await Promise.all(
  files.map(f => client.ai.extractInvoice(createReadStream(f)))
);

// Check quota before a large batch
const usage = await client.usage.check();
console.log(`${usage.remaining} calls remaining this month`);

// Merge multiple PDFs
const merged = await client.pdf.merge([
  createReadStream('part1.pdf'),
  createReadStream('part2.pdf'),
]);
merged.saveToFile('merged.pdf');

Python

Works with Python 3.8+. Supports sync and async (asyncio) usage.

Installation

bash
pip install allpdfmagic

Quick Start

python
from allpdfmagic import AllPDFMagic

client = AllPDFMagic("YOUR_API_KEY")

# Compress a PDF
with open("input.pdf", "rb") as f:
    result = client.pdf.compress(f, level="medium")
    result.save("compressed.pdf")

# Extract invoice data with AI
with open("invoice.pdf", "rb") as f:
    invoice = client.ai.extract_invoice(f)
    print(invoice.vendor, invoice.total, invoice.line_items)

# Summarize a document
with open("report.pdf", "rb") as f:
    summary = client.ai.summarize(f)
    print(summary.text)

Quota check & batch conversion

python
# Check quota
usage = client.usage.check()
print(f"{usage.remaining} calls remaining this month")

# OCR a scanned document
with open("scanned.pdf", "rb") as f:
    ocr_result = client.ai.ocr(f)
    print(ocr_result.text)

# Batch-convert multiple Word files to PDF
import glob
for path in glob.glob("reports/*.docx"):
    with open(path, "rb") as f:
        pdf = client.convert.word_to_pdf(f)
        pdf.save(path.replace(".docx", ".pdf"))

No SDK — plain HTTP

Works from any language. The API is just multipart/form-data over HTTPS.

bash
# No SDK needed — plain HTTP works everywhere
curl -X POST https://www.allpdfmagic.com/api/v1/pdf/compress \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@input.pdf" \
  -F "level=medium" \
  -o compressed.pdf

See the full API reference for all endpoints with parameters and response shapes.

Method Reference

CategoryPythonNode.jsEndpoint
PDF Operationsclient.pdf.compress(file)client.pdf.compress(stream)POST /api/v1/pdf/compress
client.pdf.merge(files)client.pdf.merge(streams)POST /api/v1/pdf/merge
client.pdf.split(file)client.pdf.split(stream)POST /api/v1/pdf/split
client.pdf.rotate(file)client.pdf.rotate(stream)POST /api/v1/pdf/rotate
client.pdf.delete_pages(file, pages)client.pdf.deletePages(stream, pages)POST /api/v1/pdf/delete-pages
client.pdf.extract_pages(file, pages)client.pdf.extractPages(stream, pages)POST /api/v1/pdf/extract-pages
Conversionsclient.convert.word_to_pdf(file)client.convert.wordToPdf(stream)POST /api/v1/convert/word-to-pdf
client.convert.pdf_to_word(file)client.convert.pdfToWord(stream)POST /api/v1/convert/pdf-to-word
client.convert.pdf_to_excel(file)client.convert.pdfToExcel(stream)POST /api/v1/convert/pdf-to-excel
client.convert.pdf_to_jpg(file)client.convert.pdfToJpg(stream)POST /api/v1/convert/pdf-to-jpg
AI Endpointsclient.ai.summarize(file)client.ai.summarize(stream)POST /api/v1/ai/summarize
client.ai.extract_invoice(file)client.ai.extractInvoice(stream)POST /api/v1/ai/extract-invoice
client.ai.ocr(file)client.ai.ocr(stream)POST /api/v1/ai/ocr
client.ai.ask(file, question)client.ai.ask(stream, question)POST /api/v1/ai/questions
Usageclient.usage.check()client.usage.check()GET /api/v1/usage/check

What the SDK handles for you

Authentication header injection on every request
Automatic retry with exponential backoff (3 attempts)
File stream handling — pass any readable stream or file path
Binary response saving — .saveToFile() / .save() helpers
TypeScript types for all request params and responses
Quota check helper — check remaining calls before large batches
Error classes — QuotaExceededError, AuthError, ValidationError
Timeout configuration and request cancellation support

Ready to integrate?

Get your free API key — 500 calls/month, no credit card required.