Zum Hauptinhalt springen

API-Referenz

Leistungsstarkes, einfaches RESTful API – implementieren Sie die professionelle Konvertierung von PDF in eBooks in nur wenigen Codezeilen

API-Anfragen

Basis-URL:
https://fusion-api.oomol.com/v1
POST/pdf-transform-markdown/submit

PDF-zu-Markdown-Aufgabe senden

Laden Sie die URL der PDF-Datei hoch und senden Sie die Aufgabe zur Konvertierung in das Markdown-Format

Anforderungsparameter

  • pdfURL - PDF-Datei-Cloud-URL (Zeichenfolge, erforderlich, erhalten von der Datei-Upload-API)
  • model - Konvertierungsmodell (Zeichenfolge, erforderlich, fester Wert: „gundam“)
  • filename - Name der Ausgabedatei ohne Erweiterung (optional), wird zur einfacheren Dateierkennung verwendet
  • ignore_pdf_errors - PDF-Parsing-Fehler ignorieren (optional, Standard: true)
  • ignore_ocr_errors - OCR-Fehler ignorieren (optional, Standard: true)

Beispielanfrage

{
  "pdfURL": "https://pdfcraft.ai/examples/api-quickstart.pdf",
  "model": "gundam",
  "filename": "my-document",
  "ignore_pdf_errors": true,
  "ignore_ocr_errors": true
}

Antwortbeispiel

{
  "success": true,
  "sessionID": "019aa097-f28d-7000-8d56-6a2987a7b144"
}
GET/pdf-transform-markdown/result/:taskId

PDF-zu-Markdown-Ergebnis abfragen

Status und Ergebnis der Konvertierungsaufgabe nach Aufgaben-ID abfragen

URL-Parameter

  • taskId - Aufgaben-ID (von der Submit-API zurückgegebene Sitzungs-ID)

Antwortbeispiel (Verarbeitung)

{
  "success": true,
  "state": "processing",
  "progress": 66
}

Antwortbeispiel (abgeschlossen)

{
  "success": true,
  "state": "completed",
  "progress": 100,
  "data": {
    "downloadURL": "https://cdn.oomol.com/result.md"
  }
}

Antwortbeispiel (fehlgeschlagen)

{
  "success": false,
  "state": "failed",
  "progress": 0,
  "error": "Grund für den Konvertierungsfehler"
}
POST/pdf-transform-epub/submit

PDF-zu-EPUB-Aufgabe senden

Laden Sie die URL der PDF-Datei hoch und senden Sie die Aufgabe zur Konvertierung in das EPUB-Format

Anforderungsparameter

  • pdfURL - PDF-Datei-Cloud-URL (Zeichenfolge, erforderlich, erhalten von der Datei-Upload-API)
  • model - Konvertierungsmodell (Zeichenfolge, erforderlich, fester Wert: „gundam“)
  • filename - Name der Ausgabedatei ohne Erweiterung (optional), wird zur einfacheren Dateierkennung verwendet
  • ignore_pdf_errors - PDF-Parsing-Fehler ignorieren (optional, Standard: true)
  • ignore_ocr_errors - OCR-Fehler ignorieren (optional, Standard: true)

Beispielanfrage

{
  "pdfURL": "https://pdfcraft.ai/examples/api-quickstart.pdf",
  "model": "gundam",
  "filename": "my-document",
  "ignore_pdf_errors": true,
  "ignore_ocr_errors": true
}

Antwortbeispiel

{
  "success": true,
  "sessionID": "019aa097-f28d-7000-8d56-6a2987a7b144"
}
GET/pdf-transform-epub/result/:taskId

PDF-zu-EPUB-Ergebnis abfragen

Status und Ergebnis der Konvertierungsaufgabe nach Aufgaben-ID abfragen

URL-Parameter

  • taskId - Aufgaben-ID (von der Submit-API zurückgegebene Sitzungs-ID)

Antwortbeispiel (Verarbeitung)

{
  "success": true,
  "state": "processing",
  "progress": 66
}

Antwortbeispiel (abgeschlossen)

{
  "success": true,
  "state": "completed",
  "progress": 100,
  "data": {
    "downloadURL": "https://cdn.oomol.com/result.epub"
  }
}

Antwortbeispiel (fehlgeschlagen)

{
  "success": false,
  "state": "failed",
  "progress": 0,
  "error": "Grund für den Konvertierungsfehler"
}

cURL

# 1. Submit PDF to Markdown task
curl -X POST https://fusion-api.oomol.com/v1/pdf-transform-markdown/submit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"pdfURL": "https://pdfcraft.ai/examples/api-quickstart.pdf",
"model": "gundam",
"filename": "my-document"
}'
# Response: {"success": true, "sessionID": "019aa097-f28d-7000-8d56-6a2987a7b144"}
# 2. Query conversion result
curl -X GET https://fusion-api.oomol.com/v1/pdf-transform-markdown/result/019aa097-f28d-7000-8d56-6a2987a7b144 \
-H "Authorization: Bearer YOUR_API_KEY"
# Response: {"success": true, "state": "completed", "data": {"downloadURL": "https://cdn.oomol.com/result.md"}}

Python-SDK

Ein Python-SDK für die Interaktion mit der PDF Craft-API. Es vereinfacht den Prozess der Konvertierung von PDFs in Markdown oder EPUB durch die Handhabung der Authentifizierung, Aufgabenübermittlung und Ergebnisabfrage.

Ansicht auf GitHub

Installation

pip install pdf-craft-sdk

Grundlegende Verwendung

from pdf_craft_sdk import PDFCraftClient
# Initialize the client
client = PDFCraftClient(api_key="YOUR_API_KEY")
# Convert a local PDF to Markdown
try:
download_url = client.convert_local_pdf("document.pdf")
print(f"Conversion successful! Download URL: {download_url}")
except Exception as e:
print(f"An error occurred: {e}")

Lokaler Datei-Upload mit Fortschrittsverfolgung

from pdf_craft_sdk import PDFCraftClient, UploadProgress
def on_progress(progress: UploadProgress):
print(f"Upload: {progress.percentage:.2f}% - Part {progress.current_part}/{progress.total_parts}")
client = PDFCraftClient(api_key="YOUR_API_KEY")
# Upload local file with progress tracking
download_url = client.convert_local_pdf(
"large_document.pdf",
progress_callback=on_progress
)

Remote-PDF-Konvertierung

from pdf_craft_sdk import PDFCraftClient, FormatType
client = PDFCraftClient(api_key="YOUR_API_KEY")
# Convert remote PDF to EPUB
download_url = client.convert(
pdf_url="https://example.com/file.pdf",
format_type=FormatType.EPUB,
includes_footnotes=True
)
print(f"Download URL: {download_url}")

Erweiterte Nutzung (Schritt für Schritt)

from pdf_craft_sdk import PDFCraftClient, FormatType
client = PDFCraftClient(api_key="YOUR_API_KEY")
# Step 1: Upload file
cache_url = client.upload_file("document.pdf")
# Step 2: Submit conversion task
task_id = client.submit_conversion(
cache_url,
format_type=FormatType.MARKDOWN
)
print(f"Task submitted. ID: {task_id}")
# Step 3: Wait for completion
download_url = client.wait_for_completion(task_id)
print(f"Download URL: {download_url}")

Konfigurationsoptionen

  • max_wait_ms: Maximale Wartezeit in Millisekunden (Standard: 7200000, also 2 Stunden)
  • check_interval_ms: Anfängliches Abfrageintervall in Millisekunden (Standard: 1000)
  • max_check_interval_ms: Maximales Abfrageintervall in Millisekunden (Standard: 5000)
  • backoff_factor: Multiplikator für zunehmendes Intervall, oder verwenden Sie PollingStrategy enum (Standard: PollingStrategy.EXPONENTIAL / 1,5)
  • Modell: Das für die Konvertierung zu verwendende Modell (Standard: „gundam“)
from pdf_craft_sdk import PDFCraftClient, FormatType, PollingStrategy
client = PDFCraftClient(api_key="YOUR_API_KEY")
# Example with custom polling configuration
download_url = client.convert(
pdf_url="https://example.com/file.pdf",
format_type=FormatType.MARKDOWN,
model="gundam",
includes_footnotes=True,
ignore_pdf_errors=True,
ignore_ocr_errors=True,
max_wait_ms=600000, # Maximum wait time: 10 minutes
check_interval_ms=2000, # Initial polling interval: 2 seconds
max_check_interval_ms=10000, # Maximum polling interval: 10 seconds
backoff_factor=PollingStrategy.EXPONENTIAL # or 1.5
)

TypeScript-SDK

Ein TypeScript-SDK für die Interaktion mit der PDF Craft-API. Es vereinfacht den Prozess der Konvertierung von PDFs in Markdown oder EPUB durch die Handhabung der Authentifizierung, Aufgabenübermittlung und Ergebnisabfrage.

Ansicht auf GitHub

Installation

npm install pdf-craft-sdk-ts
# or
yarn add pdf-craft-sdk-ts

Grundlegende Verwendung

import { PDFCraftClient, FormatType } from 'pdf-craft-sdk-ts';
const client = new PDFCraftClient("YOUR_API_KEY");
async function main() {
try {
const downloadUrl = await client.convert("cache://your-pdf-file.pdf", {
formatType: FormatType.Markdown
});
console.log(`Success! Download: ${downloadUrl}`);
} catch (error) {
console.error("Error:", error);
}
}
main();

Lokaler Datei-Upload mit Fortschrittsverfolgung

import { PDFCraftClient, FormatType, UploadProgress } from 'pdf-craft-sdk-ts';
const client = new PDFCraftClient("YOUR_API_KEY");
const onProgress = (progress: UploadProgress) => {
console.log(`Progress: ${progress.percentage.toFixed(2)}%`);
console.log(`Part ${progress.currentPart}/${progress.totalParts}`);
};
// Upload and convert local file
const downloadUrl = await client.convertLocalPdf("document.pdf", {
formatType: FormatType.Markdown,
progressCallback: onProgress,
includesFootnotes: true,
uploadMaxRetries: 5
});

Batch Verarbeitung

import { PDFCraftClient, FormatType } from 'pdf-craft-sdk-ts';
const client = new PDFCraftClient("YOUR_API_KEY");
// Create batch conversion
const files = [
{ url: "cache://file1.pdf", fileName: "document1.pdf" },
{ url: "cache://file2.pdf", fileName: "document2.pdf" }
];
const batch = await client.createBatch(files, FormatType.Markdown, false);
const result = await client.startBatch(batch.batchId);
// Monitor progress
const status = await client.getBatchStatus(batch.batchId);
console.log(`Completed: ${status.completedCount}/${status.totalCount}`);

Erweiterte Nutzung (Schritt für Schritt)

import { PDFCraftClient, FormatType } from 'pdf-craft-sdk-ts';
const client = new PDFCraftClient("YOUR_API_KEY");
// Step 1: Submit task
const taskId = await client.submitConversion(
"cache://file.pdf",
FormatType.Markdown
);
console.log(`Task submitted. ID: ${taskId}`);
// Step 2: Poll for completion
const downloadUrl = await client.waitForCompletion(
taskId,
FormatType.Markdown
);
console.log(`Download URL: ${downloadUrl}`);

Konfigurationsoptionen

  • formatType: FormatType.Markdown | FormatType.EPUB (Standard: FormatType.Markdown)
  • model: Zu verwendendes Modell (Standard: 'gundam')
  • warten: Ob auf den Abschluss gewartet werden soll (Standard: true)
  • maxWaitMs: Maximale Wartezeit in Millisekunden (Standard: 7200000, also 2 Stunden)
  • checkIntervalMs: Anfängliches Abfrageintervall in Millisekunden (Standard: 1000)
  • maxCheckIntervalMs: Maximales Abfrageintervall in Millisekunden (Standard: 5000)
  • backoffFactor: Multiplikator für zunehmendes Intervall, oder verwenden Sie PollingStrategy enum (Standard: PollingStrategy.Exponential / 1,5)
import { PDFCraftClient, FormatType, PollingStrategy } from 'pdf-craft-sdk-ts';
const client = new PDFCraftClient("YOUR_API_KEY");
// Example with custom polling configuration
const downloadUrl = await client.convert("cache://file.pdf", {
formatType: FormatType.Markdown,
model: "gundam",
wait: true,
includesFootnotes: true,
ignorePdfErrors: true,
ignoreOcrErrors: true,
maxWaitMs: 600000, // Maximum wait time: 10 minutes
checkIntervalMs: 2000, // Initial polling interval: 2 seconds
maxCheckIntervalMs: 10000, // Maximum polling interval: 10 seconds
backoffFactor: PollingStrategy.Exponential // or use a number like 1.5
});