跳至主要內容

此文件目前提供英文和簡體中文版本,以下顯示英文內容。

本頁內容

快速開始

Your first conversion

Convert a PDF to Markdown with the Python example.

The Transform API converts PDF files to Markdown, EPUB or translated PDF, and translates EPUB files into EPUB. Each conversion is an asynchronous task: create it, upload the source, start processing, then download the result.

Get an API key

Sign in to OOMOL Console and create an API key. Keep it on your server or in your local environment. Processing consumes account credits; check your balance and pricing before starting.

SettingValue
Base URLhttps://api.pdfcraft.ai/v1/pcc-api
AuthenticationAuthorization: Bearer YOUR_API_KEY
Request bodyJSON, except the direct file upload

This URL requires a production API key. Website cookies and credentials for other OOMOL services cannot replace it. Send the key only in the API request’s Authorization header; file uploads and downloads do not require it.

Run the Python example

You need Python 3.9 or later. No additional packages are required. Download the example script:

bash
curl --fail --show-error --location \  https://pdfcraft.ai/examples/api-quickstart.py \  --output api-quickstart.py

Set the key without putting it into the script. This command works in Bash and Zsh; input is hidden:

bash
export PDF_CRAFT_API_KEY="$(  python3 -c 'import getpass; print(getpass.getpass("API key: "))')"python3 api-quickstart.py

The script downloads our one-page sample PDF, uploads it and converts it to Markdown. It saves the task ID in pdf-craft-task.json so you can resume after an interruption.

The script checks the task periodically until it finishes or the timeout is reached. On success, it saves pdf-craft-result.zip and checks that the Markdown contains a sentence from the sample PDF. This check applies only to the supplied sample.

Markdown output is a ZIP archive, not a single .md file. Open it to read the Markdown and its accompanying resources. EPUB and PDF output are downloaded as their respective file formats.

Resume without creating another task

If the script times out or the connection is interrupted after the task ID was saved:

bash
python3 api-quickstart.py \  --resume pdf-craft-task.json \  --output pdf-craft-result.zip \  --timeout 1200

Use the same account. The script checks the existing task and continues uploading, processing or downloading as needed. A failed task is not restarted. Existing output files are not overwritten; choose a new output path if necessary.

If the state file contains creation_unknown instead of a uuid, the creation response was not confirmed. Do not delete the file and immediately rerun creation. Inspect the waiting-for-upload list to find the task before deciding to create another one.

Use your own document

The example script uses a fixed PDF and conversion parameters. For your own files, follow the cURL walkthrough, then choose conversion and translation parameters.

When integrating the API, save the task’s uuid and launch parameters. See task lifecycle for recovering interrupted requests and handling expiry. Use the API reference or download the OpenAPI specification.