翻译文件抽取结果
curl --request POST \
--url https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate \
--header 'Content-Type: application/json' \
--header 'x-ti-app-id: <api-key>' \
--header 'x-ti-secret-code: <api-key>' \
--data '
{
"task_id": "202412190001",
"source_language": "",
"target_language": "zh-CN"
}
'import requests
url = "https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate"
payload = {
"task_id": "202412190001",
"source_language": "",
"target_language": "zh-CN"
}
headers = {
"x-ti-app-id": "<api-key>",
"x-ti-secret-code": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-ti-app-id': '<api-key>',
'x-ti-secret-code': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({task_id: '202412190001', source_language: '', target_language: 'zh-CN'})
};
fetch('https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'task_id' => '202412190001',
'source_language' => '',
'target_language' => 'zh-CN'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-ti-app-id: <api-key>",
"x-ti-secret-code: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate"
payload := strings.NewReader("{\n \"task_id\": \"202412190001\",\n \"source_language\": \"\",\n \"target_language\": \"zh-CN\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-ti-app-id", "<api-key>")
req.Header.Add("x-ti-secret-code", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate")
.header("x-ti-app-id", "<api-key>")
.header("x-ti-secret-code", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"task_id\": \"202412190001\",\n \"source_language\": \"\",\n \"target_language\": \"zh-CN\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-ti-app-id"] = '<api-key>'
request["x-ti-secret-code"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"task_id\": \"202412190001\",\n \"source_language\": \"\",\n \"target_language\": \"zh-CN\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "<string>",
"result": {
"fields": [
{
"key": "invoiceNumber",
"translated_key": "<string>",
"index": 0,
"value": "<string>"
}
],
"tables": [
{
"table_name": "<string>",
"translated_table_name": "<string>",
"items": [
[
{
"key": "invoiceNumber",
"translated_key": "<string>",
"index": 0,
"value": "<string>"
}
]
],
"item_headers": [
{
"key": "<string>",
"translated_key": "<string>"
}
]
}
],
"stamps": [
{
"key": "<string>",
"page": 123,
"index": 123,
"stamp_prefix": "<string>",
"type_key": "<string>",
"type": "<string>",
"color_key": "<string>",
"color": "<string>",
"stamp_shape_key": "<string>",
"stamp_shape": "<string>",
"value_key": "<string>",
"value": "<string>"
}
],
"handwritings": [
{
"key": "<string>",
"page": 123,
"index": 123,
"handwriting_prefix": "<string>",
"text": "<string>"
}
]
}
}API Reference
翻译文件抽取结果
语言使用 ISO 639-1 编码,中文按地区区分为zh-CN和zh-TW。
source_language省略或传空字符串时自动检测源语言;指定源语言时不能与target_language相同。
调用接口后执行翻译并同步开启前端详情展示。并发请求会返回“任务正在翻译中,请稍后重试”。
常见业务错误码:
1005025065:任务识别失败,无法执行翻译1005025066:任务尚未完成识别1005025067:任务正在翻译中1005025068:翻译源语言和目标语言相同1005025069:目标语言为空或不是具体语言编码
POST
/
api
/
app-api
/
sip
/
platform
/
v2
/
file
/
translate
翻译文件抽取结果
curl --request POST \
--url https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate \
--header 'Content-Type: application/json' \
--header 'x-ti-app-id: <api-key>' \
--header 'x-ti-secret-code: <api-key>' \
--data '
{
"task_id": "202412190001",
"source_language": "",
"target_language": "zh-CN"
}
'import requests
url = "https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate"
payload = {
"task_id": "202412190001",
"source_language": "",
"target_language": "zh-CN"
}
headers = {
"x-ti-app-id": "<api-key>",
"x-ti-secret-code": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-ti-app-id': '<api-key>',
'x-ti-secret-code': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({task_id: '202412190001', source_language: '', target_language: 'zh-CN'})
};
fetch('https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'task_id' => '202412190001',
'source_language' => '',
'target_language' => 'zh-CN'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-ti-app-id: <api-key>",
"x-ti-secret-code: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate"
payload := strings.NewReader("{\n \"task_id\": \"202412190001\",\n \"source_language\": \"\",\n \"target_language\": \"zh-CN\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-ti-app-id", "<api-key>")
req.Header.Add("x-ti-secret-code", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate")
.header("x-ti-app-id", "<api-key>")
.header("x-ti-secret-code", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"task_id\": \"202412190001\",\n \"source_language\": \"\",\n \"target_language\": \"zh-CN\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://docflow.textin.com/api/app-api/sip/platform/v2/file/translate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-ti-app-id"] = '<api-key>'
request["x-ti-secret-code"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"task_id\": \"202412190001\",\n \"source_language\": \"\",\n \"target_language\": \"zh-CN\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "<string>",
"result": {
"fields": [
{
"key": "invoiceNumber",
"translated_key": "<string>",
"index": 0,
"value": "<string>"
}
],
"tables": [
{
"table_name": "<string>",
"translated_table_name": "<string>",
"items": [
[
{
"key": "invoiceNumber",
"translated_key": "<string>",
"index": 0,
"value": "<string>"
}
]
],
"item_headers": [
{
"key": "<string>",
"translated_key": "<string>"
}
]
}
],
"stamps": [
{
"key": "<string>",
"page": 123,
"index": 123,
"stamp_prefix": "<string>",
"type_key": "<string>",
"type": "<string>",
"color_key": "<string>",
"color": "<string>",
"stamp_shape_key": "<string>",
"stamp_shape": "<string>",
"value_key": "<string>",
"value": "<string>"
}
],
"handwritings": [
{
"key": "<string>",
"page": 123,
"index": 123,
"handwriting_prefix": "<string>",
"text": "<string>"
}
]
}
}请求体
application/json
已完成识别的任务ID。雪花ID必须作为字符串传递,禁止转换为JavaScript Number。
示例:
"1978297791713619968"
翻译目标语言,使用 ISO 639-1 编码,必填且必须是具体语言。
可用选项:
zh-CN, zh-TW, ja, ko, en, fr, pt, de, it, es, ru, th, vi, ms, id, hi, bn, ar, pl 示例:
"zh-CN"
翻译源语言,使用 ISO 639-1 编码;省略或空字符串均表示自动检测。
可用选项:
, zh-CN, zh-TW, ja, ko, en, fr, pt, de, it, es, ru, th, vi, ms, id, hi, bn, ar, pl 示例:
""
⌘I

