Documentation Index

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

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

Doc Translation

Prev Next

Papago Doc Translation API 예제를 소개합니다.

문서 번역

문서 번역 예제를 설명합니다.

Python

Python 기반의 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": 유저_클라이언트_아이디,
  "X-NCP-APIGW-API-KEY": 유저_클라이언트_시크릿
}

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

문서 번역 상태 확인

문서 번역 상태 확인 예제를 설명합니다.

Python

Python 기반의 API 예제 코드는 다음과 같습니다.

import requests

headers = {
  "X-NCP-APIGW-API-KEY-ID": 유저_클라이언트_아이디,
  "X-NCP-APIGW-API-KEY": 유저_클라이언트_시크릿
}

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

문서 번역 결과 다운로드

문서 번역 결과 다운로드 예제를 설명합니다.

Python

Python 기반의 API 예제 코드는 다음과 같습니다.

import urllib.request

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

opener = urllib.request.build_opener()
opener.addheaders = [('X-NCP-APIGW-API-KEY-ID', 유저_클라이언트_아이디), ('X-NCP-APIGW-API-KEY', 유저_클라이언트_시크릿)]
urllib.request.install_opener(opener)

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