Skip to content

Instantly share code, notes, and snippets.

@MaximKhlobystov
Created September 24, 2015 17:34
Show Gist options
  • Save MaximKhlobystov/c14fd8845324d446791c to your computer and use it in GitHub Desktop.
Save MaximKhlobystov/c14fd8845324d446791c to your computer and use it in GitHub Desktop.
needle + Yandex.Translate API example.
var needle = require("needle");
var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=" + key + "&lang=" + lang + "&text=" + words[0];
for(var i = 1; i < words.length; i++) {
url += ("%3F&text=" + words[i]);
}
needle.get(url, function(e, r) {
// handling the response here
}
// key - your API key, lang - target language, words - array of words to translate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment