Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bing-translate-api

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bing-translate-api

A simple and free API for Bing Translator for Node.js

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
increased by10.64%
Maintainers
1
Weekly downloads
 
Created
Source

bing-translate-api

NPM version Build Status NPM Downloads License

A simple and free API for Bing Translator for Node.js.

Install

npm install bing-translate-api

Usage

From auto-detected language to English:

const { translate } = require('bing-translate-api');

translate('你好', null, 'en', true).then(res => {
  console.log(res.translation);
}).catch(err => {
  console.error(err);
});

Translation result

{
  "text": "你好",
  "userLang": "auto-detect",
  "translation": "Hello",
  // `correctedText` is returned only when `corrent` is set as `true`
  // supported since v1.1.0
  "correctedText": "",
  "language": {
    "to": "en",
    "from": "zh-Hans",
    // supported since v1.1.0
    "score": 1
  }
}

API

translate(text, [from], [to], [correct], [raw], [tld], [userAgent])

text

Type: string

The text to be translated, cann't be blank.

from

Type: string Default: auto-detect

The language code of source text. MUST be auto-detect or one of the codes/names (not case sensitive) contained in lang.js

to

Type: string Default: en

The language in which the text should be translated. MUST be one of the codes/names (not case sensitive) contained in lang.js.

correct

Type: boolean Default: false Since: v1.1.0

Whether to correct the input text.

Note that:

  1. There is currently a limit of 50 characters for correction service.
  2. Only the languages in the list are supported to be corrected.
raw

Type: boolean Default: false

Whether the translation result contains raw response from Bing API.

tld

Type: string Default: ''

Can be 'www' | 'cn' | ''

userAgent

Type: string

The header value of user-agent used in API requests.

Default:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36

License

MIT © 2021 plainheart.

Thanks

Great thanks to Bing Translator for providing so excellent translation service.

Keywords

FAQs

Package last updated on 16 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc