All Products
Search
Document Center

Using REST API

Last Updated: Jul 05, 2019

Request Structure

Service Address

Territory Access Address
hangzhou mt.cn-hangzhou.aliyuncs.com

Request body and return result

The request body is a json structure string, and the service return is also a json string. For details, refer to each API document. Example request (java):

  1. public class SampleRequest {
  2. public static void main(String[] args) {
  3. String serviceURL = "http://mt.cn-hangzhou.aliyuncs.com/api/translate/web/ecommerce";
  4. String accessKeyId = "<yourAccessKeyId>";// AccessKeyId
  5. String accessKeySecret = "<yourAccessKeySecret>"; // accessKeySecret
  6. String postBody = "{\n" +
  7. " \"FormatType\": \"text\",\n" +
  8. " \"SourceLanguage\": \"zh\",\n" +
  9. " \"TargetLanguage\": \"en\",\n" +
  10. " \"SourceText\": \"大疆无人机\",\n" +
  11. " \"Scene\": \"title\"\n" +
  12. "}";
  13. // For the Sender code, please refer to the help document "Signature Method"
  14. String result = Sender.sendPost(serviceURL, postBody, accessKeyId, accessKeySecret);
  15. System.out.println(result);
  16. }
  17. }

Machine translated version

API version Access address
General version http://mt.cn-hangzhou.aliyuncs.com/api/translate/web/general
E-commerce version http://mt.cn-hangzhou.aliyuncs.com/api/translate/web/ecommerce

Normal return

Request a normal result as a json string.

Error return

  1. {"errorCode":"errorCode","errorMsg":"error message"}

Request length limit

For details on request length restrictions, please refer to [Development Guide] (https://help.aliyun.com/document_detail/96385.html?spm=a2c4g.11186623.6.548.6f58256bmGkmc0)

Character Encoding

Both the request and the return result are encoded using the UTF-8 character set.