OnlyDocs API: The Complete Developer Guide for PDF Automation (2025)



OnlyDocs API: The Complete Developer Guide for PDF Automation (2025)
Need to programmatically manipulate PDFs in your application? Tired of Adobe's $25k-$55k/year API pricing? OnlyDocs API gives you enterprise-grade PDF processing at $29.99/month with unlimited requests.
This guide covers everything you need to integrate OnlyDocs API into your application.
Why OnlyDocs API?
The Problem with Traditional PDF APIs
Adobe PDF Services API: $25,000-$55,000/year PDFtron: Enterprise pricing (typically $10k-$50k+) ILovePDF API: $6/1000 requests PDF.co: $99/month for 5,000 API calls
The OnlyDocs Solution
Business Tier: $29.99/month
- Unlimited API requests
- 30+ endpoints
- 100 requests/minute rate limit
- No per-request fees
- 94-99% cost savings
ROI Example:
- 1 million API calls/month
- OnlyDocs: $29.99
- ILovePDF: $6,000
- Savings: $5,970/month ($71,640/year)
Getting Started
1. Sign Up for Business Tier
# Visit onlydocs.net
# Click "Pricing" → "Business" → "Upgrade"
# Complete payment ($29.99/month)
2. Generate API Key
# Navigate to Settings → API Keys
# Click "Generate New Key"
# Copy your key: od_xxxxxxxxxxxxxxxxxx
# Store securely (never commit to git!)
3. Test Your First Request
const response = await fetch('https://api.onlydocs.net/v1/editor/merge', {
method: 'POST',
headers: {
'Authorization': 'Bearer od_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
pdfs: [pdfBase64_1, pdfBase64_2]
})
});
const result = await response.json();
console.log(result.data.pdfBase64); // Merged PDF
Core API Categories
1. PDF Editing (/api/v1/editor/*)
Merge PDFs
POST /editor/merge
Combine multiple PDFs into one
Split PDFs
POST /editor/split
Split PDF by page ranges or extract specific pages
Rotate Pages
POST /editor/rotate
Rotate pages 90°, 180°, or 270°
Reorder Pages
POST /editor/reorder
Rearrange page order
Delete Pages
POST /editor/delete-pages
Remove specific pages
Add Blank Pages
POST /editor/add-blank-pages
Insert blank pages at specified positions
Compress PDF
POST /editor/compress
Reduce file size while maintaining quality
Extract Text
POST /editor/extract-text
Pull text content from PDF
Extract Images
POST /editor/extract-images
Get all images from PDF
Extract Tables
POST /editor/extract-tables
Convert PDF tables to JSON/CSV
Page Info
POST /editor/page-info
Get page count, dimensions, metadata
Metadata
POST /editor/metadata
Read/write PDF metadata (title, author, etc.)
Flatten Forms
POST /editor/flatten
Convert fillable forms to static content
Fill Forms
POST /editor/fill-form
Programmatically fill PDF form fields
2. Conversions (/api/v1/convert/*)
HTML to PDF
POST /convert/html-to-pdf
Convert HTML string or URL to PDF
URL to PDF
POST /convert/url-to-pdf
Capture web pages as PDFs
Images to PDF
POST /editor/images-to-pdf
Combine JPG/PNG images into PDF
PDF to Images
POST /convert/pdf-to-image
Export each page as PNG/JPG
PDF to DOCX
POST /convert/pdf-to-docx
Convert to Microsoft Word format
PDF to HTML
POST /convert/pdf-to-html
Export as HTML document
PDF to Text
POST /convert/pdf-to-txt
Extract plain text
PDF to Excel
POST /convert/pdf-to-xlsx
Convert tables to spreadsheet
OCR (Optical Character Recognition)
POST /convert/ocr
Extract text from scanned documents/images
3. Document Operations (/api/v1/editor/*)
Rotate Pages
POST /editor/rotate
Rotate pages clockwise/counterclockwise
Delete Pages
POST /editor/delete-pages
Remove specified pages from PDF
Reorder Pages
POST /editor/reorder
Change page sequence
4. Async Jobs (/api/v1/async/*)
For large files or batch operations:
POST /async/html-to-pdf # Start async job
GET /async/jobs/{jobId} # Check status
GET /async/jobs # List all jobs
Real-World Use Cases
Use Case 1: Invoice Generation SaaS
// Generate 1000 invoices from templates
async function generateInvoices(customers) {
const invoices = await Promise.all(
customers.map(customer =>
fetch('https://api.onlydocs.net/v1/convert/html-to-pdf', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ONLYDOCS_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
html: generateInvoiceHTML(customer),
options: {
format: 'A4',
margin: { top: '20mm', bottom: '20mm' }
}
})
}).then(r => r.json())
)
);
return invoices; // Array of PDF base64 strings
}
Cost with OnlyDocs: $29.99/month Cost with ILovePDF: $6/1000 = $6.00 Monthly at 100k invoices: OnlyDocs $29.99 vs ILovePDF $600
Use Case 2: Document Processing Pipeline
// OCR → Extract Tables → Convert to Excel
async function processDocument(pdfBase64) {
// Step 1: OCR scanned document
const ocrResult = await fetch('https://api.onlydocs.net/v1/convert/ocr', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ pdfBase64, language: 'eng' })
}).then(r => r.json());
// Step 2: Extract tables
const tables = await fetch('https://api.onlydocs.net/v1/editor/extract-tables', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ pdfBase64: ocrResult.data.pdfBase64 })
}).then(r => r.json());
// Step 3: Convert to Excel
const xlsx = await fetch('https://api.onlydocs.net/v1/convert/pdf-to-xlsx', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ pdfBase64: ocrResult.data.pdfBase64 })
}).then(r => r.json());
return xlsx.data;
}
Use Case 3: Compliance Document Generator
// Merge contracts and compress for distribution
async function generateCompliancePackage(documents) {
// Merge all documents
const merged = await fetch('https://api.onlydocs.net/v1/editor/merge', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ pdfs: documents })
}).then(r => r.json());
// Compress for easy distribution
const compressed = await fetch('https://api.onlydocs.net/v1/editor/compress', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
pdfBase64: merged.data.pdfBase64,
compressionLevel: 'high'
})
}).then(r => r.json());
return compressed.data.pdfBase64;
}
API Best Practices
1. Error Handling
async function callAPI(endpoint, body) {
try {
const response = await fetch(`https://api.onlydocs.net/v1${endpoint}`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
if (!response.ok) {
const error = await response.json();
throw new Error(`API Error: ${error.message}`);
}
return await response.json();
} catch (err) {
console.error('OnlyDocs API failed:', err);
throw err;
}
}
2. Rate Limiting
// Batch requests with rate limiting (100 req/min)
const rateLimit = require('p-ratelimit');
const limit = rateLimit({
interval: 60 * 1000, // 60 seconds
rate: 100, // 100 requests
concurrency: 10 // 10 concurrent requests
});
async function processBatch(items) {
return await Promise.all(
items.map(item =>
limit(() => callAPI('/editor/merge', item))
)
);
}
3. Large Files (Use Async)
// For PDFs > 10MB, use async endpoints
async function processLargeFile(pdfBase64) {
// Start job
const job = await fetch('https://api.onlydocs.net/v1/async/html-to-pdf', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ html: largeHTML })
}).then(r => r.json());
// Poll for completion
let status = 'processing';
while (status === 'processing') {
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2s
const result = await fetch(`https://api.onlydocs.net/v1/async/jobs/${job.data.jobId}`, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
}).then(r => r.json());
status = result.data.status;
if (status === 'completed') {
return result.data.result;
}
}
}
Security Best Practices
1. Store API Keys Securely
# Environment variables (never commit!)
ONLYDOCS_API_KEY=od_xxxxxxxxxxxx
# .gitignore
.env
.env.local
// Use dotenv or similar
require('dotenv').config();
const API_KEY = process.env.ONLYDOCS_API_KEY;
2. Use Server-Side Only
// ❌ BAD - Exposes API key to client
fetch('https://api.onlydocs.net/v1/editor/merge', {
headers: { 'Authorization': `Bearer od_xxxxx` } // Visible in browser!
});
// ✅ GOOD - Keep on backend
// Backend API route
app.post('/api/merge-pdfs', async (req, res) => {
const result = await fetch('https://api.onlydocs.net/v1/editor/merge', {
headers: { 'Authorization': `Bearer ${process.env.ONLYDOCS_API_KEY}` }
});
res.json(result);
});
3. Validate Input
function validatePDFBase64(str) {
// Check if valid base64
if (!/^[A-Za-z0-9+/=]+$/.test(str)) {
throw new Error('Invalid PDF base64');
}
// Check reasonable size (e.g., < 50MB)
if (str.length > 50 * 1024 * 1024) {
throw new Error('PDF too large');
}
return true;
}
Performance Optimization
1. Compress PDFs Before Upload
// Compress before sending if possible
const compressed = await fetch('https://api.onlydocs.net/v1/editor/compress', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
pdfBase64: largePDF,
compressionLevel: 'medium'
})
}).then(r => r.json());
2. Cache Results
const NodeCache = require('node-cache');
const cache = new NodeCache({ stdTTL: 3600 }); // 1 hour
async function getCachedMerge(pdfArray) {
const cacheKey = hashPDFs(pdfArray);
const cached = cache.get(cacheKey);
if (cached) return cached;
const result = await callAPI('/editor/merge', { pdfs: pdfArray });
cache.set(cacheKey, result);
return result;
}
Pricing Comparison
| Provider | Pricing | 1M requests/mo |
|---|---|---|
| OnlyDocs | $29.99/mo unlimited | $29.99 |
| Adobe PDF Services | $0.05-0.10/call | $50,000-$100,000 |
| PDFtron | Enterprise | $10,000-$50,000+ |
| ILovePDF API | $6/1000 calls | $6,000 |
| PDF.co | $99/mo (5k calls) | $19,800 |
Support & Resources
- API Documentation: api.onlydocs.net/docs
- Status Page: status.onlydocs.net
- Priority Support: Business tier includes 24h response time
- Code Examples: GitHub repo with samples in JS, Python, PHP, Ruby
Getting Started Today
- Upgrade to Business: Visit onlydocs.net/pricing
- Generate API Key: Dashboard → Settings → API Keys
- Read Full Docs: api.onlydocs.net/docs
- Build Your Integration: Start with the examples above
- Deploy: No rate limits, no surprises
The Bottom Line
OnlyDocs API gives you enterprise-grade PDF processing at consumer pricing. Whether you're generating 100 or 1,000,000 PDFs per month, you pay the same $29.99.
No per-request fees. No overage charges. No enterprise sales calls.
Ready to save 94-99% on your PDF API costs? Upgrade to Business tier today.
Keywords: PDF API, document processing API, PDF automation, Adobe PDF Services alternative, PDFtron alternative, REST API PDF, developer tools, OnlyDocs API