Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Translator API Cognitive Services - What is the correct endpoint?

The Microsoft Azure portal for TextTranslator provides the following endpoint:

https://api.cognitive.microsoft.com/sts/v1.0

Yet this endpoint returns a 200 for issueToken and 404 for Translate. The samples refer to an endpoint of:

https://api.microsofttranslator.com/v2/http.svc/

The docs being out of date given the translator ending in the datamarket was my initial assumption. However, the doc endpoint returns for the Translate method.

http://docs.microsofttranslator.com/text-translate.html#!/default/get_Translate

Which endpoint is it that we should use?

If supposed to use the api.microsofttranslator.com then what is the api.cognitive.microsoft.com in azure for?

like image 445
DaveWilliamson Avatar asked Dec 19 '16 16:12

DaveWilliamson


People also ask

What is API cognitive Microsoft Translator?

Translator, part of Azure Cognitive Services, is a cloud-based machine translation service that can be used to build applications, websites, tools, or any solution requiring multi-language support. Built for business, Translator is a proven, customizable, and scalable technology for machine translation.

How do I use Azure translation API?

Prerequisites. Once you have your Azure subscription, create a Translator resource in the Azure portal. After your resource deploys, select Go to resource and retrieve your key and endpoint. You need the key and endpoint from the resource to connect your application to the Translator service.

Which cognitive service is used for translating text from on language to another?

Translator Service is a cloud-based neural machine translation service that is part of the Azure Cognitive Services family of REST APIs.

What Azure cognitive services API can currently do?

Azure Cognitive ServicesTranscribe audible speech into readable, searchable text. Convert text to lifelike speech for more natural interfaces. Integrate real-time speech translation into your apps. Identify and verify the people speaking based on audio.


2 Answers

You can use Microsoft Translator API in 2 ways (see the docs):

  • in 1 step: invoke (GET) https://api.microsofttranslator.com/V2/Http.svc/Translate?text=Neoliberismo&from=it&to=en, passing Ocp-Apim-Subscription-Key: your_subscription_key as request header
  • in 2 steps, with OAuth:
    • invoke (POST) https://api.cognitive.microsoft.com/sts/v1.0/issueToken, passing Subscription-Key=your_subscription_key as query parameter or better passing Ocp-Apim-Subscription-Key: your_subscription_key as request header
    • you'll get a token that expires after 10 minutes
    • invoke (GET) https://api.microsofttranslator.com/V2/Http.svc/Translate?text=Neoliberismo&from=it&to=en, passing Authorization: Bearer the_token as request header
like image 59
bluish Avatar answered Oct 23 '22 06:10

bluish


For the translator API, you need to first get an auth token (first link), and with this token you can call the Translate api (second link).

You can learn more about the auth step here.

like image 20
cthrash Avatar answered Oct 23 '22 05:10

cthrash