The request body is a JSON string, and the service returns a JSON string. For specific requirements, see the documentation for each API operation. The following is a sample request in Java:Service endpoint
Region | Endpoint |
Hangzhou | mt.cn-hangzhou.aliyuncs.com |
HTTP API endpoint
http://mt.cn-hangzhou.aliyuncs.com/api/resourceNormal Return
A successful request returns a JSON string.
An error response has the format {"errorCode":"errorCode","errorMsg":"error message"}.
Requests and responses are encoded in the UTF-8 character set.
Request body and response
public static void main(String[] args) {
String serviceURL = "http://mt.cn-hangzhou.aliyuncs.com/api/resource";
String accessKeyId = "";// Use your Alibaba Cloud AccessKey ID
String accessKeySecret = ""; // Use your Alibaba Cloud AccessKey secret
String postBody = "{\n" +
" \"ApiName\": \"imageTranslate\",\n" +
" \"Params\": {\n" +
" \"extra\": \" {\\\"without_text\\\":\\\"true\\\"}\",\n" +
" \"sourceLanguage\": \"zh\",\n" +
" \"targetLanguage\": \"en\",\n" +
" \"url\": \"https://img.alicdn.com/imgextra/i4/388322682/O1CN011VgOhz82ye0dlh0_!!388322682.jpg\"\n" +
" }\n" +
"}";
// For the Sender code, see the "Signature method" document.
String result = Sender.sendPost(serviceURL, postBody, accessKeyId, accessKeySecret);
System.out.println(result);
}HTTP API parameters
ApiName | imageTranslate: AI-powered product image translation imageDiagnose: Image diagnosis titleIntelligence: AI-powered title generation titleGenerate: Title optimization titleDiagnose: Title diagnosis |
Params | The specific parameters for each API operation are described below. |
Sample postBody for AI-powered product image translation
{
"ApiName": "imageTranslate",
"Params": {
"extra": " {\"without_text\":\"true\"}",
"sourceLanguage": "zh",
"targetLanguage": "en",
"url": "https://img.alicdn.com/imgextra/i4/388322682/O1CN011VgOhz82ye0dlh0_!!388322682.jpg"
}
}Sample postBody for image diagnosis
{
"ApiName": "imageDiagnose",
"Params": {
"extra": " {\"product_id\":\"12121\"}",
"url": "https://img.alicdn.com/imgextra/i4/388322682/O1CN011VgOhz82ye0dlh0_!!388322682.jpg"
}
}Sample postBody for AI-powered title generation
{
"ApiName": "titleIntelligence",
"Params": {
"catLevel2Id": 111,
"catLevel3Id": 3333,
"extra": " {\"product_id\":\"12121\"}",
"keywords": "hello,apple",
"platform": "ae"
}
}Sample postBody for title optimization
{
"ApiName": "titleGenerate",
"Params": {
"attributes": {
"2": "None",
"10": "Plastic"
},
"categoryId": 111,
"extra": " {\"product_id\":\"12121\"}",
"hotWords": "watch,apple",
"language": "en",
"platform": "ae",
"title": "apple watch is good"
}
}Sample postBody for title diagnosis
{
"ApiName": "titleDiagnose",
"Params": {
"categoryId": 111,
"extra": " {\"product_id\":\"12121\"}",
"language": "en",
"platform": "ae",
"title": "apple watch is good"
}
}该文章对您有帮助吗?