[T010]Translate Text

post
https://connect.patsnap.com/hiro_translation/translate
Try in Sandbox

Translate source text from source language to target language and return a single JSON result.

content, sourceLanguageCode and targetLanguageCode are required. Both sourceLanguageCode and targetLanguageCode must be supported language codes (zh, en, ja, ko, de, fr, ru, es, pt, it, nl, ar, hi, th, vi, id, tr, pl) and must differ. content is limited to 65536 characters by default. mode supports stream and fast, defaulting to fast. stream: sliding-window sequential translation, returned segment by segment via SSE; later segments can leverage already-translated context within the window, maximizing consistency across the whole text. fast: concurrent segment-based translation that returns the complete JSON result in a single response, offering higher throughput but weaker cross-segment context consistency.

Request Parameters

List of parameters supported by this API endpoint

NameTypeExampleDescription
content
Required
string本发明公开了一种档案管理文件储存用分类标识装置。
Source text to translate. Must not be blank. Default max 65536 characters.
mode
stringfast
Translation mode. Supports fast and stream, defaulting to fast. fast: concurrent segment-based translation that returns the complete JSON result in a single response, offering higher throughput but weaker cross-segment context consistency. stream: sliding-window sequential translation, returned segment by segment via SSE; later segments can leverage already-translated context within the window, maximizing consistency across the whole text.
sourceLanguageCode
Required
stringzh
Source language code. Supported: zh, en, ja, ko, de, fr, ru, es, pt, it, nl, ar, hi, th, vi, id, tr, pl.
targetLanguageCode
Required
stringen
Target language code; must differ from source. Supported: zh, en, ja, ko, de, fr, ru, es, pt, it, nl, ar, hi, th, vi, id, tr, pl.

Response Schema

Structure of the API response data

Field NameTypeExampleDescription
data
object-
response data
state
Required
stringsuccess
Execution status, always success
textTranslated
Required
stringThe invention discloses a classified marking device for archive management file storage.
Full translated text
translatedCharacterCount
Required
integer<int32>82
Character count of translated text
status
Required
booleanfalse
Status
error_msg
stringThe request parameter format is incorrect!
Error Message
error_code
Required
integer0
Error Code

Success Response Example

Example of a successful API response

JSON
{
  "data": {
    "state": "success",
    "textTranslated": "The invention discloses a classified marking device for archive management file storage.",
    "translatedCharacterCount": 82
  },
  "status": true,
  "error_code": 0
}

Error Codes

List of possible error codes returned by this endpoint

Business Errors

Error CodeDescription
68300004Invalid parameter!
68300005Search api failure!
68300006Analytic basic access error!
68300007Bad request!
68300008Service error, please try again later!
68300010The file does not comply with upload specifications!

Platform Errors

Error CodeDescription
67200000API call exceeds the total limit set by the platform!
67200001API call exceeds the total limit set by the platform!
67200002The current call rate is too fast, exceeding the current configuration limit QPS!
67200003The key and secret parameters for applying for the token are incorrect or the client has been disabled!
67200004The requested api does not have permission. Please contact our support personnel!
67200005Insufficient account balance/number of calls!
67200006The client has exceeded the activation validity period!
67200007The current call exceeds the configured usage limit of the day!
67200008Please check if the required apikey in the query parameter has been transmitted!
67200009The apikey does not match the passed bearerToken. Please check if a valid token is being used!
67200012The request is illegal!
67200100The current server status is busy, request response timeout!
67200101The API requested currently does not exist. Please check the request path!

HTTP Status Codes

Status CodeDescription
0Success
201Created
401Unauthorized
403Forbidden
404Not Found

Performance Metrics

Expected performance characteristics for this endpoint

Normal Response Time

5000 ms

Max Response Time

10000 ms