{"id":13438807,"url":"https://github.com/matheuss/google-translate-api","last_synced_at":"2025-05-14T02:08:36.187Z","repository":{"id":8469019,"uuid":"58514850","full_name":"matheuss/google-translate-api","owner":"matheuss","description":"A free and unlimited API for Google Translate :dollar::no_entry_sign:","archived":false,"fork":false,"pushed_at":"2024-07-22T05:57:54.000Z","size":37,"stargazers_count":2996,"open_issues_count":88,"forks_count":622,"subscribers_count":61,"default_branch":"master","last_synced_at":"2025-05-06T15:19:34.866Z","etag":null,"topics":["api","free","google","javascript","translate"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/google-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/matheuss.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":"2016-05-11T04:43:13.000Z","updated_at":"2025-05-06T07:16:20.000Z","dependencies_parsed_at":"2023-01-16T20:16:02.417Z","dependency_job_id":"0b33cb31-1ba1-488d-a9d8-2d80c74abab8","html_url":"https://github.com/matheuss/google-translate-api","commit_stats":{"total_commits":51,"total_committers":6,"mean_commits":8.5,"dds":"0.21568627450980393","last_synced_commit":"777d7db94f82ec402e7758af1549818c07d55747"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheuss%2Fgoogle-translate-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheuss%2Fgoogle-translate-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheuss%2Fgoogle-translate-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheuss%2Fgoogle-translate-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matheuss","download_url":"https://codeload.github.com/matheuss/google-translate-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254053178,"owners_count":22006717,"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","free","google","javascript","translate"],"created_at":"2024-07-31T03:01:08.592Z","updated_at":"2025-05-14T02:08:31.169Z","avatar_url":"https://github.com/matheuss.png","language":"JavaScript","readme":"# google-translate-api [![Build Status](https://travis-ci.org/matheuss/google-translate-api.svg?branch=master)](https://travis-ci.org/matheuss/google-translate-api) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) [![Coverage Status](https://coveralls.io/repos/github/matheuss/google-translate-api/badge.svg?branch=master)](https://coveralls.io/github/matheuss/google-translate-api?branch=master) [![Known Vulnerabilities](https://snyk.io/test/npm/google-translate-api/badge.svg)](https://snyk.io/test/npm/google-translate-api)\n\nA **free** and **unlimited** API for Google Translate :dollar::no_entry_sign:\n\n## Features \n\n- Auto language detection\n- Spelling correction\n- Language correction \n- Fast and reliable – it uses the same servers that [translate.google.com](https://translate.google.com) uses\n\n## Install \n\n```\nnpm install --save google-translate-api\n```\n\n## Usage\n\nFrom automatic language detection to English:\n\n``` js\nconst translate = require('google-translate-api');\n\ntranslate('Ik spreek Engels', {to: 'en'}).then(res =\u003e {\n    console.log(res.text);\n    //=\u003e I speak English\n    console.log(res.from.language.iso);\n    //=\u003e nl\n}).catch(err =\u003e {\n    console.error(err);\n});\n```\n\nFrom English to Dutch with a typo:\n\n``` js\ntranslate('I spea Dutch!', {from: 'en', to: 'nl'}).then(res =\u003e {\n    console.log(res.text);\n    //=\u003e Ik spreek Nederlands!\n    console.log(res.from.text.autoCorrected);\n    //=\u003e true\n    console.log(res.from.text.value);\n    //=\u003e I [speak] Dutch!\n    console.log(res.from.text.didYouMean);\n    //=\u003e false\n}).catch(err =\u003e {\n    console.error(err);\n});\n```\n\nSometimes, the API will not use the auto corrected text in the translation:\n\n``` js\ntranslate('I spea Dutch!', {from: 'en', to: 'nl'}).then(res =\u003e {\n    console.log(res);\n    console.log(res.text);\n    //=\u003e Ik spea Nederlands!\n    console.log(res.from.text.autoCorrected);\n    //=\u003e false\n    console.log(res.from.text.value);\n    //=\u003e I [speak] Dutch!\n    console.log(res.from.text.didYouMean);\n    //=\u003e true\n}).catch(err =\u003e {\n    console.error(err);\n});\n```\n\n## API\n\n### translate(text, options)\n\n#### text\n\nType: `string`\n\nThe text to be translated\n\n#### options\n\nType: `object`\n\n##### from\n\nType: `string` Default: `auto`\n\nThe `text` language. Must be `auto` or one of the codes/names (not case sensitive) contained in [languages.js](https://github.com/matheuss/google-translate-api/blob/master/languages.js)\n\n##### to\n\nType: `string` Default: `en`\n\nThe language in which the text should be translated. Must be one of the codes/names (not case sensitive) contained in [languages.js](https://github.com/matheuss/google-translate-api/blob/master/languages.js).\n\n##### raw\n\nType: `boolean` Default: `false`\n\nIf `true`, the returned object will have a `raw` property with the raw response (`string`) from Google Translate.\n\n### Returns an `object`:\n\n- `text` *(string)* – The translated text.\n- `from` *(object)*\n  - `language` *(object)*\n    - `didYouMean` *(boolean)* - `true` if the API suggest a correction in the source language\n    - `iso` *(string)* - The [code of the language](https://github.com/matheuss/google-translate-api/blob/master/languages.js) that the API has recognized in the `text`\n  - `text` *(object)*\n    - `autoCorrected` *(boolean)* – `true` if the API has auto corrected the `text`\n    - `value` *(string)* – The auto corrected `text` or the `text` with suggested corrections\n    - `didYouMean` *(booelan)* – `true` if the API has suggested corrections to the `text`\n- `raw` *(string)* - If `options.raw` is true, the raw response from Google Translate servers. Otherwise, `''`.\n\nNote that `res.from.text` will only be returned if `from.text.autoCorrected` or `from.text.didYouMean` equals to `true`. In this case, it will have the corrections delimited with brackets (`[ ]`):\n\n``` js\ntranslate('I spea Dutch').then(res =\u003e {\n    console.log(res.from.text.value);\n    //=\u003e I [speak] Dutch\n}).catch(err =\u003e {\n    console.error(err);\n});\n```\nOtherwise, it will be an empty `string` (`''`).\n\n## Related\n\n- [`vertaler`](https://github.com/matheuss/vertaler) – CLI for this module\n\n## License\n\nMIT © [Matheus Fernandes](http://matheus.top)\n","funding_links":[],"categories":["HarmonyOS","Uncategorized","JavaScript"],"sub_categories":["Windows Manager","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatheuss%2Fgoogle-translate-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatheuss%2Fgoogle-translate-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatheuss%2Fgoogle-translate-api/lists"}