SDK for Papago Translation API, supports multiple languages.
This SDK requires Papago API Client ID and Secret.
For further guidance, see Client ID and Secret.
Zero-cost Papago API is available HERE,(working on integration)text.translate()
anddetect()
is supported only.- 100,000 KRW(~$75) worth credit for Naver Cloud Console is available HERE.
pnpm add papago-sdk
Set up a client with your Papago Translation credentials.
// CJS
const { Papago } = require('papago-sdk')
// ESM
import { Papago } from 'papago-sdk'
const papago = new Papago({
id: 'PAPAGO_CLIENT_ID',
secret: 'PAPAGO_CLIENT_SECRET',
})
Translate the given text from one language to another.
const textTranslation = await papago.translate({
from: 'en',
to: 'ko',
type: 'text',
input: 'Hello, World!'
});
// Output:
{
message: {
result: {
srcLangType: 'en',
tarLangType: 'ko',
translatedText: '안녕, 세상!'
}
}
}
Returns translated text only as translatedText
.
const textOnly = await papago.translate({
from: 'en',
to: 'ko',
type: 'text',
text: 'Hello, World!',
textOnly: true,
})
// Output:
{
translatedText: '안녕, 세상!'
}
Translate an HTML string from one language to another as translatedHtml
.
Note that the HTML structure will be preserved.
const htmlTranslation = await papago.translate({
from: 'en',
to: 'ko',
type: 'html',
input: '<div>Hello, world!</div>',
})
// Output:
{
translatedHtml: '<div>안녕, 세상!</div>'
}
Good to know: For
translate
, whenfrom
is set to'auto'
, the source language is detected automatically.
Detect lang code of the given text.
const detection = await papago.detect({
query: 'Hello World!',
})
// Output:
{
langCode: 'en'
}
Order by Accuracy & Cross-Language Support
- 🇰🇷 한국어
- 🇺🇸 English
- 🇯🇵 日本語
- 🇨🇳 简体中文
- 🇹🇼 繁體中文
- 🇻🇳 Tiếng Việt
- 🇹🇭 ภาษาไทย
- 🇮🇩 Indonésia
- 🇫🇷 français
- 🇪🇸 español
- 🇷🇺 русский
- 🇩🇪 Deutsch
- 🇮🇹 italiàno
For more information, see Language Support.
papago-sdk
is an open source published by an individual.The activities and announcements of
papago-sdk
are not affiliated with Naver Cloud, corp.