{"id":15347779,"url":"https://github.com/plainheart/bing-translate-api","last_synced_at":"2025-04-04T20:15:25.969Z","repository":{"id":39997686,"uuid":"343642305","full_name":"plainheart/bing-translate-api","owner":"plainheart","description":"A simple and free API for Bing \u0026 Microsoft Translator for Node.js","archived":false,"fork":false,"pushed_at":"2024-03-13T10:46:32.000Z","size":154,"stargazers_count":143,"open_issues_count":1,"forks_count":25,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-14T03:05:29.516Z","etag":null,"topics":["api","azure","bing","bing-translator","free","javascript","microsoft","microsoft-translator","node","translate","translator"],"latest_commit_sha":null,"homepage":"https://github.com/plainheart/bing-translate-api","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plainheart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-02T04:12:24.000Z","updated_at":"2024-05-21T07:43:43.063Z","dependencies_parsed_at":"2022-06-26T06:34:43.584Z","dependency_job_id":"a7f74978-2888-4858-a717-fd2701d101b0","html_url":"https://github.com/plainheart/bing-translate-api","commit_stats":{"total_commits":99,"total_committers":4,"mean_commits":24.75,"dds":0.04040404040404044,"last_synced_commit":"afd45de363f0e310e9e4eaebce4663f1c8d1c6b8"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plainheart%2Fbing-translate-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plainheart%2Fbing-translate-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plainheart%2Fbing-translate-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plainheart%2Fbing-translate-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plainheart","download_url":"https://codeload.github.com/plainheart/bing-translate-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242681,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","azure","bing","bing-translator","free","javascript","microsoft","microsoft-translator","node","translate","translator"],"created_at":"2024-10-01T11:39:38.334Z","updated_at":"2025-04-04T20:15:25.948Z","avatar_url":"https://github.com/plainheart.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bing-translate-api\n[![NPM version](https://img.shields.io/npm/v/bing-translate-api.svg?style=flat)](https://www.npmjs.org/package/bing-translate-api)\n[![Auto Test](https://github.com/plainheart/bing-translate-api/actions/workflows/autotest.yml/badge.svg)](https://github.com/plainheart/bing-translate-api/actions/workflows/autotest.yml)\n[![NPM Downloads](https://img.shields.io/npm/dm/bing-translate-api.svg)](https://npmcharts.com/compare/bing-translate-api?minimal=true)\n[![License](https://img.shields.io/npm/l/bing-translate-api.svg)](https://github.com/plainheart/bing-translate-api/blob/master/LICENSE)\n\nA **simple** and **free** API for [Bing Translator](https://bing.com/translator) and [Microsoft Translator](https://learn.microsoft.com/azure/ai-services/translator/) for Node.js.\n\n## Install\n\n```\nnpm install bing-translate-api\n```\n\n## Usage\n\n### Microsoft Translator \u003csup\u003e🆕\u003c/sup\u003e\n\nAdded since v4.0.0. More stable and powerful. Both free service and paid service are supported. Feel free to give it a try!\n\nRead the [README](./src/met/README.md) for more details.\n\n### Bing Translator\n\nFrom auto-detected language to English:\n\n```js\nconst { translate } = require('bing-translate-api');\n\ntranslate('你好', null, 'en').then(res =\u003e {\n  console.log(res.translation);\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\nTranslation result\n\n```js\n{\n  // original text\n  \"text\": \"你好\",\n  // user-specified language code\n  \"userLang\": \"auto-detect\",\n  // translated text\n  \"translation\": \"Hello\",\n  // `correctedText` is returned only when `correct` is set as `true`\n  // supported since v1.1.0\n  \"correctedText\": \"\",\n  // detected language\n  \"language\": {\n    // language code of translated text\n    \"to\": \"en\",\n    // detected language code of original text\n    \"from\": \"zh-Hans\",\n    // score of language detection\n    // supported since v1.1.0\n    \"score\": 1\n  }\n}\n```\n\n## API\n\n### translate(text, [from], [to], [correct], [raw], [userAgent], [proxyAgents])\n\n#### _text_\nType: `string`\n\nThe text to be translated, can't be blank. The **maximum** text length is **1000**.\n\n**NOTE:**\n1) The maximum text length is up to **5000** characters only in **China**.\n2) In EPT mode (since `v3.0.0`), the maximum text length is currently **3000**.\n\n##### _from_\nType: `string` Default: `auto-detect`\n\nThe language code of source text.\n\n**MUST** be `auto-detect` or one of the codes/names (not case sensitive) contained in [lang.json](src/lang.json)\n\n**NOTE:** The EPT mode (since `v3.0.0`) only supports the languages contained in [src/config.json#eptLangs](src/config.json#L31). Any other language will fall back to the legacy mode, in which a 429 (Too Many Requests) error often occurs.\n\n##### _to_\nType: `string` Default: `en`\n\nThe language in which the text should be translated.\n\n**MUST** be one of the codes/names (not case sensitive) contained in [lang.json](src/lang.json).\n\n**NOTE:** The EPT mode (since `v3.0.0`) only supports the languages contained in [src/config.json#eptLangs](src/config.json#L31). Any other language will fall back to the legacy mode, in which a 429 (Too Many Requests) error often occurs.\n\n##### _correct_\nType: `boolean` Default: `false` Since: `v1.1.0`\n\nWhether to correct the input text.\n\nNote that:\n1) There is currently a **limit** of **50 characters** for correction service.\n2) **Only** [the languages in the list](src/config.json#L9-L30) are supported to be corrected.\n\n##### _raw_\nType: `boolean` Default: `false`\n\nWhether the translation result contains raw response from Bing API.\n\n##### _userAgent_\nType: `string`\n\nThe header value of `user-agent` used in API requests. \n\nRefer to [src/config.json#userAgent](src/config.json#L111) for the default user agent.\n\n##### _proxyAgents_\nType: [`Got['Agents']`](https://github.com/sindresorhus/got/blob/v11.8.6/source/core/index.ts#L60-L64) Default: `undefined` Since: `v2.4.0`\n\nSet [agents](https://github.com/sindresorhus/got/blob/main/documentation/tips.md#proxying) of [`got`](https://github.com/sindresorhus/got) for proxy.\n\n## License\n\nMIT \u0026copy; 2021-2025 [plainheart](https://github.com/plainheart).\n\n## Thanks\n\nGreat thanks to [Bing Translator](https://bing.com/translator) for providing such an excellent translation service.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplainheart%2Fbing-translate-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplainheart%2Fbing-translate-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplainheart%2Fbing-translate-api/lists"}