参数 | 类型 | 必选 | 值 | 示例 |
Authorization | string | 是 | 授权 access_token | Bearer 1798c6aadec33d1bc2f5b707f1049aefexxxx |
参数 | 类型 | 必选 | 描述 |
media | int | 是 | 0 为手淘,1 为 PC 会影响 tagId 的设置和 sort 设置 |
sort | int | 是 | media 为 0 时,可选值:0-默认,1-人气,2-销量,3-信用,4-最新,5-价格升,6-价格降,media 为 1 时,可选值:0-默认,2-销量,5-价格升,6-价格降 |
pattern | int | 是 | 1:精准 |
keyword | string | 是 | 搜索词 |
item_id | string | 是 | 商品链接 |
start_page | int | 是 | 开始查找的页码 |
page_step | int | 否 | 默认为一次 2 页,最大一次 3 页,假设第 1 页开始,设置为 2,则查找 1、2 页,数据不保证 100% 返回,可能返回为空,需要自己的程序里加入判断逻辑;如果没有返回,或者只返回一部分,没返回的需要重新请求,返回的请求是连续的 |
tag_id | int | 否 | 选择 PC 且为所有宝贝(all)时,可选值:0-包邮,1-赠送退货运费险,2-货到付款,3-海外商品,4-二手,5-天猫,6-正品保证,7-24 小时内发货,8-7+ 天内退货,9-旺旺在线,10-信用卡支付,11-折扣促销,12-新品 ;选择 PC 且为天猫时(tmall),可选值:0-包邮,1-赠送退货运费险,2-货到付款,3-海外商品,4-二手,6-正品保证,7-24 小时内发货,9-旺旺在线,10-信用卡支付,11-折扣促销,12-新品;选择无线时(不管所有宝贝还是天猫),可选值:13-免运费,14-天猫,15-全球购,16-消费者保障,17-手机专享价,18-淘金币,19-货到付款,20-七天退换,21-促销 |
type | string | 否 | 会影响 tag_id 的设置 默认为 all 、tmall,选择 PC 且为所有宝贝时 |
curl --location --request POST 'http://xxxxxxxxxx.com/tool/accounts/item-rank' \ --header 'Authorization: Bearer c2c20409e5f3f34437aece02c69b9a9dxxxxxxxx' \ --header 'Cookie: PHPSESSID=9clrl8itapsmakj80smt4rr0ts; _csrf=ef2da6cdf78743574ec4cbdec8fe8d959eb0b7c9e34418e3bffbad55ea2c034ba%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%228DZXA6sKgG5y_7mQSJO6M2QtvDvRbvP-%22%3B%7D' \ --form 'media=1' \ --form 'sort=0' \ --form 'pattern=1' \ --form 'keyword=好欢螺' \ --form 'item_id=https://detail.tmall.com/item.htm?id=604618443394&ali_trackid=2:mm_124190590_30248727_109212350230:1596447162_115_871152963&spm=a231o.7712113/g.1004.338&pvid=200_11.8.64.128_4701_1596447149036&bxsign=tbk1596447162349fad57f7d8f659cc9f697b3b32d70e180' \ --form 'start_page=1' \ --form 'page_step=2' \ --form 'tag_id=14' \ --form 'type=all'
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "http://xxxxxxxxxxxxxx.com/tool/accounts/item-rank", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => array('media' => '1','sort' => '0','pattern' => '1','keyword' => '好欢螺','item_id' => 'https://detail.tmall.com/item.htm?id=604618443394&ali_trackid=2:mm_124190590_30248727_109212350230:1596447162_115_871152963&spm=a231o.7712113/g.1004.338&pvid=200_11.8.64.128_4701_1596447149036&bxsign=tbk1596447162349fad57f7d8f659cc9f697b3b32d70e180','start_page' => '1','page_step' => '2','tag_id' => '14','type' => 'all'), CURLOPT_HTTPHEADER => array( "Authorization: Bearer c2c20409e5f3f34437aece02c69b9a9dxxxxxxxx", "Cookie: PHPSESSID=9clrl8itapsmakj80smt4rr0ts; _csrf=ef2da6cdf78743574ec4cbdec8fe8d959eb0b7c9e34418e3bffbad55ea2c034ba%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%228DZXA6sKgG5y_7mQSJO6M2QtvDvRbvP-%22%3B%7D" ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("text/plain"); RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) .addFormDataPart("media", "1") .addFormDataPart("sort", "0") .addFormDataPart("pattern", "1") .addFormDataPart("keyword", "好欢螺") .addFormDataPart("item_id", "https://detail.tmall.com/item.htm?id=604618443394&ali_trackid=2:mm_124190590_30248727_109212350230:1596447162_115_871152963&spm=a231o.7712113/g.1004.338&pvid=200_11.8.64.128_4701_1596447149036&bxsign=tbk1596447162349fad57f7d8f659cc9f697b3b32d70e180") .addFormDataPart("start_page", "1") .addFormDataPart("page_step", "2") .addFormDataPart("tag_id", "14") .addFormDataPart("type", "all") .build(); Request request = new Request.Builder() .url("http://xxxxxxxxxxxxx.com/tool/accounts/item-rank") .method("POST", body) .addHeader("Authorization", "Bearer c2c20409e5f3f34437aece02c69b9a9dxxxxxxxx") .addHeader("Cookie", "PHPSESSID=9clrl8itapsmakj80smt4rr0ts; _csrf=ef2da6cdf78743574ec4cbdec8fe8d959eb0b7c9e34418e3bffbad55ea2c034ba%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%228DZXA6sKgG5y_7mQSJO6M2QtvDvRbvP-%22%3B%7D") .build(); Response response = client.newCall(request).execute();
参数 | 类型 | 描述 |
data | object | 返回数据信息 |
totalpage | int | 总页数 |
startpage | int | 开始页码 |
nextpage | int | 下一页 |
pagestep | int | 查询页码尾数 |
items | string | 商品信息 |
code | int | 返回状态码 |
msg | string | 返回码描述 |
msec | int | 接口执行时间 |
time | int | 接口返回时间 |
{ "code": 0, "msg": "获取排名数据成功", "msec": 4265, "time": 1596449461, "data": { "info": { "totalpage": 37, "startpage": 1, "nextpage": 4, "pagestep": 3 }, "data": { "items": [ { "id": "604618443394", "pos": 20, "page": 2, "title": "好欢螺螺蛳粉300g*10袋礼盒装螺丝粉广西柳州螺狮粉正宗整箱包邮", "nick": "迅荟食品专营店", "url": "https://item.taobao.com/item.htm?id=604618443394", "img": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i2/3400066719/O1CN01K386yS1zVLj5tJsAw_!!3400066719.jpg", "isp4p": 0, "view_sales": 5808, "category": null, "price": "38.70", "area": "广西 柳州", "seller_type": "1", "seller_level": null } ] } } }
代码 | 代码描述 | 解决方案 |
0 | 成功 | |
100 | 请求参数错误 | 检查您的请求参数是否正确 |
101 | 请求超时 | 检查您的参数或者网络连接情况或联系客服解决 |
200 | 系统错误,请联系客服 | 检查您的接口地址填写是否正确,其他问题联系客服解决 |
203 | 暂不支持当前接口 | |
204 | 请求异常:无该接口权限,请前往官网开通正式接口。 | 前往官网开通该接口权限 |
204 | 请求异常:API 调用次数不足,请前往网站兑换次数。 | 前往官网充值该接口调用次数 |
401 | 身份凭证无效 | 在请求头中添加 access_token |
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!