请求地址: api-gw.onebound.cn/lazada/item…
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
key | String | 是 | 调用key(必须以GET方式拼接在URL中) |
secret | String | 是 | 调用密钥 |
api_name | String | 是 | API接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等] |
cache | String | 否 | [yes,no]默认yes,将调用缓存的数据,速度比较快 |
result_type | String | 否 | [json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读 |
lang | String | 否 | [cn,en,ru]翻译语言,默认cn简体中文 |
version | String | 否 | API版本 |
请求参数:num_iid=267690734&nation=co.th
参数说明:num_iid:lazada商品ID(是对应国家不同国家的ID不能通用)
nation:国家
国家域名后缀可选值如下:co.id、com.my、com.ph、sg、co.th、vn
Version: Date:
名称 | 类型 | 必须 | 示例值 | 描述 |
---|---|---|---|---|
item | item[] | 0 | 获得lazada商品详情 | |
num_iid | String | 0 | 267690734 | 宝贝ID |
title | String | 0 | 中国新年假期交付63年2月2日!!城市豪宅鞋鞋高跟鞋男士正商务正装男士鞋鞋牛津牛津向左急转福特男性电影ShoeFree。 | 商品标题 |
price | Float | 0 | 7.70 | 价格 |
nick | String | 0 | URBAN SAFARI | 卖家昵称 |
pic_url | String | 0 | //my-test-11.slatic.net/original/208de91b5132477f8a723c82c56c3a58.jpg | 宝贝图片 |
detail_url | String | 0 | www.lazada.co.th/products/2-… | 宝贝链接 |
brand | String | 0 | MAJE | 品牌 |
orginal_price | Float | 0 | 7.70 | 原价 |
skus | Mix | 0 | {"sku": [{"properties": "0:0", "properties_name": "0:0:颜色:小号", "price": "7.70", "orginal_price": "7.70", "quantity": 716, "sku_id": 3184603612387 }]} | 商品规格信息列表 |
props_name | String | 0 | 0:0:小号:;0:1:中号:;0:2:大号: | 商品属性名 |
props_img | Mix | 0 | 属性图片 | |
item_imgs | Mix | 0 | [{"url": "//my-test-11.slatic.net/original/208de91b5132477f8a723c82c56c3a58.jpg"}] | 商品图片列表 |
seller | Mix | 0 | ||
desc | String | 0 | ||
props_list | Mix | 0 | {"0:0": "颜色:小号"} | 商品属性 |
seller_info | Mix | 0 | {"level": "", "shop_type": "A", "user_num_id": "2620712400", "cid": null, "delivery_score": null, "item_score": null, "score_p": null, "city": "广东 广州", "shop_name": "深圳市福田区尚我佳日用制品厂", "nick": "尚我佳日用品厂", "zhuy": "m.1688.com/winport/b2b…", "sid": "b2b-262071240083f4c"} | 卖家信息 |
num | Int | 0 | 2191 | |
post_fee | Float | 0 | 9.00 | 邮费 |
language | String | 0 | th | |
currency_code | String | 0 | THB | |
property_alias | String | 0 | 0:0:小号;0:1:中号;0:2:大号 | 属性别名 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.PrintWriter;
import java.net.URLConnection;
public class Example {
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.print(body);
out.flush();
InputStream instream = conn.getInputStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
instream.close();
}
}
public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
InputStream instream = conn.getInputStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
instream.close();
}
}
public static void main(String[] args) throws IOException, JSONException {
// 请求示例 url 默认请求参数已经URL编码处理
String url = "https://api-gw.onebound.cn/lazada/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=267690734&nation=co.th";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}