開發者 API

適用於每種檔案工作流程的單一通用 API

Converter App 為開發者提供高效能的檔案處理介面。以單一 API 取代分散工具,實現可擴充的文件轉換、媒體處理、轉錄與 OCR。

Converter App API 概覽

Converter App API 為開發者提供無縫、通用的介面,滿足各種檔案處理需求。您的應用程式不必整合零散分散的多個工具,而是可以呼叫單一的高效能服務。您可以將我們完整的轉換工具套件直接整合到後端工作流程中,處理從標準檔案轉換到高要求媒體任務的各種工作。

公開的基礎 URL 為 https://api.converter.app/。本文檔中的路徑皆使用此對外提供的 API 根目錄。

全面涵蓋

透過一個簡化整合,即可使用完整的轉換工具庫。

兩種處理模式

若要立即回應,請選擇同步請求;若是大型檔案和長時間執行的工作,請選擇非同步工作。

根據您的需求量身打造

與我們聯絡,我們可以以無與倫比的價格為您提供量身打造的方案。

文件 圖片 音訊 影片 文字 壓縮檔案

探索支援的轉換(無需金鑰)

使用公開 pairs 端點作為最簡單的連線測試。這不需要 API 金鑰,並會回傳平台上可用的完整支援轉換配對清單。

GET /public/pairs

此端點是開放的,因此開發者在申請或設定 API 金鑰之前,可以先檢視通用轉換目錄。

curl "https://api.converter.app/public/pairs"

JavaScript

const response = await fetch('https://api.converter.app/public/pairs');
const pairs = await response.json();
console.log(pairs.supported_pairs);

Python

import requests

response = requests.get('https://api.converter.app/public/pairs')
response.raise_for_status()
pairs = response.json()
print(pairs['supported_pairs'])

範例回應

{
  "supported_pairs": [
    { "from": "mp3", "to": "text" },
    { "from": "mp4", "to": "mp3" },
    { "from": "mov", "to": "mp4" },
    { "from": "wav", "to": "mp3" },
    { "from": "mkv", "to": "mp4" }
  ]
}

驗證與存取控制

開發者可透過在 HTTP 標頭 X API Key 中傳遞其 API 金鑰進行驗證。公開的 /public/pairs 端點是本頁唯一不需要金鑰的端點。

控制運作方式開發者影響
X-API-Key將金鑰作為 HTTP 請求標頭傳送。/pairs/convert/sync/convert/progress/{jobid}/download/{jobid} 所需。
使用配額每個金鑰都有數值轉換配額。建立轉換任務時,配額會減少。-1 的配額表示可無限次轉換。其他值則代表剩餘可用的轉換次數。
允許的配對金鑰可以限制為特定的轉換類型,例如 mp42mp3,或授予對 all 支援組合的存取權。/pairs 只會回傳您的金鑰獲授權可使用的格式配對,超出該清單的轉換請求將會被拒絕。
curl "https://api.converter.app/pairs" \
  -H "X-API-Key: YOUR_API_KEY"

JavaScript

const response = await fetch('https://api.converter.app/pairs', {
  headers: {
    'X-API-Key': apiKey
  }
});

const pairs = await response.json();
console.log(pairs);

Python

import requests

headers = {'X-API-Key': 'YOUR_API_KEY'}
response = requests.get('https://api.converter.app/pairs', headers=headers)
response.raise_for_status()
print(response.json())

2. 同步轉換

POST /convert/sync

當您希望在同一個 HTTP 回應中立即取得結果時,請使用同步轉換。請求會保持開啟,直到 API 啟動轉換工作並等待完成,最長可達 30 分鐘。

表單欄位類型說明
target_format字串所要求的輸出副檔名,例如 pdfdocxmp3jpg
filesfile[]一個或多個已上傳的來源檔案。API 會根據已上傳的檔案名稱判定來源格式。
curl -X POST "https://api.converter.app/convert/sync" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "target_format=pdf" \
  -F "files=@/path/to/document.docx" \
  -o converted.pdf

JavaScript

const form = new FormData();
form.append('target_format', 'pdf');
form.append('files', fileInput.files[0]);

const response = await fetch('https://api.converter.app/convert/sync', {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey
  },
  body: form
});

const convertedFile = await response.blob();

Python

import requests

headers = {'X-API-Key': 'YOUR_API_KEY'}
data = {'target_format': 'pdf'}

with open('/path/to/document.docx', 'rb') as document:
    files = {'files': document}
    response = requests.post(
        'https://api.converter.app/convert/sync',
        headers=headers,
        data=data,
        files=files
    )

response.raise_for_status()
with open('converted.pdf', 'wb') as output:
    output.write(response.content)

回應會直接串流轉換後的檔案。如果轉換產生多個檔案,API 會回傳 .zip 壓縮檔。

3. 非同步轉換

POST /convert

對於大型檔案、批次處理、長時間執行的音訊或影片任務,或不應在工作執行期間保持上傳請求開啟的正式應用程式,請使用非同步轉換。

表單欄位類型說明
target_format字串所需的輸出格式。來源與目標構成轉換組合,例如 mp42mp3
filesfile[]要轉換的一個或多個檔案。

cURL

curl -X POST "https://api.converter.app/convert" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "target_format=mp3" \
  -F "files=@/path/to/video.mp4"

JavaScript

const form = new FormData();
form.append('target_format', 'mp3');
form.append('files', fileInput.files[0]);

const response = await fetch('https://api.converter.app/convert', {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey
  },
  body: form
});

const job = await response.json();
console.log(job.jobid, job.remaining_quota);

Python

import requests

headers = {'X-API-Key': 'YOUR_API_KEY'}
data = {'target_format': 'mp3'}

with open('/path/to/video.mp4', 'rb') as video:
    files = {'files': video}
    response = requests.post(
        'https://api.converter.app/convert',
        headers=headers,
        data=data,
        files=files
    )

response.raise_for_status()
job = response.json()
print(job['jobid'], job['remaining_quota'])

成功回應

{
  "status": "success",
  "jobid": "b3f6b2e8f5c34c4ab01c93c4d1b2f9e8",
  "pair": "mp42mp3",
  "remaining_quota": 42
}

4. 狀態追蹤

取得 /progress/{jobid}

建立非同步工作後,請輪詢此端點。它會回傳工作狀態、從 0.01.0 的數值進度,以及若轉換失敗時的錯誤詳細資訊。

頁首說明
X-API-Key您的開發人員 API 金鑰。
curl "https://api.converter.app/progress/b3f6b2e8f5c34c4ab01c93c4d1b2f9e8" \
  -H "X-API-Key: YOUR_API_KEY"

JavaScript

const response = await fetch('https://api.converter.app/progress/b3f6b2e8f5c34c4ab01c93c4d1b2f9e8', {
  headers: {
    'X-API-Key': apiKey
  }
});

const progress = await response.json();
console.log(progress.status, progress.progress);

Python

import requests

headers = {'X-API-Key': 'YOUR_API_KEY'}
response = requests.get(
    'https://api.converter.app/progress/b3f6b2e8f5c34c4ab01c93c4d1b2f9e8',
    headers=headers
)
response.raise_for_status()
progress = response.json()
print(progress['status'], progress['progress'])
{
  "jobid": "b3f6b2e8f5c34c4ab01c93c4d1b2f9e8",
  "progress": 1.0,
  "status": "completed",
  "error": null
}

可能的狀態為 processingcompletedfailed。進度是介於 0.01.0 之間的數字。

5. 檔案擷取

取得 /download/{jobid}

一旦非同步工作達到 completed,請使用建立該工作的相同 API 金鑰擷取已轉換的輸出。

結果類型行為
單一輸出檔案API 會直接串流轉換後的檔案。
結果檔案 清單如果工作提供結果清單,API 會傳回該清單中指定的檔案。
多個輸出檔案API 會在處理時將生成的檔案打包成 .zip 壓縮檔。
curl -L "https://api.converter.app/download/b3f6b2e8f5c34c4ab01c93c4d1b2f9e8" \
  -H "X-API-Key: YOUR_API_KEY" \
  -o converted-output.zip

JavaScript

const response = await fetch('https://api.converter.app/download/b3f6b2e8f5c34c4ab01c93c4d1b2f9e8', {
  headers: {
    'X-API-Key': apiKey
  }
});

const file = await response.blob();

Python

import requests

headers = {'X-API-Key': 'YOUR_API_KEY'}
response = requests.get(
    'https://api.converter.app/download/b3f6b2e8f5c34c4ab01c93c4d1b2f9e8',
    headers=headers
)
response.raise_for_status()

with open('converted-output.zip', 'wb') as output:
    output.write(response.content)

開發者工作流程摘要

此 API 支援兩種整合模式,讓開發人員可為每個使用情境選擇合適的行為。

流程請求模式最適合用於
快速同步流程POST /convert/sync 會在同一個回應中傳回轉換後的檔案。小型檔案、命令列指令碼、原型,以及簡單的伺服器端自動化。
穩健的非同步流程POST /convert,然後輪詢 GET /progress/{jobid},接著呼叫 GET /download/{jobid}大型影片或音訊檔案、批次轉換、網頁應用程式後端,以及適合重試的正式生產系統。

非同步流程範例

# 1. Start the job
curl -X POST "https://api.converter.app/convert" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "target_format=mp3" \
  -F "files=@/path/to/video.mp4"

# 2. Poll until completed
curl "https://api.converter.app/progress/JOBID" \
  -H "X-API-Key: YOUR_API_KEY"

# 3. Download the finished output
curl -L "https://api.converter.app/download/JOBID" \
  -H "X-API-Key: YOUR_API_KEY" \
  -o result.mp3

JavaScript

const form = new FormData();
form.append('target_format', 'mp3');
form.append('files', fileInput.files[0]);

const createResponse = await fetch('https://api.converter.app/convert', {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey
  },
  body: form
});
const job = await createResponse.json();

const progressResponse = await fetch(`https://api.converter.app/progress/${job.jobid}`, {
  headers: {
    'X-API-Key': apiKey
  }
});
const progress = await progressResponse.json();

if (progress.status === 'completed') {
  const downloadResponse = await fetch(`https://api.converter.app/download/${job.jobid}`, {
    headers: {
      'X-API-Key': apiKey
    }
  });
  const result = await downloadResponse.blob();
}

Python

import requests

headers = {'X-API-Key': 'YOUR_API_KEY'}
data = {'target_format': 'mp3'}

with open('/path/to/video.mp4', 'rb') as video:
    files = {'files': video}
    create_response = requests.post(
        'https://api.converter.app/convert',
        headers=headers,
        data=data,
        files=files
    )

create_response.raise_for_status()
job = create_response.json()

progress_response = requests.get(
    f"https://api.converter.app/progress/{job['jobid']}",
    headers=headers
)
progress_response.raise_for_status()
progress = progress_response.json()

if progress['status'] == 'completed':
    download_response = requests.get(
        f"https://api.converter.app/download/{job['jobid']}",
        headers=headers
    )
    download_response.raise_for_status()
    with open('result.mp3', 'wb') as output:
        output.write(download_response.content)

錯誤回應

錯誤會以 JSON 格式回傳,並使用標準 HTTP 狀態碼,且包含 detail 欄位。

狀態常見原因
400缺少檔案、缺少 target_format、不支援的工作 ID 格式,或無效的請求輸入。
401缺少或無效的 X API Key
403API 金鑰不允許使用所要求的轉換組合。
404您要求的工作或產生的結果檔案無法取得。
409當要求下載時,轉換仍在處理中。
429API 金鑰已無剩餘配額。
500由於伺服器端處理發生錯誤,無法準備或完成轉換。
{
  "detail": "This API key is not authorized for mp42mp3 conversions."
}