US-美国站; CA-加拿大站; MX-墨西哥站; UK-英国站; DE-德国站; FR-法国站; IT-意大利站; ES-西班牙站; JP-日本站; IN-印度站;
{
"code": "OK",
"data": {
"marketplace": "US",
"asin": "B0031M9H30",
"keywords": [
{
"search_volume": 236358,
"keyword": "garbage can",
"search_weight": 94
},
{
"search_volume": 204233,
"keyword": "kitchen trash can",
"search_weight": 94
}
],
"variations": [
{
"asin": "B00JWQ5NF0",
"attribute": "13 Gal $71.99",
"traffic_words_num": 241
},
{
"asin": "B0031M9H30",
"attribute": "18 Gal from 16 sellers",
"traffic_words_num": 409
}
],
"frequencies": [
{
"word": "trash",
"frequency": 149
},
{
"word": "can",
"frequency": 126
}
],
"product_information": {
"image": "https://images-na.ssl-images-amazon.com/images/I/41cX73-LylL._SS200_.jpg",
"marketplace": "US",
"asin": "B0031M9H30",
"available_date": "20200908",
"title": "NINESTARS DZT-70-11R Automatic Touchless Infrared Motion Sensor Trash Can/Recycler, 18 Gal 70L, Stainless Steel Base (D Shape, Silver/Black Lid)",
"brand": "Ninestars"
}
},
"message": ""
}
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.security.MessageDigest;
public class AsinSeedApiTest {
private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static final String PARTNER_CODE = "test";
private static final String PARTNER_SECRET_KEY = "7442a95a-b804-4929-af93-fb73e51f8d4a";
private static String byteArrayToHexString(byte[] byteArray) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < byteArray.length; i++) {
int n = byteArray[i];
n = n < 0 ? n + 256 : n;
resultSb.append(HEX_CHAR[n / 16]).append(HEX_CHAR[n % 16]);
}
return resultSb.toString();
}
private static String encode(String origin) {
String output = null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
output = byteArrayToHexString(md.digest(origin.getBytes("UTF-8")));
} catch (Throwable e) {
e.printStackTrace();
}
return null != output ? output.substring(0, 12) : "";
}
public static void main(String[] args) {
String marketplace = "US";
String asin = "B017H39S5U";
String partner = PARTNER_CODE;
String qid = marketplace + "_" + asin + "_" + PARTNER_SECRET_KEY;
qid = encode(qid);
String urlStr = "https://www.asinseed.com/api/" + marketplace + "/" + asin + "/" + partner + "/" + qid;
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(urlStr);
try {
HttpResponse response = httpClient.execute(httpGet);
HttpEntity responseEntity = response.getEntity();
if (null != responseEntity) {
String responseJsonStr = EntityUtils.toString(responseEntity, "UTF-8");
JSONObject result = JSON.parseObject(responseJsonStr);
String code = result.getString("code");
if ("ok".equalsIgnoreCase(code)) {
JSONObject data = result.getJSONObject("data");
JSONArray keywords = data.getJSONArray("keywords");
//TODO your custom business logic
System.out.println(keywords.toJSONString());
} else {
String errMsg = result.get("message").toString();
//TODO handle the error msg from api
System.out.println("errorMs=>" + errMsg);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}