一、获取淘宝卖家店铺订单背景
订单是卖家的核心数据,卖家的很多日常工作都是围绕着订单展开,应用的基本功能就是要保证订单实时、完整的展示在卖家面前。由于API请求依赖于网络,存在 着网络不稳定和同步时间长的问题,所以应用必须把淘宝的订单数据同步到本地。如何才能快速、完整的把订单同步到本地是本方案将要讨论的问题。
二、名词解释
在线订单:卖家三个月内已卖出的订单。
增量订单:相对已经同步到本地的订单,凡是在淘宝上发生了变更的订单就是增量订单。
消息服务:一种通过HTTP长连接实时向客户端(应用)推送数据(交易)变更的渠道。
三、API介绍
taobao.trades.sold.get - 获取三个月内已卖出的在线订单,适用于用户初始化的时候使用,ISV不应该用此接口来获取增量订单。不建议使用或尽量少用此接口。
taobao.trades.sold.increment.get – 获取增量订单,适用于用户初始化后,增量同步发生变更的订单,ISV不应该用此接口来获取三个月内的订单。
taobao.trade.fullinfo.get - 获取单笔订单详情。
四,公共参数
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
key | String | 是 | 调用key(获取测试key和secret) |
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版本 |
五、代码展示
{
"page": "1",
"real_total_results": "4959370",
"total_results": "4959370",
"page_size": "10",
"pagecount": "200",
"item": [
{
"title": "优衣库 【Theory联名款】女装 连帽外套 448450 UNIQLO",
"pic_url": "http://g.search1.alicdn.com/img/bao/uploaded/i4/i3/196993935/O1CN01PsEfDn1ewHIdMTmjI_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "199.00",
"price": "199.00",
"sales": "186",
"num_iid": "668508094727",
"seller_nick": "优衣库官方旗舰店",
"area": "上海",
"seller_id": "196993935",
"detail_url": "http://a.m.taobao.com/i668508094727.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "优衣库防晒衣女装AIRism防紫外线拉链连帽开衫(春秋透气)433703",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i1/196993935/O1CN01THQ4jc1ewHIXivjCU_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "99.00",
"price": "99.00",
"sales": "4252",
"num_iid": "634981011414",
"seller_nick": "优衣库官方旗舰店",
"area": "上海",
"seller_id": "196993935",
"detail_url": "http://a.m.taobao.com/i634981011414.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "优衣库 女装印花V领收腰连衣裙(春季 七分袖 法式风情)448065",
"pic_url": "http://g.search.alicdn.com/img/bao/uploaded/i4/i2/196993935/O1CN01VSra8T1ewHHpq4zgu_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "149.00",
"price": "149.00",
"sales": "356",
"num_iid": "663771779061",
"seller_nick": "优衣库官方旗舰店",
"area": "上海",
"seller_id": "196993935",
"detail_url": "http://a.m.taobao.com/i663771779061.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "优衣库女装半拉链卫衣(长袖运动衫 套头情侣卫衣) 442794/451155",
"pic_url": "http://g.search.alicdn.com/img/bao/uploaded/i4/i3/196993935/O1CN012txBAe1ewHIbmP0us_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "79.00",
"price": "79.00",
"sales": "2734",
"num_iid": "658345840527",
"seller_nick": "优衣库官方旗舰店",
"area": "上海",
"seller_id": "196993935",
"detail_url": "http://a.m.taobao.com/i658345840527.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "黑色西装裤女夏薄款九分西裤高腰裤子大码女裤秋冬垂感职业烟管裤",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i1/872268169/O1CN01D6P1Fb2ADS2sMR6RX_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "129.00",
"price": "129.00",
"sales": "2287",
"num_iid": "552967842105",
"seller_nick": "潞依韩旗舰店",
"area": "浙江 杭州",
"seller_id": "872268169",
"detail_url": "http://a.m.taobao.com/i552967842105.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "优衣库 UNIQLO U女装 圆领T恤(白色短袖正肩上衣)435193",
"pic_url": "http://g.search1.alicdn.com/img/bao/uploaded/i4/i2/196993935/O1CN01XD3Hjc1ewHHgaXi2q_!!196993935.jpg_60x60.jpg",
"promotion_price": "79.00",
"price": "79.00",
"sales": "98",
"num_iid": "669794920061",
"seller_nick": "优衣库官方旗舰店",
"area": "上海",
"seller_id": "196993935",
"detail_url": "http://a.m.taobao.com/i669794920061.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "妈妈秋装外套洋气高贵2022新款中年女士秋季风衣中老年人春秋上衣",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i3/2216096858/O1CN01RZHkJr20X0uuDSuiu_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "366.00",
"price": "366.00",
"sales": "1417",
"num_iid": "600291055211",
"seller_nick": "乔芙丽旗舰店",
"area": "湖北 武汉",
"seller_id": "2216096858",
"detail_url": "http://a.m.taobao.com/i600291055211.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "太平鸟短款牛仔外套女春秋装2022年新款炸街韩版宽松牛仔衣ins潮",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i2/112394247/O1CN01mbt8Jd1hFAs8ZGzTd_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "569.00",
"price": "569.00",
"sales": "551",
"num_iid": "620482928256",
"seller_nick": "太平鸟官方旗舰店",
"area": "浙江 宁波",
"seller_id": "112394247",
"detail_url": "http://a.m.taobao.com/i620482928256.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "优衣库【UNIQLO U】女装AIRism棉混纺喇叭型长连衣裙(短袖)448069",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i3/196993935/O1CN01ulWkNQ1ewHHpVeAg4_!!0-item_pic.jpg_60x60.jpg",
"promotion_price": "149.00",
"price": "149.00",
"sales": "782",
"num_iid": "666989006518",
"seller_nick": "优衣库官方旗舰店",
"area": "上海",
"seller_id": "196993935",
"detail_url": "http://a.m.taobao.com/i666989006518.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
},
{
"title": "美背内衣吊带背心女夏季内搭外穿文胸一体打底网红爆款带胸垫上衣",
"pic_url": "http://g.search.alicdn.com/img/bao/uploaded/i4/i1/3481090180/O1CN01wD2a0A1DCTt5bmtYh_!!3481090180-0-lubanu-s.jpg_60x60.jpg",
"promotion_price": "69.00",
"price": "69.00",
"sales": "8478",
"num_iid": "615965749443",
"seller_nick": "法澳娜旗舰店",
"area": "浙江 温州",
"seller_id": "3481090180",
"detail_url": "http://a.m.taobao.com/i615965749443.htm?&ttid=2018%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"
}
],
"_ddf": "cdy",
"error": "",
"reason": "",
"error_code": "0000",
"cache": 0,
"api_info": "today:3 max:10100 all[22=3+2+17];expires:2030-12-31",
"execution_time": "2.609",
"server_time": "Beijing/2022-09-27 09:31:50",
"client_ip": "106.6.34.243",
"call_args": [],
"api_type": "taobao",
"translate_language": "zh-CN",
"translate_engine": "baidu_api",
"server_memory": "5.93MB",
"request_id": "gw-3.6332528457059",
"last_id": "1246151746"
}