logoby DIP
  • Products
  • Pricing
  • About Us
  • Resources
  • Solution
    By language
    By document
    By use case
    By technology
    language
    ArabicArabicEnglishEnglishFrenchFrenchGermanGermanHindiHindiIndonesianIndonesianItalianItalianJapaneseJapaneseJavaneseJavaneseKoreanKoreanMarathiMarathiPortuguesePortuguesePunjabiPunjabiRussianRussianSpanishSpanishTamilTamilTeluguTeluguTurkishTurkishUrduUrduVietnameseVietnameseChinese (Simplified)Chinese (Simplified)Chinese (Traditional)Chinese (Traditional)BanglaBangla
  • Solution

    arrows
    By Language
    arrows
    By Document
    arrows
    By Use Case
    arrows
    By Technology
    arrows
  • Support
    View Plans
logoby DIP
menu
blogblogBack to blog
blog

Unlock Powerful Integrations: API Integration Guide

January 14, 2026

Overview

This document describes all interfaces of the Translation Platform Open API. The Open API allows third-party systems to integrate translation services, including file translation, term library management, and memory library management.

Basic Information

  • Base URL: /api/open_api/v1
  • Request Format: application/json (except for file uploads)
  • Response Format: application/json

Authentication

All APIs require an API Key in the request header:

http
X-API-Key: your_api_key_here

Unified Response Format

json
{
    "code": 0,
    "message": "success",
    "data": {}
}
FieldTypeDescription
codeintStatus code, 0 indicates success
messagestringStatus message
dataobjectResponse data

Rate Limiting (QPS)

To ensure service stability, all APIs have rate limits:

API TypeQPS LimitDescription
File Upload5/sMaximum 5 requests per second per API Key
Submit Translation10/sMaximum 10 requests per second per API Key
Query Status10/sMaximum 10 requests per second per API Key
Get Download URL10/sMaximum 10 requests per second per API Key
Other APIs20/sMaximum 20 requests per second per API Key

When rate limit is exceeded, the API returns error code 91006 (Rate limit exceeded). Please reduce request frequency and retry.


General APIs

Get Supported Languages

Get all supported language codes and names.

Request

http
GET /api/open_api/v1/languages

Request Parameters

None

Response Data

FieldTypeDescription
languagesarrayLanguage list
languages[].codestringLanguage code
languages[].namestringLanguage name in English
totalintTotal number of languages

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "languages": [
            {"code": "zh-cn", "name": "Chinese Simplified"},
            {"code": "en", "name": "English"},
            {"code": "ja", "name": "Japanese"}
        ],
        "total": 50
    }
}

File Translation APIs

The following file translation APIs use pre-signed upload URLs. The workflow is: Create Upload URL → Upload File → Submit Translation → Poll Status (with download URL).

Create Pre-signed Upload URL

Generate a pre-signed upload URL for direct file upload to cloud storage.

Request

http
POST /api/open_api/v1/files/create_upload_url
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
filenamestringYesFilename with extension. Supported: docx, doc, pdf, pptx, ppt, xlsx, xls, txt, xml
is_can_editbooleanNoWhether PDF file is editable, default true. Set to false for scanned/image PDFs (enables OCR)

Request Example

json
{
    "filename": "report.docx",
    "is_can_edit": true
}

Response Data

FieldTypeDescription
file_idstringFile ID
upload_urlstringPre-signed upload URL
cloud_pathstringCloud storage path
expires_inintURL expiration time in seconds
content_typestringContent-Type to set when uploading

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "file_id": "12345678901234567",
        "upload_url": "https://storage.example.com/upload?token=xxx",
        "cloud_path": "uploads/12345678901234567/report.docx",
        "expires_in": 3600,
        "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
    }
}

Upload File

After obtaining the upload_url, use a PUT request to upload the file:

bash
curl -X PUT "<upload_url>" \
  -H "Content-Type: <content_type>" \
  --data-binary @report.docx

Submit File Translation

Submit a pre-signed uploaded file for translation. Validates file upload, triggers parsing, and automatically submits translation after parsing completes.

Request

http
POST /api/open_api/v1/translate/document
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
file_idintYesFile ID returned by create_upload_url (integer type)
source_languagestringYesSource language code (LanguageEnum value)
target_languagestringYesTarget language code (LanguageEnum value)
trans_modestringNoTranslation mode: deep or master, default master
term_lib_idsint[]NoList of term library IDs
memory_libsobject[]NoMemory library configuration list
memory_libs[].memory_lib_idintYesMemory library ID
memory_libs[].thresholdfloatNoMatch threshold, range 0-1, default 0.8

Request Example

json
{
    "file_id": 12345678901234567,
    "source_language": "en",
    "target_language": "zh-cn",
    "trans_mode": "master",
    "term_lib_ids": [1, 2],
    "memory_libs": [
        {"memory_lib_id": 1, "threshold": 0.8}
    ]
}

Response Data

FieldTypeDescription
file_idstringFile ID
statusstringProcessing status: parsing

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "file_id": "12345678901234567",
        "status": "parsing"
    }
}

Query Translation Status (with Download URL)

Query file translation status. Automatically triggers composition when translation is complete and returns the download URL. Clients should poll this endpoint every 3-5 seconds until status_name is completed.

Request

http
POST /api/open_api/v1/translate/status
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
file_idstringYesFile ID (string type)

Request Example

json
{
    "file_id": "12345678901234567"
}

Response Data

FieldTypeDescription
file_idstringFile ID
status_namestringStatus name (see table below)
download_urlstringDownload URL (returned when completed, null otherwise)

Status Names

StatusMeaningAction
parsingParsing documentContinue polling
parse_failedParse errorCheck file format
pendingWaiting for translationContinue polling
translatingTranslation in progressContinue polling
translation_failedTranslation errorRetry or contact support
compositingGenerating output fileContinue polling
completedDoneGet download_url

Response Example (Translating)

json
{
    "code": 0,
    "message": "success",
    "data": {
        "file_id": "12345678901234567",
        "status_name": "translating",
        "download_url": null
    }
}

Response Example (Completed)

json
{
    "code": 0,
    "message": "success",
    "data": {
        "file_id": "12345678901234567",
        "status_name": "completed",
        "download_url": "https://storage.example.com/file.docx?token=xxx"
    }
}

Delete File

Delete an uploaded file.

Request

http
POST /api/open_api/v1/files/delete
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
file_idstringYesFile ID (string type)

Request Example

json
{
    "file_id": "12345678901234567"
}

Response Data

FieldTypeDescription
file_idstringFile ID
deletedbooleanWhether deletion was successful

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "file_id": "12345678901234567",
        "deleted": true
    }
}

Text Translation APIs

Instant Text Translation

Synchronous text translation that returns results directly.

Request

http
POST /api/open_api/v1/text/translate
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
textstringYesText to translate, max 5000 characters
source_languagestringYesSource language code (LanguageEnum value)
target_languagestringYesTarget language code (LanguageEnum value)

Request Example

json
{
    "text": "Hello World",
    "source_language": "en",
    "target_language": "ja"
}

Response Data

FieldTypeDescription
translated_textstringTranslation result
source_languagestringSource language code
target_languagestringTarget language code
char_countintSource text character count

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "translated_text": "こんにちは世界",
        "source_language": "en",
        "target_language": "ja",
        "char_count": 11
    }
}

Term Library APIs

Create Term Library

Create a new term library.

Request

http
POST /api/open_api/v1/term-libs/create
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
namestringYesTerm library name, max 255 characters
source_languagestringYesSource language code (LanguageEnum value)
target_languagestringYesTarget language code (LanguageEnum value)
descriptionstringNoDescription, max 500 characters

Request Example

json
{
    "name": "Technical Terms",
    "source_language": "zh-cn",
    "target_language": "en",
    "description": "IT technical terminology"
}

Response Data

FieldTypeDescription
idintTerm library ID
namestringTerm library name
source_languagestringSource language code
target_languagestringTarget language code
descriptionstringDescription
entry_countintNumber of entries
create_timedatetimeCreation time

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "name": "Technical Terms",
        "source_language": "zh-cn",
        "target_language": "en",
        "description": "IT technical terminology",
        "entry_count": 0,
        "create_time": "2024-01-15T10:30:00"
    }
}

List Term Libraries

Get paginated list of term libraries.

Request

http
POST /api/open_api/v1/term-libs/list
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
pageintNoPage number, default 1, minimum 1
sizeintNoPage size, default 10, range 1-100
keywordstringNoKeyword search, max 100 characters
source_languagestringNoSource language filter (LanguageEnum value)
target_languagestringNoTarget language filter (LanguageEnum value)

Request Example

json
{
    "page": 1,
    "size": 10,
    "keyword": "technical",
    "source_language": "zh-cn",
    "target_language": "en"
}

Response Data

FieldTypeDescription
itemsarrayTerm library list
items[].idintTerm library ID
items[].namestringTerm library name
items[].source_languagestringSource language code
items[].target_languagestringTarget language code
items[].descriptionstringDescription
items[].entry_countintNumber of entries
items[].create_timedatetimeCreation time
items[].update_timedatetimeUpdate time
totalintTotal count
pageintCurrent page
sizeintPage size
pagesintTotal pages

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "items": [
            {
                "id": 1,
                "name": "Technical Terms",
                "source_language": "zh-cn",
                "target_language": "en",
                "description": "IT technical terminology",
                "entry_count": 150,
                "create_time": "2024-01-15T10:30:00",
                "update_time": "2024-01-16T08:00:00"
            }
        ],
        "total": 5,
        "page": 1,
        "size": 10,
        "pages": 1
    }
}

Edit Term Library

Edit term library information.

Request

http
POST /api/open_api/v1/term-libs/edit
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idintYesTerm library ID
namestringNoNew name, max 255 characters
descriptionstringNoNew description, max 500 characters

Request Example

json
{
    "id": 1,
    "name": "New Term Library Name",
    "description": "Updated description"
}

Response Data

FieldTypeDescription
idintTerm library ID
namestringTerm library name
source_languagestringSource language code
target_languagestringTarget language code
descriptionstringDescription
entry_countintNumber of entries
update_timedatetimeUpdate time

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "name": "New Term Library Name",
        "source_language": "zh-cn",
        "target_language": "en",
        "description": "Updated description",
        "entry_count": 150,
        "update_time": "2024-01-16T10:00:00"
    }
}

Delete Term Library

Delete a term library and all its entries.

Request

http
POST /api/open_api/v1/term-libs/delete
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idintYesTerm library ID

Request Example

json
{
    "id": 1
}

Response Data

FieldTypeDescription
idintTerm library ID
deletedbooleanWhether deletion was successful

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "deleted": true
    }
}

Add Term Entries

Add one or more entries to a term library.

Request

http
POST /api/open_api/v1/term-entries/add
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
term_lib_idintYesTerm library ID
entriesobject[]YesEntry list
entries[].source_textstringYesSource term, max 1000 characters
entries[].target_textstringYesTarget term, max 1000 characters

Request Example

json
{
    "term_lib_id": 1,
    "entries": [
        {"source_text": "人工智能", "target_text": "Artificial Intelligence"},
        {"source_text": "机器学习", "target_text": "Machine Learning"}
    ]
}

Response Data

None (data is null)

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": null
}

List Term Entries

Get entries from a term library.

Request

http
POST /api/open_api/v1/term-entries/list
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
term_lib_idintYesTerm library ID
pageintNoPage number, default 1, minimum 1
sizeintNoPage size, default 10, range 1-100
keywordstringNoKeyword search, max 100 characters

Request Example

json
{
    "term_lib_id": 1,
    "page": 1,
    "size": 10,
    "keyword": "AI"
}

Response Data

FieldTypeDescription
itemsarrayEntry list
items[].idintEntry ID
items[].source_textstringSource term
items[].target_textstringTarget term
items[].create_timedatetimeCreation time
items[].update_timedatetimeUpdate time
totalintTotal count
pageintCurrent page
sizeintPage size
pagesintTotal pages

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "items": [
            {
                "id": 1,
                "source_text": "人工智能",
                "target_text": "Artificial Intelligence",
                "create_time": "2024-01-15T10:30:00",
                "update_time": null
            }
        ],
        "total": 150,
        "page": 1,
        "size": 10,
        "pages": 15
    }
}

Edit Term Entry

Edit a single term entry.

Request

http
POST /api/open_api/v1/term-entries/edit
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idintYesEntry ID
source_textstringNoNew source term, max 1000 characters
target_textstringNoNew target term, max 1000 characters

Request Example

json
{
    "id": 1,
    "source_text": "New Source Term",
    "target_text": "New Target Term"
}

Response Data

FieldTypeDescription
idintEntry ID
source_textstringSource term
target_textstringTarget term
update_timedatetimeUpdate time

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "source_text": "New Source Term",
        "target_text": "New Target Term",
        "update_time": "2024-01-16T10:00:00"
    }
}

Delete Term Entries

Delete one or more term entries.

Request

http
POST /api/open_api/v1/term-entries/delete
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idsint[]YesList of entry IDs

Request Example

json
{
    "ids": [1, 2, 3]
}

Response Data

FieldTypeDescription
deletedintNumber of deleted entries
idsint[]List of deleted entry IDs

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "deleted": 3,
        "ids": [1, 2, 3]
    }
}

Memory Library APIs

Create Memory Library

Create a new memory library.

Request

http
POST /api/open_api/v1/memory-libs/create
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
namestringYesMemory library name, max 255 characters
source_languagestringYesSource language code (LanguageEnum value)
target_languagestringYesTarget language code (LanguageEnum value)
descriptionstringNoDescription, max 500 characters

Request Example

json
{
    "name": "Technical Documentation TM",
    "source_language": "zh-cn",
    "target_language": "en",
    "description": "Technical documentation translation memory"
}

Response Data

FieldTypeDescription
idintMemory library ID
namestringMemory library name
source_languagestringSource language code
target_languagestringTarget language code
descriptionstringDescription
entry_countintNumber of entries
create_timedatetimeCreation time

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "name": "Technical Documentation TM",
        "source_language": "zh-cn",
        "target_language": "en",
        "description": "Technical documentation translation memory",
        "entry_count": 0,
        "create_time": "2024-01-15T10:30:00"
    }
}

List Memory Libraries

Get paginated list of memory libraries.

Request

http
POST /api/open_api/v1/memory-libs/list
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
pageintNoPage number, default 1, minimum 1
sizeintNoPage size, default 10, range 1-100
keywordstringNoKeyword search, max 100 characters
source_languagestringNoSource language filter (LanguageEnum value)
target_languagestringNoTarget language filter (LanguageEnum value)

Request Example

json
{
    "page": 1,
    "size": 10,
    "keyword": "technical",
    "source_language": "zh-cn",
    "target_language": "en"
}

Response Data

FieldTypeDescription
itemsarrayMemory library list
items[].idintMemory library ID
items[].namestringMemory library name
items[].source_languagestringSource language code
items[].target_languagestringTarget language code
items[].descriptionstringDescription
items[].entry_countintNumber of entries
items[].create_timedatetimeCreation time
items[].update_timedatetimeUpdate time
totalintTotal count
pageintCurrent page
sizeintPage size
pagesintTotal pages

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "items": [
            {
                "id": 1,
                "name": "Technical Documentation TM",
                "source_language": "zh-cn",
                "target_language": "en",
                "description": "Technical documentation translation memory",
                "entry_count": 500,
                "create_time": "2024-01-15T10:30:00",
                "update_time": "2024-01-16T08:00:00"
            }
        ],
        "total": 3,
        "page": 1,
        "size": 10,
        "pages": 1
    }
}

Edit Memory Library

Edit memory library information.

Request

http
POST /api/open_api/v1/memory-libs/edit
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idintYesMemory library ID
namestringNoNew name, max 255 characters
descriptionstringNoNew description, max 500 characters

Request Example

json
{
    "id": 1,
    "name": "New Memory Library Name",
    "description": "Updated description"
}

Response Data

FieldTypeDescription
idintMemory library ID
namestringMemory library name
source_languagestringSource language code
target_languagestringTarget language code
descriptionstringDescription
entry_countintNumber of entries
update_timedatetimeUpdate time

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "name": "New Memory Library Name",
        "source_language": "zh-cn",
        "target_language": "en",
        "description": "Updated description",
        "entry_count": 500,
        "update_time": "2024-01-16T10:00:00"
    }
}

Delete Memory Library

Delete a memory library and all its entries.

Request

http
POST /api/open_api/v1/memory-libs/delete
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idintYesMemory library ID

Request Example

json
{
    "id": 1
}

Response Data

FieldTypeDescription
idintMemory library ID
deletedbooleanWhether deletion was successful

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "deleted": true
    }
}

Add Memory Entries

Add one or more entries to a memory library.

Request

http
POST /api/open_api/v1/memory-entries/add
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
memory_lib_idintYesMemory library ID
entriesobject[]YesEntry list
entries[].source_textstringYesSource text, max 5000 characters
entries[].target_textstringYesTarget text, max 5000 characters

Request Example

json
{
    "memory_lib_id": 1,
    "entries": [
        {
            "source_text": "This is an example sentence.",
            "target_text": "这是一个示例句子。"
        },
        {
            "source_text": "Machine translation technology is developing rapidly.",
            "target_text": "机器翻译技术正在快速发展。"
        }
    ]
}

Response Data

None (data is null)

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": null
}

List Memory Entries

Get entries from a memory library.

Request

http
POST /api/open_api/v1/memory-entries/list
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
memory_lib_idintYesMemory library ID
pageintNoPage number, default 1, minimum 1
sizeintNoPage size, default 10, range 1-100
keywordstringNoKeyword search, max 100 characters

Request Example

json
{
    "memory_lib_id": 1,
    "page": 1,
    "size": 10,
    "keyword": "example"
}

Response Data

FieldTypeDescription
itemsarrayEntry list
items[].idintEntry ID
items[].source_textstringSource text
items[].target_textstringTarget text
items[].create_timedatetimeCreation time
items[].update_timedatetimeUpdate time
totalintTotal count
pageintCurrent page
sizeintPage size
pagesintTotal pages

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "items": [
            {
                "id": 1,
                "source_text": "This is an example sentence.",
                "target_text": "这是一个示例句子。",
                "create_time": "2024-01-15T10:30:00",
                "update_time": null
            }
        ],
        "total": 500,
        "page": 1,
        "size": 10,
        "pages": 50
    }
}

Edit Memory Entry

Edit a single memory entry.

Request

http
POST /api/open_api/v1/memory-entries/edit
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idintYesEntry ID
source_textstringNoNew source text, max 5000 characters
target_textstringNoNew target text, max 5000 characters

Request Example

json
{
    "id": 1,
    "source_text": "New source text.",
    "target_text": "New target text."
}

Response Data

FieldTypeDescription
idintEntry ID
source_textstringSource text
target_textstringTarget text
update_timedatetimeUpdate time

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "id": 1,
        "source_text": "New source text.",
        "target_text": "New target text.",
        "update_time": "2024-01-16T10:00:00"
    }
}

Delete Memory Entries

Delete one or more memory entries.

Request

http
POST /api/open_api/v1/memory-entries/delete
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
idsint[]YesList of entry IDs

Request Example

json
{
    "ids": [1, 2, 3]
}

Response Data

FieldTypeDescription
deletedintNumber of deleted entries
idsint[]List of deleted entry IDs

Response Example

json
{
    "code": 0,
    "message": "success",
    "data": {
        "deleted": 3,
        "ids": [1, 2, 3]
    }
}

Error Codes

Authentication Related (910xx)

Error CodeDescription
91000API Key is required
91001Invalid API Key
91002API Key has expired
91003API Key is disabled
91004API Key is not yet effective
91005Customer not found
91006Rate limit exceeded

File Translation Related (911xx)

Error CodeDescription
91100File size exceeds the limit
91101File type not supported
91102File upload failed
91103File not found
91104File status does not allow this operation
91105Insufficient account balance
91106Refund failed, balance record not found
91107Task not found
91108Task not completed, cannot download
91109Translated file not found
91110Failed to get download URL
91111File is being translated, cannot operate
91112File has not been uploaded yet

Text Translation Related (915xx)

Error CodeDescription
91500Text exceeds model token limit
91501Translation service error
91502Translation returned empty result

Term Library Related (912xx)

Error CodeDescription
91200Term library name already exists
91201Term library not found
91202Source term already exists
91203Term entry not found
91204Entry list cannot be empty

Memory Library Related (913xx)

Error CodeDescription
91300Memory library name already exists
91301Memory library not found
91302Memory entry not found
91303Entry list cannot be empty

Language Code Reference

The following are common language codes (for the complete list, call the /api/open_api/v1/languages API):

CodeLanguage
zh-cnChinese (Simplified)
zh-TWChinese (Traditional)
enEnglish
jaJapanese
koKorean
deGerman
frFrench
esSpanish
ptPortuguese
ruRussian
arArabic
thThai
viVietnamese
idIndonesian
msMalay

Usage Examples

Python Example

python
import requests
import time

BASE_URL = "https://api.example.com/api/open_api/v1"
API_KEY = "your_api_key"

headers = {
    "X-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 1. Create upload URL
response = requests.post(
    f"{BASE_URL}/files/create_upload_url",
    json={"filename": "document.docx", "is_can_edit": True},
    headers=headers
)
data = response.json()["data"]
file_id = data["file_id"]
upload_url = data["upload_url"]
content_type = data["content_type"]

# 2. Upload file to pre-signed URL
with open("document.docx", "rb") as f:
    requests.put(upload_url, data=f, headers={"Content-Type": content_type})

# 3. Submit translation
response = requests.post(
    f"{BASE_URL}/translate/document",
    json={
        "file_id": int(file_id),
        "source_language": "zh-cn",
        "target_language": "en",
        "trans_mode": "master"
    },
    headers=headers
)

# 4. Poll status until completed
while True:
    response = requests.post(
        f"{BASE_URL}/translate/status",
        json={"file_id": file_id},
        headers=headers
    )
    result = response.json()["data"]
    if result["status_name"] == "completed":
        download_url = result["download_url"]
        break
    elif result["status_name"] in ("parse_failed", "translation_failed"):
        raise Exception(f"Translation failed: {result['status_name']}")
    time.sleep(5)

cURL Example

bash
# Get supported languages
curl -X GET "https://api.example.com/api/open_api/v1/languages" \
  -H "X-API-Key: your_api_key"

# Create upload URL
curl -X POST "https://api.example.com/api/open_api/v1/files/create_upload_url" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"filename": "document.docx", "is_can_edit": true}'

# Upload file to pre-signed URL (upload_url and content_type from previous step)
curl -X PUT "<upload_url>" \
  -H "Content-Type: <content_type>" \
  --data-binary @document.docx

# Submit translation
curl -X POST "https://api.example.com/api/open_api/v1/translate/document" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"file_id": 12345678901234567, "source_language": "zh-cn", "target_language": "en", "trans_mode": "master"}'

# Poll translation status (includes download URL)
curl -X POST "https://api.example.com/api/open_api/v1/translate/status" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"file_id": "12345678901234567"}'

# Create term library
curl -X POST "https://api.example.com/api/open_api/v1/term-libs/create" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"name": "Technical Terms", "source_language": "zh-cn", "target_language": "en"}'

# Add term entries
curl -X POST "https://api.example.com/api/open_api/v1/term-entries/add" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"term_lib_id": 1, "entries": [{"source_text": "人工智能", "target_text": "AI"}]}'