0.1.0 • Published 8 years ago

node-baidu-translate v0.1.0

Weekly downloads
12
License
MIT
Repository
github
Last release
8 years ago

node-baidu-translate

npm CircleCI npm npm

http://api.fanyi.baidu.com/api/trans/product/apidoc

Quick Start

import BaiduTranslate from 'node-baidu-translate'

const bdt = new BaiduTranslate(APPID, SECRET_KEY)

bdt.translate('apple', 'en').then(res => {
  console.log(res)
  // { from: 'en',
  //   to: 'zh',
  //   trans_result: [ { src: 'apple', dst: '苹果' } ] 
  // }
})

API

constructor(appId: string, secretKey: string, endPoint?: string): baiduTranslateInstance

  • appId
  • secretKey
  • endPoint

    API 请求 endpoint, 一般不需要填

baiduTranslateInstance.translate(query: string, to: string, from?: string = 'auto'): Promise

License

MIT License