API Tutorial: Microsoft’s Text Translator with Rakuten RapidAPI

Microsoft’s Text Translation API is a favorite rest API among devs for a reason. It works well, and it has some really neat features. Ebay and Etsy are a couple of big names that are using this direct competitor of Google Translate and Yandex Translator, both of which are also offered by Rakuten RapidAPI.

Microsoft Azure’s offering features language detection and translation across 64 languages. The request structure is super simple, and easy to use. And, as a cherry on top, it is among very few talking translators out there. It has this cool feature that returns an Mp4 track of the text being spoken in the target language.

Getting the Javascript Code

All the javascript you need for the API integration is wrapped up in an easy unirest SDK, a library to simplify HTTP REST requests and that saves you time remaking the wheel (rewriting code).

Get started by installing the unirest package with the following command:

npm install unirest --save

As soon as that’s done, you can start exploring the API. **It’s safe to ignore the npm warn messages at this point if you see any.**

Sign Up to the Microsoft Translation & Aylien APIs

Both offer free dev accounts, and you only need one API key to access both APIs through Rakuten RapidAPI — the world’s largest restful API marketplace. With 8,000+ third-party APIs and used by over 500,000 active developers, we enable developers to build transformative apps through the power of APIs. Find, test and connect to all the services you need in one place!

We’ve also got you covered with super simple integration. You can try it without leaving the browser. You’ll need to sign up to get the API keys. Then you’ll be able to make and authenticate the requests, and we’ll know they’re coming from you.

As soon as you sign-in with your account, the view above will be replaced with another view, where you can see your API keys (X-RapidAPI-Key) in the Request Headers section and a ready to copy snippet of code at the right side.

Rakuten RapidAPI Access Overview

It offers five endpoints, each of which covers a specific feature that you can use:

Translate: Translate a string of text.

Speak: Returns an Mp4 of the translated text being spoken in the target language.

getTranslateSupportedLanguages: Get a list of supported languages for text translation.

getSpeakSupportedLanguages: Get a list of supported languages for spoken translation.

detectLanguage: Detect the language in the text.

breakSentences: Break sentences in text into substrings.

Article Translator

We’re going to make something that is both simple and useful. When we’re done, this script will take a URL to an article, and with that it will extract the article and then translate it to the target language.

Let’s get started.

Extract Article:

It would be nice if we had a simple string to work with, and thanks to Aylien, we just need an article’s URL to get the string we’re after. This is the only call to the Aylien API that we’ll make, but it makes our app cooler, so why not? Here’s what we’re starting with — an Italian news article that I can’t read, formatting and all:

Query Params:

API key

string

Your API key.

Aylien Base URL

string

The base URL for Aylien’s article extraction service.

Translate Base URL

string

The base URL for Microsoft’s translator API.

Article URL

string

The URL that points to the article we want to work with.

Upon successful completion, we’ll receive the following response body. **Note: the full text is included in the actual response. I’ve abridged it here for the sake of space.**

Response body:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">"The risk is always there, no one can know what ² will come out from this vote ... Â». The great fear that kept us awake Luigi di Maio loyalists are locked in what Mr Emilio Carelli, one of many lawmakers who did not appreciate the delegation to the network: Â «Ã an act of courage, but the platform Rousseau if they could evitareÂ». On the day of the verdict, entrusted to Â «sacred blogÂ» of Casaleggio Associati, the political leader gets weak as never before, driving a Movement mauled. Guaranteed against an overzealous sense of Justice. Figuratively pro-Salvini against Orthodox neighbors to Roberto Fico. An internal clash that threatens the holding of the majority and the leadership of Dart. The blue Deborah Bergamini puts it thus: Â «On Rousseau is deciderÃ if you bring down the Government or whether to drop By MaioÂ».

That’s it!

You’re ready to make all kinds of things accessible for and useful to all kinds of people!! Feel free to use any or all of the above snippits as you like. Check out the thousands more building blocks that are equally simple to access.

About Rakuten Rapid API

The world’s largest API marketplace with 8,000+ third-party APIs and used by over 500,000 active developers. We enable developers to build transformative apps through the power of APIs. Find, test and connect to all the APIs you need in one place!

Definitely imaqgine tat which you said. Your favorite reason seemed to
be on thee nnet thee easiest thing to bear in mind of. I say to you,
I definitely get irked aat the same time as othr folks
think about concerns that they plainly don’t understand about.
You controlled to hit the nail upon thhe top andd defined out tthe entire thing with no need side effect , people could take a
signal. Will probably be again to get more. Thanks

Hiya very nice site!! Man .. Beautiful .. Wonderful ..
I’ll bookmark your website and take the feeds additionally?
I’m satisfied to find a lot of useful information right here within the put up, we’d like develop more techniques on this regard, thanks for sharing.

I would like to thank you for thee efforts you’ve put in writing this website.
I’m hoping thee same high-grade website post from you in the
upcoming also. In fact your creative writing skills has encouraged
me to get my own web site now. Really the blogging is spreading its wings fast.
Your write up is a great example of it.