Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including google-translate-token-v2 with all npm packages installed. Try it out:

var googleTranslateTokenV2 = require("google-translate-token-v2")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

google-translate-token-v2 v1.0.1

A package that generates the necessary token to use the Google Translate API for free

google-translate-token Build Status XO code style Known Vulnerabilities

A package that generates the necessary token to use the Google Translate API for free :dollar::no_entry_sign:

Why

translate.google.com uses a token to authorize the requests. If you are not Google, you do not have this token and will have to pay $20 per 1 million characters of text.

This package is the result of reverse engineering on the obfuscated and minified code used by Google to generate such token.

How it works

The token is based on a seed which is updated once per hour and on the text that will be translated. Both are combined – by some strange math – in order to generate a final token (e.g. 820594.703830) which is used by the API to validade the request.

Install

npm install --save google-translate-token

Usage

const token = require('google-translate-token');

token.get('Hello').then(console.log);
//=> { name: 'tk', value: '159402.284291' }

Related

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free