Doc Translation
    • PDF

    Doc Translation

    • PDF

    Article summary

    The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.

    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://naveropenapi.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://naveropenapi.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://naveropenapi.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")
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.