Java是一种高级编程语言,由Sun Microsystems公司于1995年推出,现在属于Oracle公司开发和维护。Java以平台无关性、面向对象、安全性、可移植性和高性能著称,广泛用于桌面应用程序、嵌入式系统、企业级服务、Android移动应用程序等。
接口是Java中的一个重要概念,可以理解为定义了一组方法签名的抽象类。它定义了方法的名字、参数和返回值类型,但没有实现代码。接口的作用是为了让不同的类具有相似的行为(即方法),从而可以实现多态。Java中的高并发指的是在多个线程同时执行的情况下,系统仍然保持稳定、响应快速的特性。在Java中,可以使用线程池、锁、同步机制等技术来提高程序的并发处理能力。
1688商品详情API接入说明
1、api申请地址-注册调用key请求接入api
2、请求示例
(1)JAVA
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/1688/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=610947572360";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
3、参数说明
通用参数说明
1、version:API版本
2、key:调用key,测试key:test_api_key
3、api_name:API类型[item_search,item_get]
4、cache:[yes,no]默认yes,将调用缓存的数据,速度比较快
5、result_type:[json,xml,serialize,var_export]返回数据格式,默认为json
6、lang:[cn,en,ru] 翻译语言,默认cn简体中文
7、API:item_search 参数说明: q:搜索关键词 cat:分类ID start_price:开始价格 end_price:结束价格 8、sort:排序 page:
9、API:item_get 参数说明: num_iid:商品id【num_iid=1520294】
4、响应参数示例
{
"item": {
"num_iid": "610947572360",
"title": "厂家直销小米有品Qin2 Pro智能手机学生机老人机备用机小爱同学4G",
"desc_short": "",
"price": "799.00",
"total_price": 0,
"suggestive_price": 0,
"orginal_price": "799.00",
"nick": "qin多亲科技",
"num": "1763",
"detail_url": "https://detail.1688.com/offer/610947572360.html",
"pic_url": "https://cbu01.alicdn.com/img/ibank/2020/063/830/13235038360_979836901.jpg",
"brand": "",
"brandId": "",
"rootCatId": "",
"cid": "50903",
"desc": "<div id=\"offer-template-0\"></div><p><span><span>深圳市多亲科技有限公司(简称“多亲科技”)成立于2014年9月是国内领先的人工智能硬件解决方案供应商。多亲科技积极推动人工智能技术的创新研发,在人工智能终端设备、系统软件的研发和生产领域,具有深厚的技术沉淀与实力。</span></span></p><p><span> </span></p><p><span> 多亲产品销售网络覆盖全国各地乃至远销海外,欢迎企业定制、团购、经销代理。</span></p><p><span> 优质的产品、过硬的技术、完善的服务、是我们合作双赢的开篇。</span></p><p><span> <span ><strong><span >欢迎有意向者实地考察,垂询电话:13662284449.</span></strong></span></span></p><p><span> </span></p><p><span>温馨提示:</span></p><p><span><span><span>1、可定制--</span></span>承接各种订单订制!为客户定制机身、开机画面、预装软件、包装等定制!</span><br /><span><span><span>2、质量保证--</span></span>本公司专注通讯行业10年,线下线下百花齐放,客户复购率达30%以上。</span><br /><span><span><span>3、价格实惠--</span></span>本店是工厂直供,没有中间商差价,一站到客,薄利多销。</span><br /><span><span><span>4、售后服务--</span></span>本店出售的所有产品均提供1年的质保。因质量原因退换货(非人为因素)30天内换新。</span></p><p> </p><p><span><img alt=\"undefined\" height=\"446.22866894197955\" src=\"https://cbu01.alicdn.com/img/ibank/2020/560/807/14112708065_979836901.jpg\" width=\"790\" /><br /><img alt=\"undefined\" height=\"457.5154730327144\" src=\"https://cbu01.alicdn.com/img/ibank/2020/303/507/14112705303_979836901.jpg\" width=\"790\" /><br /><img alt=\"undefined\" height=\"443.2365499573014\" src=\"https://cbu01.alicdn.com/img/ibank/2020/499/812/14150218994_979836901.jpg\" width=\"790\" /><br /><img alt=\"undefined\" height=\"440.350569675723\" src=\"https://cbu01.alicdn.com/img/ibank/2020/770/128/14199821077_979836901.jpg\" width=\"790\" /><br /></span></p><p><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/588/942/13197249885_979836901.jpg\" /></p><p><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/778/789/13234987877_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/109/489/13234984901_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/156/072/13197270651_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/270/710/13235017072_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/735/999/13234999537_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/549/252/13197252945_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/409/552/13197255904_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/247/935/13278539742_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/355/845/13278548553_979836901.jpg\" /><br /><br /></p><p><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/917/372/13197273719_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/969/099/13234990969_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/175/455/13278554571_979836901.jpg\" /></p><p><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/427/386/13314683724_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/331/365/13278563133_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/654/500/13235005456_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/542/110/13235011245_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/291/020/13235020192_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/329/635/13278536923_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/996/155/13278551699_979836901.jpg\" /></p><p><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/230/920/13235029032_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/464/972/13197279464_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/380/275/13278572083_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/999/462/13197264999_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/868/245/13278542868_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/843/410/13235014348_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/897/200/13235002798_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/914/800/13235008419_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/709/762/13197267907_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/427/545/13278545724_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/741/003/13197300147_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/175/710/13235017571_979836901.jpg\" /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/410/485/13278584014_979836901.jpg\" /><br /><br /><img alt=\"undefined\" src=\"https://cbu01.alicdn.com/img/ibank/2020/863/665/13278566368_979836901.jpg\" /><br /><br /><br /></p>",
"item_imgs": [
{
"url": "https://cbu01.alicdn.com/img/ibank/2020/063/830/13235038360_979836901.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/2020/445/748/13819847544_979836901.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/2020/487/543/13234345784_979836901.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/2020/296/695/13418596692_979836901.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/2020/167/778/13462877761_979836901.jpg"
}
],
"item_weight": "",
"post_fee": "",
"express_fee": "",
"ems_fee": "",
"shipping_to": "",
"video": [],
"sample_id": "",
"props_name": "0:0:机身内存:64GB;1:0:颜色:铁灰色;1:1:颜色:瓷白色",
"prop_imgs": {
"prop_img": []
},
"property_alias": "0:0:64GB;1:0:铁灰色;1:1:瓷白色",
"props": [
{
"name": "品牌",
"value": "多亲"
},
{
"name": "型号",
"value": "Qin 2 Pro"
},
{
"name": "手机类型",
"value": "老人手机"
},
{
"name": "外形",
"value": "直板"
},
{
"name": "主屏尺寸",
"value": "大屏幕(5.0英寸—5.9英寸)"
},
{
"name": "网络制式",
"value": "移动4G(TD-LTE),联通/电信4G(FDD-LTE)"
},
{
"name": "操作系统",
"value": "Android 9.0系统"
},
{
"name": "电池容量",
"value": "2100"
},
{
"name": "摄像头像素",
"value": "1200万-1999万"
},
{
"name": "存储卡",
"value": "支持存储卡"
},
{
"name": "处理器核心",
"value": "八核"
},
{
"name": "运行内存",
"value": "2GB"
},
{
"name": "手机版本",
"value": "大陆行货"
},
{
"name": "售后类型",
"value": "全国联保"
},
{
"name": "上市时间",
"value": "2019"
},
{
"name": "适用送礼场合",
"value": "员工福利,颁奖纪念,广告促销,节日,展销会,公关策划,生日,商务馈赠"
},
{
"name": "3C证书编号",
"value": "2019161606319519"
},
{
"name": "CPU品牌",
"value": "展讯"
},
{
"name": "运营商",
"value": "中国移动,中国电信,中国联通"
},
5、此API目前支持以下基本接口:
item_get_specifications-获得跨境属性
item_search-按关键字搜索商品
item_search_img-按图搜索1688商品(拍立淘)
item_search_shop-获得店铺的所有商品
item_password-获得淘口令真实url
item_search_new-按关键字搜索新品数据
custom-自定义API操作(1688订单数据)
注:本帖只展示部分参数,点击获取全部参数