API Integration

Getting Your API Key

1

Log into Dashboard

Visit your account dashboard at peedief.com
2

Navigate to API Keys

Find the API section in the main menu
3

Generate Key

Click “Generate New API Key”
4

Name Your Key

Give it a descriptive name (e.g., “My Website Integration”)
5

Copy & Store

Securely save your API key immediately

Basic API Usage

Simple PDF Generation

Endpoint: POST https://peedief.com/api/pdf Headers:
x-api-key: YOUR_API_KEY
Content-Type: application/json
Basic Request:
{
  "html": "<html><body><h1>Hello World</h1><p>This is my first PDF!</p></body></html>",
  "fileName": "my-first-pdf.pdf"
}
Response:
{
  "success": true,
  "downloadUrl": "https://storage.../your-pdf.pdf",
  "fileName": "my-first-pdf.pdf",
  "fileSize": 12345
}

Advanced Options

Control PDF formatting with additional options:
{
  "html": "Your HTML content here",
  "options": {
    "format": "A4",
    "landscape": false,
    "printBackground": true,
    "margin": {
      "top": "20mm",
      "bottom": "20mm",
      "left": "15mm",
      "right": "15mm"
    },
    "scale": 1.0
  },
  "fileName": "professional-document.pdf"
}

Available Options

  • format: A4, A3, Letter, or custom dimensions
  • landscape: true/false for orientation
  • printBackground: Include CSS backgrounds and images
  • margin: Control page margins (top, bottom, left, right)
  • scale: Zoom level from 0.1 to 2.0

Integration Examples

Website Integration

Add “Save as PDF” functionality to your website:
<!-- Add a button to your webpage -->
<button id="save-pdf" onclick="generatePDF()">Save as PDF</button>

<script>
async function generatePDF() {
  // Get the HTML content you want to convert
  const htmlContent = document.documentElement.outerHTML;
  
  const response = await fetch('https://peedief.com/api/pdf', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      html: htmlContent,
      fileName: 'webpage-export.pdf',
      options: {
        format: 'A4',
        printBackground: true
      }
    })
  });
  
  const result = await response.json();
  
  if (result.success) {
    // Open download link
    window.open(result.downloadUrl, '_blank');
  } else {
    alert('Error generating PDF: ' + result.error);
  }
}
</script>

Node.js Integration

Server-side PDF generation:
const axios = require('axios');

async function generatePDF(htmlContent, options = {}) {
  try {
    const response = await axios.post('https://peedief.com/api/pdf', {
      html: htmlContent,
      fileName: options.fileName || 'document.pdf',
      options: {
        format: options.format || 'A4',
        landscape: options.landscape || false,
        printBackground: options.printBackground !== false,
        ...options.pdfOptions
      }
    }, {
      headers: {
        'x-api-key': `Bearer ${process.env.PEEDIEF_API_KEY}`,
        'Content-Type': 'application/json'
      }
    });

    return response.data;
  } catch (error) {
    console.error('PDF generation failed:', error.response?.data || error.message);
    throw error;
  }
}

// Usage
const result = await generatePDF('<html><body><h1>Hello</h1></body></html>', {
  fileName: 'my-document.pdf',
  format: 'A4',
  landscape: false
});

console.log('PDF generated:', result.downloadUrl);

Python Integration

import requests
import os

def generate_pdf(html_content, file_name="document.pdf", options=None):
    if options is None:
        options = {}
    
    payload = {
        "html": html_content,
        "fileName": file_name,
        "options": {
            "format": options.get("format", "A4"),
            "landscape": options.get("landscape", False),
            "printBackground": options.get("printBackground", True),
            **options.get("pdfOptions", {})
        }
    }
    
    headers = {
        "x-api-key": f"Bearer {os.getenv('PEEDIEF_API_KEY')}",
        "Content-Type": "application/json"
    }
    
    response = requests.post(
        "https://peedief.com/api/pdf",
        json=payload,
        headers=headers
    )
    
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"PDF generation failed: {response.text}")

# Usage
html = "<html><body><h1>Python Generated PDF</h1></body></html>"
result = generate_pdf(html, "python-doc.pdf", {
    "format": "A4",
    "landscape": False
})

print(f"PDF available at: {result['downloadUrl']}")

No-Code Tools Integration

Zapier Integration

1

Create New Zap

Start a new automation in Zapier
2

Add Webhook Action

Use “Webhooks by Zapier” as your action
3

Configure Action Event

Action event: POST
4

Set URL

URL: https://peedief.com/api/pdf
5

Configure Payload

  • Payload Type: Json
  • Data:
    • html: <html><body><h1>Hello, PDF!</h1></body></html>
6

Add Headers

Headers:
  • x-api-key: YOUR_API_KEY

Make.com Integration

1

Add HTTP Module

Create a new scenario and add “HTTP > Make a request” module
2

Configure URL

URL: https://peedief.com/api/pdf
3

Set Method

Method: POST
4

Add Header

  • Name: x-api-key
  • Value: YOUR_API_KEY
5

Configure Body

  • Body type: Raw
  • Content type: application/json
  • Request content: { "html": "<html><body><h1>Hello, PDF!</h1></body></html>" }
6

Save

Save your configuration to complete the setup

Error Handling

Always implement proper error handling:
async function generatePDFWithErrorHandling(html, options) {
  try {
    const response = await fetch('https://peedief.com/api/pdf', {
      method: 'POST',
      headers: {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ html, options })
    });

    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${response.statusText}`);
    }

    const result = await response.json();
    
    if (!result.success) {
      throw new Error(result.error || 'PDF generation failed');
    }

    return result;
  } catch (error) {
    console.error('PDF Generation Error:', error);
    // Handle error appropriately for your application
    throw error;
  }
}

Rate Limits

Respect API rate limits to ensure reliable service:
  • Free Plan: 5 requests per minute
  • Paid Plans: Up to 60 requests per minute
  • Enterprise: Custom limits available
Implement rate limiting in your applications to avoid hitting these limits.

Next Steps