Documentation Index

Fetch the complete documentation index at: https://api.ncloud-docs.com/llms.txt

Use this file to discover all available pages before exploring further.

Doc Translation

Prev Next

Available in Classic and VPC

This document introduces the Papago Doc Translation API examples.

Document translation

This section describes a document translation example.

Python

The following is a Python-based sample code for the API.

import requests
from requests_toolbelt import MultipartEncoder
import uuid

data = {
  'source': 'ko',
  'target': 'en',
  'file': ('a.docx', open('a.docx', 'rb'), 'application/octet-stream', {'Content-Transfer-Encoding': 'binary'})
}
m = MultipartEncoder(data, boundary=uuid.uuid4())

headers = {
  "Content-Type": m.content_type,
  "X-NCP-APIGW-API-KEY-ID": user_client_ID,
  "X-NCP-APIGW-API-KEY": user_client_secret
}

url = "https://papago.apigw.ntruss.com/doc-trans/v1/translate"
res = requests.post(url, headers=headers, data=m.to_string())
print(res.text)

Check document translation status

This section describes an example of checking document translation status.

Python

The following is a Python-based sample code for the API.

import requests

headers = {
  "X-NCP-APIGW-API-KEY-ID": user_client_ID,
  "X-NCP-APIGW-API-KEY": user_client_secret
}

url = "https://papago.apigw.ntruss.com/doc-trans/v1/status?requestId=" + RequestId
res = requests.get(url, headers=headers)
print(res.text)

Download document translation result

This section describes an example of downloading document translation results.

Python

The following is a Python-based sample code for the API.

import urllib.request

url = "https://papago.apigw.ntruss.com/doc-trans/v1/download?requestId=" + RequestId

opener = urllib.request.build_opener()
opener.addheaders = [('X-NCP-APIGW-API-KEY-ID', user_client_ID), ('X-NCP-APIGW-API-KEY', user_client_secret)]
urllib.request.install_opener(opener)

urllib.request.urlretrieve(url, "b.docx")