API接口允许不同应用程序之间共享数据,在系统之间传输、读取和更新数据。例如,一个电商网站可以通过API接口获取支付系统的支付状态。API接口允许开发人员使用他人开发的功能来扩展自己的应用程序。通过调用第三方API接口,开发人员无需重新实现功能,而是直接使用其他应用程序的功能。
店铺所有商品接口(item_search_shop-获得店铺的所有商品)代码封装代码如下:
公共参数
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
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版本 |
请求参数:shop_id=433655136&page=1&sort=
参数说明: shop_id:shop_id page:页码
sort:排序[new,bid,sale]
(new 新品,bid:价格,sale:销量,bid加_前缀为从大到小排序)
请求示例
# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://api-gw.onebound.cn/taobao/item_search_shop/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&shop_id=433655136&page=1&sort="
headers = {
"Accept-Encoding": "gzip",
"Connection": "close"
}
if __name__ == "__main__":
r = requests.get(url, headers=headers)
json_obj = r.json()
print(json_obj)
响应示例
{
"items": {
"shop_id": "433655136",
"page": "1",
"real_total_results": "146",
"total_results": "146",
"page_size": 10,
"page_count": 15,
"_ddf": "ti",
"item": [
{
"num_iid": "719687641307",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN01VuRq3O1nzKXgcuhFb_!!2209411885160.jpg",
"title": "IFIK Camisole Dress横竖五线谱 蓝白条纹防走光收腰抹胸连衣裙裤",
"promotion_price": "380.00",
"price": "380.00",
"sales": 45,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=719687641307"
},
{
"num_iid": "697342951530",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN01t0yBsl1nzKVXAC65E_!!2209411885160.jpg",
"title": "IFIK Shaggy T-shirt 亲肤水貂拼针织短袖方领软糯金属项链T恤2色",
"promotion_price": "220.00",
"price": "220.00",
"sales": 50,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=697342951530"
},
{
"num_iid": "719464692888",
"pic_url": "http://g.search.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN01YHSLO41nzKXkNrKs9_!!2209411885160.jpg",
"title": "IFIK Denim Skirt丹宁弦乐 2个葫芦扣复古洗水散边超短牛仔百褶裙",
"promotion_price": "400.00",
"price": "400.00",
"sales": 100,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=719464692888"
},
{
"num_iid": "719683921611",
"pic_url": "http://g.search1.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN01545WzP1nzKXmhDGaU_!!2209411885160.jpg",
"title": "IFIK Off Shoulder Top薄雾奏响 一字肩天丝棉微透打底长袖防晒衣",
"promotion_price": "210.00",
"price": "210.00",
"sales": 100,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=719683921611"
},
{
"num_iid": "718831376404",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i2/2209411885160/O1CN01BrDQ2I1nzKXXllId0_!!2209411885160.png",
"title": "【低至5折专区】IFIK 2023折扣合集 不退不换",
"promotion_price": "330.00",
"price": "330.00",
"sales": 200,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=718831376404"
},
{
"num_iid": "697344019504",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN01ymReKS1nzKWdQATsZ_!!2209411885160.jpg",
"title": "IFIK Mini Skort 复古撞色线 复杂立体水洗牛仔开叉黑色短裙裤",
"promotion_price": "360.00",
"price": "360.00",
"sales": 300,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=697344019504"
},
{
"num_iid": "696527856406",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN0159US5p1nzKVxh8SLs_!!2209411885160.jpg",
"title": "IFIK Cut-out Sweater 呼吸感知 背面镂空马海毛半透薄款针织上衣",
"promotion_price": "330.00",
"price": "330.00",
"sales": 91,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=696527856406"
},
{
"num_iid": "675006395148",
"pic_url": "http://g.search.alicdn.com/img/bao/uploaded/i4/i1/2209411885160/O1CN01aUT9ek1nzKTEwLfVw_!!2209411885160.jpg",
"title": "IFIK Leather Jacket 'Hunter复古水洗牛仔拼皮夹克 短款垫肩外套",
"promotion_price": "580.00",
"price": "580.00",
"sales": 39,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=675006395148"
},
{
"num_iid": "724068493983",
"pic_url": "http://g.search1.alicdn.com/img/bao/uploaded/i4/i3/2209411885160/O1CN01qx7qmm1nzKXw1gOj7_!!2209411885160.jpg",
"title": "IFIK Cargo Jeans#1856粉色扉页 经典版型阔腿口袋炒盐牛仔工装裤",
"promotion_price": "460.00",
"price": "460.00",
"sales": 44,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=724068493983"
},
{
"num_iid": "674342109993",
"pic_url": "http://g.search2.alicdn.com/img/bao/uploaded/i4/i1/2209411885160/O1CN01x2oAnJ1nzKSRWjJMF_!!2209411885160.jpg",
"title": "IFIK Bootcut Jeans #1969 50粒铆钉复古高腰微喇重洗水牛仔裤",
"promotion_price": "400.00",
"price": "400.00",
"sales": 200,
"quantity": "13",
"seller_nick": "ifiker",
"seller_id": null,
"shop_id": "433655136",
"shop_title": "ifiker",
"detail_url": "https://item.taobao.com/item.htm?id=674342109993"
}
]
},
"error_code": "0000",
"reason": "ok",
"secache": "5177b6f4db5be7bfce9032529452fd88",
"secache_time": 1688091186,
"secache_date": "2023-06-30 10:13:06",
"error": "",
"cache": 0,
"api_info": "today:62 max:10100 all[3216=62+12+3142];expires:2030-12-31",
"execution_time": "8.064",
"server_time": "Beijing/2023-06-30 10:13:06",
"client_ip": "106.6.34.137",
"call_args": {
"seller_nick": "433655136",
"start_price": "1"
},