全部
常见问题
产品动态
精选推荐

虾皮(shopee)商品详情接口(虾皮API系列)

管理 管理 编辑 删除

虾皮(Shopee)的商品详情接口通常用于获取商品的详细信息,如标题、价格、描述、库存、图片等。Shopee 提供了官方的 API 供开发者使用,通过这些 API 可以获取商品详情数据。

Shopee 商品详情接口的基本信息

  1. API 名称: item_get
  2. 请求方法: GET
  3. 请求 URL: http://c0b.cc/R4rbK2
  4. 认证方式: 需要使用 Shopee 的 API 密钥进行认证。

请求参数

  • partner_id: 合作伙伴 ID,由 Shopee 提供。
  • shopid: 店铺 ID,表示要查询的商品所属的店铺。
  • itemid: 商品 ID,表示要查询的具体商品。
  • timestamp: 请求的时间戳。
  • sign: 请求签名,用于验证请求的合法性。

响应示例

json

{
  "item": {
    "itemid": 123456789,
    "shopid": 987654321,
    "name": "Example Product",
    "description": "This is an example product description.",
    "price": 1999,
    "stock": 100,
    "images": [
      "https://example.com/image1.jpg",
      "https://example.com/image2.jpg"
    ],
    "attributes": [
      {
        "name": "Color",
        "value": "Red"
      },
      {
        "name": "Size",
        "value": "M"
      }
    ]
  },
  "error": null,
  "warning": null
}

签名生成

Shopee API 要求每个请求都必须包含一个签名 (sign),用于验证请求的合法性。签名的生成方式如下:

  1. 将请求参数按字母顺序排序。
  2. 将排序后的参数拼接成一个字符串。
  3. 将拼接后的字符串与 API 密钥进行 HMAC-SHA256 加密。
  4. 将加密后的结果转换为十六进制字符串。

示例代码(Python)

python

import hmac
import hashlib
import time
import requests
# 封装好的第三方shopee商品列表接口,复制链接获取测试。 
demo url=c0b.cc/R4rbK2  wechat id:Taobaoapi2014
def generate_signature(partner_id, api_key, shopid, itemid, timestamp):
    base_string = f"partner_id={partner_id}&shopid={shopid}&itemid={itemid}×tamp={timestamp}"
    signature = hmac.new(api_key.encode(), base_string.encode(), hashlib.sha256).hexdigest()
    return signature

def get_item_details(partner_id, api_key, shopid, itemid):
    timestamp = int(time.time())
    signature = generate_signature(partner_id, api_key, shopid, itemid, timestamp)
    
    url = "https://api.shopee.com/v2/item/get"
    params = {
        "partner_id": partner_id,
        "shopid": shopid,
        "itemid": itemid,
        "timestamp": timestamp,
        "sign": signature
    }
    
    response = requests.get(url, params=params)
    return response.json()

# 使用示例
partner_id = "YOUR_PARTNER_ID"
api_key = "YOUR_API_KEY"
shopid = "YOUR_SHOP_ID"
itemid = "ITEM_ID"

item_details = get_item_details(partner_id, api_key, shopid, itemid)
print(item_details)

注意事项

  1. API 密钥: 请妥善保管你的 API 密钥,不要泄露。
  2. 请求频率: Shopee API 可能有请求频率限制,请遵守相关规定。
  3. 错误处理: 在实际应用中,建议添加错误处理逻辑,以应对可能的网络问题或 API 错误。


请登录后查看

用户19970108018 最后编辑于2025-02-10 13:44:28

快捷回复
回复
回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level }}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{item.is_suggest == 1? '取消推荐': '推荐'}}
沙发 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暂无简介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
163
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} 加精
{{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服