{"id":27164813,"url":"https://github.com/chewawi/microsoft-translate-api","last_synced_at":"2025-10-27T02:18:04.748Z","repository":{"id":231994069,"uuid":"783201151","full_name":"Chewawi/microsoft-translate-api","owner":"Chewawi","description":"A simple, powerful and free API for Microsoft Translator for Node.js","archived":false,"fork":false,"pushed_at":"2025-01-15T21:28:21.000Z","size":116,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T14:48:43.041Z","etag":null,"topics":["microsoft","translation"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/microsoft-translate-api","language":"TypeScript","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/Chewawi.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":"2024-04-07T08:07:30.000Z","updated_at":"2025-03-05T11:52:58.000Z","dependencies_parsed_at":"2024-04-07T09:24:37.936Z","dependency_job_id":"61b218cc-bc89-4ef7-a25f-5b9eae75ce3a","html_url":"https://github.com/Chewawi/microsoft-translate-api","commit_stats":null,"previous_names":["chewawi/microsoft-translate-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chewawi%2Fmicrosoft-translate-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chewawi%2Fmicrosoft-translate-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chewawi%2Fmicrosoft-translate-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chewawi%2Fmicrosoft-translate-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chewawi","download_url":"https://codeload.github.com/Chewawi/microsoft-translate-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247966073,"owners_count":21025490,"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":["microsoft","translation"],"created_at":"2025-04-09T02:32:54.687Z","updated_at":"2025-10-27T02:17:59.711Z","avatar_url":"https://github.com/Chewawi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Microsoft Translate API\n\n[![NPM version](https://img.shields.io/npm/v/microsoft-translate-api.svg?style=flat)](https://www.npmjs.org/package/microsoft-translate-api)\n[![Auto Test](https://github.com/chewawi/microsoft-translate-api/actions/workflows/autotest.yml/badge.svg)](https://github.com/chewawi/microsoft-translate-api/actions/workflows/autotest.yml)\n[![Build](https://github.com/chewawi/microsoft-translate-api/actions/workflows/transpile.yml/badge.svg)](https://github.com/chewawi/microsoft-translate-api/actions/workflows/transpile.yml)\n[![NPM Downloads](https://img.shields.io/npm/dm/microsoft-translate-api.svg)](https://npmcharts.com/compare/microsoft-translate-api?minimal=true)\n[![License](https://img.shields.io/npm/l/microsoft-translate-api.svg)](https://github.com/tuusuario/microsoft-translate-api/blob/master/LICENSE)\n\nA stable and powerful zero-dependency **free** translator for [Microsoft Translator](https://learn.microsoft.com/azure/ai-services/translator/) designed for Node.js.\n\n## Install\n\nNPM\n\n```sh\n[npm | bun | pnpm | yarn] install microsoft-translate-api\n```\n\n### Basic Usage\n\n#### Translate from Auto-Detected Language to Another Language\n\n```javascript\nconst { translate } = require('microsoft-translate-api')\n\ntranslate('你好，很高兴认识你！', null, 'en').then(res =\u003e {\n  console.log(res);\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eTranslation result\u003c/summary\u003e\n\n```json\n[\n  {\n    \"detectedLanguage\": {\n      \"language\": \"zh-Hans\",\n      \"score\": 1\n    },\n    \"translations\": [\n      {\n        \"text\": \"Hello, nice to meet you!\",\n        \"to\": \"en\"\n      }\n    ]\n  }\n]\n```\n\n\u003c/details\u003e\n\n#### Translate from Auto-Detected Language to Multiple Languages\n\n```javascript\nconst { translate } = require('microsoft-translate-api')\n\ntranslate('你好，很高兴认识你！', null, ['en', 'ja']).then(res =\u003e {\n  console.log(res);\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eTranslation result\u003c/summary\u003e\n\n```json\n[\n  {\n    \"detectedLanguage\": {\n      \"language\": \"zh-Hans\",\n      \"score\": 1\n    },\n    \"translations\": [\n      {\n        \"text\": \"Hello, nice to meet you!\",\n        \"to\": \"en\"\n      },\n      {\n        \"text\": \"こんにちは、はじめまして!\",\n        \"to\": \"ja\"\n      }\n    ]\n  }\n]\n```\n\n\u003c/details\u003e\n\n#### Translate HTML text\n\n```javascript\nconst { translate } = require('microsoft-translate-api')\n\nconst htmlText = `\n  \u003cdiv class=\"notranslate\"\u003eThis will not be translated.\u003c/div\u003e\n  \u003cdiv\u003eThis will be translated.\u003c/div\u003e\n`;\ntranslate(htmlText, null, 'zh-Hans', {\n  translateOptions: {\n    // Explicitly set textType as `html`. Defaults to `plain`.\n    textType: 'html'\n  }\n}).then(res =\u003e {\n  console.log(res);\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eTranslation result\u003c/summary\u003e\n\n```json\n[\n  {\n    \"detectedLanguage\": {\n      \"language\": \"en\",\n      \"score\": 1\n    },\n    \"translations\": [\n      {\n        \"text\": \"\u003cdiv class=\\\"notranslate\\\"\u003eThis will not be translated.\u003c/div\u003e\\n\u003cdiv\u003e这将被翻译。\u003c/div\u003e\",\n        \"to\": \"zh-Hans\"\n      }\n    ]\n  }\n]\n```\n\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\n### Optional Translation Options\n\n\u003e [Reference](https://learn.microsoft.com/azure/ai-services/translator/reference/v3-0-translate#optional-parameters)\n\n```typescript\ninterface TranslateOptions {\n  translateOptions?: Record\u003cstring, object\u003e;\n  authenticationHeaders?: Record\u003cstring, string\u003e;\n  userAgent?: string;\n  fetchOptions?: RequestInit;\n}\n```\n\n### Full Translation Results\n\n\u003e [Reference](https://learn.microsoft.com/azure/ai-services/translator/reference/v3-0-translate#response-body)\n\n```typescript\ninterface TranslationResult {\n  translations: {\n    text: string;\n    to: string;\n    sentLen?: {\n      srcSentLen: number[];\n      transSentLen: number[];\n    };\n    transliteration?: {\n      script: string;\n      text: string;\n    };\n    alignment?: object;\n  }[];\n  detectedLanguage?: {\n    language: string;\n    score: number;\n  };\n}\n```\n\n\u003cbr/\u003e\n\n### Supported Languages\n\nRefer to [langs](src/lib/langs.ts).\n\n### Service Limits\n\n[Character and array limits per request](https://learn.microsoft.com/azure/ai-services/translator/service-limits#character-and-array-limits-per-request)\n\n\u003cbr/\u003e\n\n\u003e [!NOTE]\n\u003e Note that the correction service is not available.\n\n\n\u003cbr/\u003e\n\n### Use Paid Service With Your Private Keys\n\n```javascript\nconst { translate } = require('microsoft-translate-api')\n\ntranslate('你好，很高兴认识你！', null, 'en', {\n  authenticationHeaders: {\n    // Use private subscription key\n    'Ocp-Apim-Subscription-Key': 'YOUR KEY',\n    // Or use a JWT token\n    'Authorization': 'YOUR TOKEN'\n  }\n}).then(res =\u003e {\n  console.log(res);\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\nSee also [Authentication](https://learn.microsoft.com/azure/ai-services/translator/reference/v3-0-reference#authentication)\n\n\u003e [!NOTE]\n\u003e Note that using your private keys, the translator will skip to fetch the free authorization and you will have to check if the authorization is expired by yourself.\n\n\u003cbr/\u003e\n\n## Thanks\n\u003e\n\u003e [bing-translate-api](https://github.com/plainheart/bing-translate-api/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchewawi%2Fmicrosoft-translate-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchewawi%2Fmicrosoft-translate-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchewawi%2Fmicrosoft-translate-api/lists"}