❤️myPDF.AI API Documentation

Extract data from PDFs, images, and URLs using our powerful REST API. Our artificial intelligence processes documents of any complexity with unmatched precision.

🚀 Quick Start

Start extracting data in less than 5 minutes:

  1. Get your access token
  2. Make your first request
  3. Receive structured data

🌐 Base URL

https://api.mypdf-ai.com

📁 Supported Formats

  • PDFs: All types, including scanned documents
  • Images: PNG, JPG, JPEG, GIF, BMP, TIFF
  • URLs: Direct links to PDFs or images

🔐 Authentication

🔑 Access Token

All requests must include your access token in the access_token header. You receive this token after purchase.

curl --location 'https://api.mypdf-ai.com/api/pdf' \
--header 'access_token: YOUR_TOKEN_HERE' \
--form 'pdf=@"document.pdf"'

📄 PDF Extraction

POST /api/pdf

Extracts structured data from PDF files, including text, tables, and metadata.

Parameters

Name Type Required Description
pdf file Required PDF file for processing
access_token string Required Authentication token in header
curl --location 'https://api.mypdf-ai.com/api/pdf' \
--header 'access_token: YOUR_TOKEN_HERE' \
--form 'pdf=@"document.pdf"'

🖼️ Image Extraction

POST /api/image

Extracts text and data from images using advanced OCR with artificial intelligence.

Parameters

Name Type Required Description
image file Required Image file (PNG, JPG, JPEG, GIF, BMP, TIFF)
access_token string Required Authentication token in header
curl --location 'https://api.mypdf-ai.com/api/image' \
--header 'access_token: YOUR_TOKEN_HERE' \
--form 'image=@"document.png"'

🔗 URL Extraction

POST /api/url

Extracts data from files hosted on public URLs. Supports PDFs and images.

Parameters

Name Type Required Description
url string Required Public URL of the file for processing
type string Required File type: "pdf" or "image"
access_token string Required Authentication token in header
curl --location 'https://api.mypdf-ai.com/api/url' \
--header 'Content-Type: application/json' \
--header 'access_token: YOUR_TOKEN_HERE' \
--data '{
    "url": "https://example.com/document.pdf",
    "type": "pdf"
}'

📋 Response Format

All responses are returned in JSON format with the following structure:

✅ Success Response (200)
{
    "success": true,
    "data": {
        "text": "Extracted text from document...",
        "pages": 5,
        "metadata": {
            "title": "Document Title",
            "author": "Author",
            "creation_date": "2024-01-15"
        },
        "tables": [
            {
                "page": 1,
                "data": [
                    ["Column 1", "Column 2"],
                    ["Value 1", "Value 2"]
                ]
            }
        ]
    },
    "processing_time": "2.3s",
    "credits_used": 5
}
❌ Error Response (400/401/500)
{
    "success": false,
    "error": {
        "code": "INVALID_TOKEN",
        "message": "Invalid or expired access token"
    }
}

⚠️ Error Codes

HTTP Code Error Code Description
400 INVALID_FILE Invalid or corrupted file
400 FILE_TOO_LARGE File exceeds size limit
400 INVALID_URL Invalid or inaccessible URL
401 INVALID_TOKEN Invalid or expired access token
402 INSUFFICIENT_CREDITS Insufficient credits to process
429 RATE_LIMIT_EXCEEDED Request rate limit exceeded
500 PROCESSING_ERROR Internal processing error

💡 Practical Examples

Invoice Processing

Example of how to process an invoice PDF and extract structured information:

# Invoice processing using cURL
curl --location 'https://api.mypdf-ai.com/api/pdf' \
--header 'access_token: your_token_here' \
--form 'pdf=@"invoice.pdf"'

# Expected response:
# {
#   "success": true,
#   "data": {
#     "text": "Extracted text from invoice...",
#     "tables": [...],
#     "pages": 2,
#     "metadata": {...}
#   },
#   "processing_time": "1.2s",
#   "credits_used": 2
# }

Batch Processing

Example of how to efficiently process multiple documents:

# Batch processing using cURL in bash
#!/bin/bash

TOKEN="your_token_here"
PDF_DIR="./pdfs_to_process"

echo "Processing PDFs from directory: $PDF_DIR"

# Success and failure counters
SUCCESS_COUNT=0
FAIL_COUNT=0

# Loop through all PDFs
for pdf_file in "$PDF_DIR"/*.pdf; do
    if [ -f "$pdf_file" ]; then
        echo "Processing: $(basename "$pdf_file")"
        
        # Make cURL request
        response=$(curl -s -w "%{http_code}" --location 'https://api.mypdf-ai.com/api/pdf' \
            --header "access_token: $TOKEN" \
            --form "pdf=@\"$pdf_file\"")
        
        # Extract HTTP code (last 3 characters)
        http_code="${response: -3}"
        response_body="${response%???}"
        
        if [ "$http_code" -eq 200 ]; then
            echo "✅ $(basename "$pdf_file") - Processed successfully"
            SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
        else
            echo "❌ $(basename "$pdf_file") - HTTP Error: $http_code"
            FAIL_COUNT=$((FAIL_COUNT + 1))
        fi
        
        # Pause to respect rate limits
        sleep 0.5
    fi
done

echo ""
echo "📊 Summary:"
echo "Total: $((SUCCESS_COUNT + FAIL_COUNT))"
echo "Successes: $SUCCESS_COUNT"
echo "Failures: $FAIL_COUNT"

Need Help?

Our team is ready to help you integrate the ❤️myPDF.AI API

Technical Support More Examples