GetTranslationsArray Method

Use the GetTranslationsArray method to retrieve multiple translation candidates for multiple source texts.

Request URI

URI parameters
Parameter Description


Required. A string containing "Bearer" + " " + access token.


Required. An array containing the texts for translation. All strings must be of the same language. The total of all texts to be translated must not exceed 10000 characters. The maximum number of array elements is 10.


Required. A string representing the language code of the translation text.


Required. A string representing the language code to translate the text into.


Required. An int representing the maximum number of translations to return.


Optional. A TranslateOptions object which contains the values listed below. They all default to the most common settings. You do not need to set any of the values.
  • Category: A string containing the category (domain) of the translation. Defaults to "general".
  • ContentType: A string containing the type of content. Either "text/html" or "text/plain". Defaults to "text/plain".
  • Uri: A string containing the content location of this translation.
  • User: A string used to track the originator of the submission.
  • State: User state to help correlate request and response. The same contents will be returned in the response.

Name Description
Array of GetTranslationsResponse Returns a GetTranslationsResponse array. Each GetTranslationsResponse has the following elements:
  • Translations: An array of matches found, stored in TranslationMatch (see below) objects. The translations may include slight variants of the original text (fuzzy matching). The translations will be sorted: 100% matches first, fuzzy matches below.
  • From: If the method did not specify a From language, this will be the result of auto language detection. Otherwise it will be the given From language.
  • State: User state to help correlate request and response. Contains the same value as given in the TranslateOptions parameter.
TranslationMatch A TranslationMatch object consists of the following:
  • Error: If an error has occurred for a specific input string, the error code is stored. Otherwise the field is empty.
  • MatchDegree: The system matches input sentences against the store, including inexact matches. MatchDegree indicates how closely the input text matches the original text found in the store. The value returned ranges from 0 to 100, where 0 is no similarity and 100 is an exact case sensitive match.
  • MatchedOriginalText: Original text that was matched for this result. Only returned if the matched original text was different than the input text. Used to return the source text of a fuzzy match. Not returned for Microsoft Translator results.
  • Rating: Indicates the authority of the person making the quality decision. Machine Translation results will have a rating of 5. End user submitted translations will generally have a rating of 1 to 4, whilst webmaster approved translations will generally have a rating of 6 to 10.
  • Count: The number of times this translation with this rating has been selected by the users. The value will be 0 for the automatically translated response.
  • TranslatedText: The translated text.

Ff512403.alert_note(en-us,MSDN.10).gif Note

Bing App ID is deprecated and is no longer supported.   Please obtain an access token to use the Microsoft Translator API. For details, go here.


Obtain an Access Token on the server-side

public static AdmAccessToken GetAccessToken()
    AdmAccessToken admToken;
    string headerValue;
    //Get Client Id and Client Secret from
    AdmAuthentication admAuth = new AdmAuthentication("clientid", "clientsecret");

    admToken = admAuth.GetAccessToken();
    // Create a header with the access_token property of the returned token
    headerValue = "Bearer" + " " + HttpUtility.UrlEncode(admToken.access_token);

    return admToken;
Invoke the AJAX method on the client-side

<html xmlns="">
<head runat="server">
    <script type="text/javascript">
        var languageFrom = "es";
        var languageTo = "en";
        var texts = "[\"" + encodeURIComponent("a veces los errores son divertidos") + "\", \"" +
                               encodeURIComponent("una importante contribución a la rentabilidad de la empresa") + "\"]";
        var sourceText = new Array();
        sourceText[0] = "a veces los errores son divertidos";
        sourceText[1] = "una importante contribución a la rentabilidad de la empresa";
        var maxTranslations = 5;
        var options = "{\"User\":\"TestUserId\"}";
        function getTranslationsArray() {
            PageMethods.GetAccessToken(OnSucceeded, OnFailed);
        function OnSucceeded(result, usercontext, methodName) {
            window.mycallback = function (response) {
                var array = response;
                var translations = "";
                for (var i = 0; i < array.length; i++) {
                    translations = translations + "<br /><br />Source text: " + sourceText[i] + "<br />";
                    for (var count = 0; count < array[i].Translations.length; count++) {

                        translations = translations + "Matched original text: " + array[i].Translations[count].MatchedOriginalText +
                          "<br />Translated text: " + array[i].Translations[count].TranslatedText +
                          "<br />Match degree: " + array[i].Translations[count].MatchDegree +
                          "<br />Rating: " + array[i].Translations[count].Rating +
                          "<br />count: " + array[i].Translations[count].Count + "<br />";
                document.getElementById('<%= lblResult.ClientID %>').innerHTML = translations;
            var s = document.createElement("script");
            s.src = " " + encodeURIComponent(result.access_token) + "&texts=" + texts + "&from=" + languageFrom +
                        "&to=" + languageTo + "&maxTranslations=" + maxTranslations + "&options=" + options;
        function OnFailed(error, userContext, methodName) {
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager" runat="server" EnablePageMethods="true" />
        <asp:Button ID="buttonGetTransArray" runat="server" Text="GetTranslationsArray" OnClientClick="getTranslationsArray();return false;" />
        <br />
        <asp:Label ID="lblResult" runat="server"></asp:Label>