
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:
X-API-Key: your_api_key_hereUnified Response Format
{
"code": 0,
"message": "success",
"data": {}
}| Field | Type | Description |
|---|---|---|
| code | int | Status code, 0 indicates success |
| message | string | Status message |
| data | object | Response data |
Rate Limiting (QPS)
To ensure service stability, all APIs have rate limits:
| API Type | QPS Limit | Description |
|---|---|---|
| File Upload | 5/s | Maximum 5 requests per second per API Key |
| Submit Translation | 10/s | Maximum 10 requests per second per API Key |
| Query Status | 10/s | Maximum 10 requests per second per API Key |
| Get Download URL | 10/s | Maximum 10 requests per second per API Key |
| Other APIs | 20/s | Maximum 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
GET /api/open_api/v1/languagesRequest Parameters
None
Response Data
| Field | Type | Description |
|---|---|---|
| languages | array | Language list |
| languages[].code | string | Language code |
| languages[].name | string | Language name in English |
| total | int | Total number of languages |
Response Example
{
"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
POST /api/open_api/v1/files/create_upload_url
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| filename | string | Yes | Filename with extension. Supported: docx, doc, pdf, pptx, ppt, xlsx, xls, txt, xml |
| is_can_edit | boolean | No | Whether PDF file is editable, default true. Set to false for scanned/image PDFs (enables OCR) |
Request Example
{
"filename": "report.docx",
"is_can_edit": true
}Response Data
| Field | Type | Description |
|---|---|---|
| file_id | string | File ID |
| upload_url | string | Pre-signed upload URL |
| cloud_path | string | Cloud storage path |
| expires_in | int | URL expiration time in seconds |
| content_type | string | Content-Type to set when uploading |
Response Example
{
"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:
curl -X PUT "<upload_url>" \
-H "Content-Type: <content_type>" \
--data-binary @report.docxSubmit File Translation
Submit a pre-signed uploaded file for translation. Validates file upload, triggers parsing, and automatically submits translation after parsing completes.
Request
POST /api/open_api/v1/translate/document
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| file_id | int | Yes | File ID returned by create_upload_url (integer type) |
| source_language | string | Yes | Source language code (LanguageEnum value) |
| target_language | string | Yes | Target language code (LanguageEnum value) |
| trans_mode | string | No | Translation mode: deep or master, default master |
| term_lib_ids | int[] | No | List of term library IDs |
| memory_libs | object[] | No | Memory library configuration list |
| memory_libs[].memory_lib_id | int | Yes | Memory library ID |
| memory_libs[].threshold | float | No | Match threshold, range 0-1, default 0.8 |
Request Example
{
"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
| Field | Type | Description |
|---|---|---|
| file_id | string | File ID |
| status | string | Processing status: parsing |
Response Example
{
"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
POST /api/open_api/v1/translate/status
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| file_id | string | Yes | File ID (string type) |
Request Example
{
"file_id": "12345678901234567"
}Response Data
| Field | Type | Description |
|---|---|---|
| file_id | string | File ID |
| status_name | string | Status name (see table below) |
| download_url | string | Download URL (returned when completed, null otherwise) |
Status Names
| Status | Meaning | Action |
|---|---|---|
| parsing | Parsing document | Continue polling |
| parse_failed | Parse error | Check file format |
| pending | Waiting for translation | Continue polling |
| translating | Translation in progress | Continue polling |
| translation_failed | Translation error | Retry or contact support |
| compositing | Generating output file | Continue polling |
| completed | Done | Get download_url |
Response Example (Translating)
{
"code": 0,
"message": "success",
"data": {
"file_id": "12345678901234567",
"status_name": "translating",
"download_url": null
}
}Response Example (Completed)
{
"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
POST /api/open_api/v1/files/delete
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| file_id | string | Yes | File ID (string type) |
Request Example
{
"file_id": "12345678901234567"
}Response Data
| Field | Type | Description |
|---|---|---|
| file_id | string | File ID |
| deleted | boolean | Whether deletion was successful |
Response Example
{
"code": 0,
"message": "success",
"data": {
"file_id": "12345678901234567",
"deleted": true
}
}Text Translation APIs
Instant Text Translation
Synchronous text translation that returns results directly.
Request
POST /api/open_api/v1/text/translate
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text to translate, max 5000 characters |
| source_language | string | Yes | Source language code (LanguageEnum value) |
| target_language | string | Yes | Target language code (LanguageEnum value) |
Request Example
{
"text": "Hello World",
"source_language": "en",
"target_language": "ja"
}Response Data
| Field | Type | Description |
|---|---|---|
| translated_text | string | Translation result |
| source_language | string | Source language code |
| target_language | string | Target language code |
| char_count | int | Source text character count |
Response Example
{
"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
POST /api/open_api/v1/term-libs/create
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Term library name, max 255 characters |
| source_language | string | Yes | Source language code (LanguageEnum value) |
| target_language | string | Yes | Target language code (LanguageEnum value) |
| description | string | No | Description, max 500 characters |
Request Example
{
"name": "Technical Terms",
"source_language": "zh-cn",
"target_language": "en",
"description": "IT technical terminology"
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Term library ID |
| name | string | Term library name |
| source_language | string | Source language code |
| target_language | string | Target language code |
| description | string | Description |
| entry_count | int | Number of entries |
| create_time | datetime | Creation time |
Response Example
{
"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
POST /api/open_api/v1/term-libs/list
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | int | No | Page number, default 1, minimum 1 |
| size | int | No | Page size, default 10, range 1-100 |
| keyword | string | No | Keyword search, max 100 characters |
| source_language | string | No | Source language filter (LanguageEnum value) |
| target_language | string | No | Target language filter (LanguageEnum value) |
Request Example
{
"page": 1,
"size": 10,
"keyword": "technical",
"source_language": "zh-cn",
"target_language": "en"
}Response Data
| Field | Type | Description |
|---|---|---|
| items | array | Term library list |
| items[].id | int | Term library ID |
| items[].name | string | Term library name |
| items[].source_language | string | Source language code |
| items[].target_language | string | Target language code |
| items[].description | string | Description |
| items[].entry_count | int | Number of entries |
| items[].create_time | datetime | Creation time |
| items[].update_time | datetime | Update time |
| total | int | Total count |
| page | int | Current page |
| size | int | Page size |
| pages | int | Total pages |
Response Example
{
"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
POST /api/open_api/v1/term-libs/edit
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Term library ID |
| name | string | No | New name, max 255 characters |
| description | string | No | New description, max 500 characters |
Request Example
{
"id": 1,
"name": "New Term Library Name",
"description": "Updated description"
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Term library ID |
| name | string | Term library name |
| source_language | string | Source language code |
| target_language | string | Target language code |
| description | string | Description |
| entry_count | int | Number of entries |
| update_time | datetime | Update time |
Response Example
{
"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
POST /api/open_api/v1/term-libs/delete
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Term library ID |
Request Example
{
"id": 1
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Term library ID |
| deleted | boolean | Whether deletion was successful |
Response Example
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"deleted": true
}
}Add Term Entries
Add one or more entries to a term library.
Request
POST /api/open_api/v1/term-entries/add
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| term_lib_id | int | Yes | Term library ID |
| entries | object[] | Yes | Entry list |
| entries[].source_text | string | Yes | Source term, max 1000 characters |
| entries[].target_text | string | Yes | Target term, max 1000 characters |
Request Example
{
"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
{
"code": 0,
"message": "success",
"data": null
}List Term Entries
Get entries from a term library.
Request
POST /api/open_api/v1/term-entries/list
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| term_lib_id | int | Yes | Term library ID |
| page | int | No | Page number, default 1, minimum 1 |
| size | int | No | Page size, default 10, range 1-100 |
| keyword | string | No | Keyword search, max 100 characters |
Request Example
{
"term_lib_id": 1,
"page": 1,
"size": 10,
"keyword": "AI"
}Response Data
| Field | Type | Description |
|---|---|---|
| items | array | Entry list |
| items[].id | int | Entry ID |
| items[].source_text | string | Source term |
| items[].target_text | string | Target term |
| items[].create_time | datetime | Creation time |
| items[].update_time | datetime | Update time |
| total | int | Total count |
| page | int | Current page |
| size | int | Page size |
| pages | int | Total pages |
Response Example
{
"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
POST /api/open_api/v1/term-entries/edit
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Entry ID |
| source_text | string | No | New source term, max 1000 characters |
| target_text | string | No | New target term, max 1000 characters |
Request Example
{
"id": 1,
"source_text": "New Source Term",
"target_text": "New Target Term"
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Entry ID |
| source_text | string | Source term |
| target_text | string | Target term |
| update_time | datetime | Update time |
Response Example
{
"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
POST /api/open_api/v1/term-entries/delete
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| ids | int[] | Yes | List of entry IDs |
Request Example
{
"ids": [1, 2, 3]
}Response Data
| Field | Type | Description |
|---|---|---|
| deleted | int | Number of deleted entries |
| ids | int[] | List of deleted entry IDs |
Response Example
{
"code": 0,
"message": "success",
"data": {
"deleted": 3,
"ids": [1, 2, 3]
}
}Memory Library APIs
Create Memory Library
Create a new memory library.
Request
POST /api/open_api/v1/memory-libs/create
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Memory library name, max 255 characters |
| source_language | string | Yes | Source language code (LanguageEnum value) |
| target_language | string | Yes | Target language code (LanguageEnum value) |
| description | string | No | Description, max 500 characters |
Request Example
{
"name": "Technical Documentation TM",
"source_language": "zh-cn",
"target_language": "en",
"description": "Technical documentation translation memory"
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Memory library ID |
| name | string | Memory library name |
| source_language | string | Source language code |
| target_language | string | Target language code |
| description | string | Description |
| entry_count | int | Number of entries |
| create_time | datetime | Creation time |
Response Example
{
"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
POST /api/open_api/v1/memory-libs/list
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | int | No | Page number, default 1, minimum 1 |
| size | int | No | Page size, default 10, range 1-100 |
| keyword | string | No | Keyword search, max 100 characters |
| source_language | string | No | Source language filter (LanguageEnum value) |
| target_language | string | No | Target language filter (LanguageEnum value) |
Request Example
{
"page": 1,
"size": 10,
"keyword": "technical",
"source_language": "zh-cn",
"target_language": "en"
}Response Data
| Field | Type | Description |
|---|---|---|
| items | array | Memory library list |
| items[].id | int | Memory library ID |
| items[].name | string | Memory library name |
| items[].source_language | string | Source language code |
| items[].target_language | string | Target language code |
| items[].description | string | Description |
| items[].entry_count | int | Number of entries |
| items[].create_time | datetime | Creation time |
| items[].update_time | datetime | Update time |
| total | int | Total count |
| page | int | Current page |
| size | int | Page size |
| pages | int | Total pages |
Response Example
{
"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
POST /api/open_api/v1/memory-libs/edit
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Memory library ID |
| name | string | No | New name, max 255 characters |
| description | string | No | New description, max 500 characters |
Request Example
{
"id": 1,
"name": "New Memory Library Name",
"description": "Updated description"
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Memory library ID |
| name | string | Memory library name |
| source_language | string | Source language code |
| target_language | string | Target language code |
| description | string | Description |
| entry_count | int | Number of entries |
| update_time | datetime | Update time |
Response Example
{
"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
POST /api/open_api/v1/memory-libs/delete
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Memory library ID |
Request Example
{
"id": 1
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Memory library ID |
| deleted | boolean | Whether deletion was successful |
Response Example
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"deleted": true
}
}Add Memory Entries
Add one or more entries to a memory library.
Request
POST /api/open_api/v1/memory-entries/add
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| memory_lib_id | int | Yes | Memory library ID |
| entries | object[] | Yes | Entry list |
| entries[].source_text | string | Yes | Source text, max 5000 characters |
| entries[].target_text | string | Yes | Target text, max 5000 characters |
Request Example
{
"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
{
"code": 0,
"message": "success",
"data": null
}List Memory Entries
Get entries from a memory library.
Request
POST /api/open_api/v1/memory-entries/list
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| memory_lib_id | int | Yes | Memory library ID |
| page | int | No | Page number, default 1, minimum 1 |
| size | int | No | Page size, default 10, range 1-100 |
| keyword | string | No | Keyword search, max 100 characters |
Request Example
{
"memory_lib_id": 1,
"page": 1,
"size": 10,
"keyword": "example"
}Response Data
| Field | Type | Description |
|---|---|---|
| items | array | Entry list |
| items[].id | int | Entry ID |
| items[].source_text | string | Source text |
| items[].target_text | string | Target text |
| items[].create_time | datetime | Creation time |
| items[].update_time | datetime | Update time |
| total | int | Total count |
| page | int | Current page |
| size | int | Page size |
| pages | int | Total pages |
Response Example
{
"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
POST /api/open_api/v1/memory-entries/edit
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Entry ID |
| source_text | string | No | New source text, max 5000 characters |
| target_text | string | No | New target text, max 5000 characters |
Request Example
{
"id": 1,
"source_text": "New source text.",
"target_text": "New target text."
}Response Data
| Field | Type | Description |
|---|---|---|
| id | int | Entry ID |
| source_text | string | Source text |
| target_text | string | Target text |
| update_time | datetime | Update time |
Response Example
{
"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
POST /api/open_api/v1/memory-entries/delete
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| ids | int[] | Yes | List of entry IDs |
Request Example
{
"ids": [1, 2, 3]
}Response Data
| Field | Type | Description |
|---|---|---|
| deleted | int | Number of deleted entries |
| ids | int[] | List of deleted entry IDs |
Response Example
{
"code": 0,
"message": "success",
"data": {
"deleted": 3,
"ids": [1, 2, 3]
}
}Error Codes
Authentication Related (910xx)
| Error Code | Description |
|---|---|
| 91000 | API Key is required |
| 91001 | Invalid API Key |
| 91002 | API Key has expired |
| 91003 | API Key is disabled |
| 91004 | API Key is not yet effective |
| 91005 | Customer not found |
| 91006 | Rate limit exceeded |
File Translation Related (911xx)
| Error Code | Description |
|---|---|
| 91100 | File size exceeds the limit |
| 91101 | File type not supported |
| 91102 | File upload failed |
| 91103 | File not found |
| 91104 | File status does not allow this operation |
| 91105 | Insufficient account balance |
| 91106 | Refund failed, balance record not found |
| 91107 | Task not found |
| 91108 | Task not completed, cannot download |
| 91109 | Translated file not found |
| 91110 | Failed to get download URL |
| 91111 | File is being translated, cannot operate |
| 91112 | File has not been uploaded yet |
Text Translation Related (915xx)
| Error Code | Description |
|---|---|
| 91500 | Text exceeds model token limit |
| 91501 | Translation service error |
| 91502 | Translation returned empty result |
Term Library Related (912xx)
| Error Code | Description |
|---|---|
| 91200 | Term library name already exists |
| 91201 | Term library not found |
| 91202 | Source term already exists |
| 91203 | Term entry not found |
| 91204 | Entry list cannot be empty |
Memory Library Related (913xx)
| Error Code | Description |
|---|---|
| 91300 | Memory library name already exists |
| 91301 | Memory library not found |
| 91302 | Memory entry not found |
| 91303 | Entry 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):
| Code | Language |
|---|---|
| zh-cn | Chinese (Simplified) |
| zh-TW | Chinese (Traditional) |
| en | English |
| ja | Japanese |
| ko | Korean |
| de | German |
| fr | French |
| es | Spanish |
| pt | Portuguese |
| ru | Russian |
| ar | Arabic |
| th | Thai |
| vi | Vietnamese |
| id | Indonesian |
| ms | Malay |
Usage Examples
Python Example
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
# 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"}]}'