All Products
Search
Document Center

Using REST API

Last Updated: Jun 10, 2020

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\": \"en\",\n" +
  9. " \"TargetLanguage\": \"zh\",\n" +
  10. " \"SourceText\": \"Hello\",\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"}

Character Encoding

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