Thursday, April 26, 2012

How to use the new Bing translator API with access tokens

Updated on December 6th 2017 to use Microsoft Azure accounts

Bing translator has changed its API recently again to migrate to the new Azure accounts on Before this version, we used accounts on Azure Data Market. The new API still requires you to get an access token first before using any Bing service. The URL and parameters are changed to use the new Azure accounts.

Step 0: sign up for a Microsoft Azure account 

To access the Microsoft Translator Text API you will need to sign up for Microsoft Azure. Follow these steps.
  1. Sign up for a Microsoft Azure account at
  2. After you have an account go to
  3. Select the + New option.
  4. Select AI + Cognitive Services from the list of services.
  5. Select Translator Text API. You may need to click "See all" or search to see it.
  6. Fill out the rest of the form, and select the Create button.
  7. You are now subscribed to Microsoft Translator Text API.
  8. Go to All Resources and select the Microsoft Translator API you subscribed to.
  9. Go to the Keys option and copy your subscription key to access the service.

Step 1: get access token

$ curl --header 'Ocp-Apim-Subscription-Key: [Your-Azure-subscription-key]' --data "" ''

After this curl command, you will get an access token which is valid for a short period.

For the details about this step, please refer to:

Step 2: get translation using the obtained access token 

curl -i -H "Authorization: Bearer [access-token-obtained-in-step-1]" ""

You will get some output from curl like (the last line is the real HTTP response):

HTTP/1.1 200 OK 
Content-Length: 83 
Content-Type: application/xml; 
X-MS-Trans-Info: 0916.V2_Rest.Translate.1D6C05C5 
Date: Mon, 10 Apr 2017 17:50:43 GMT 

<string xmlns="">哈哈</string>


(1) For details about the Microsoft Translation APIs:

(2) For details about what languages are supported and what languages are using Neural Machine Translation (NMT) models:


Translator Jobs said...

great, the bing API is useful.

Anonymous said...

Thanks, it helped me build my tiny application.

trikthemaster said...

hello, could you provide php code from requesting token, until getting the translation result?

thanks in advance

Upeksha Wisidagama said...

Very clear instructions. Thanks Wang.

biovamps said...
and you can see the demo also

AD said...

Wang, thanks for providing clarity. I'm able to get the access_token (using perl). My access_token is a very large string, starts with http and contains "%" characters ..its kind of a big http url.
Is that how it should be?


trikthemaster said...

I tried the code from:

I believe it doesn't have script to renew the token. I visited the demo too, and it happened to work only for several minutes.

Valerio Morgante said...

make a translation, is a GET request

Marco said...

masina s-a stricat, trebuie s-o repar

Anonymous said...

Can you post how to do the same with web searches. thx dude

Anonymous said...

omg this info is pointless for noobs (me me me me me). it's all so bloody confusing :(


Louis Martin said...

Technical Translation Services

Thanks for sharing this wonderful and useful information,Please keep updating.

Megha Sharma said...

mba courses in india

I trust it doesn't have content to restore the token. I went by the demo as well, and it happened to work just for a few minutes.