Full Analysis of Taobao Item Detail API taobao.item.get

taobao.item.get is a core item detail query interface provided by the Taobao Open Platform . It is used to obtain complete information of Taobao platform items by item ID (num_iid), covering core data such as item basic attributes, price, sales volume, specification parameters, detailed descriptions, and store information. It is an essential interface for e-commerce product selection, item management, data monitoring, and other scenarios.

I. Core Positioning of the Interface

Item Details
Interface Identifier taobao.item.get
Interface Function Accurately query full-item detail data of Taobao items, supporting single-item/batch item information acquisition
Applicable Scenarios Item information collection, inventory monitoring, price tracking, product selection analysis, item data synchronization
Calling Restrictions Requires applying for developer permissions on the Taobao Open Platform and obtaining AppKey/AppSecret for identity verification

II. Detailed Explanation of Core Parameters

The interface request parameters are divided into basic parameters (platform authentication) and business parameters (item query). Among them, num_iid is a mandatory parameter, and other parameters can be configured as needed.

1. Basic Parameters (Mandatory)

Parameter Name Type Mandatory Description
app_key String Yes Developer AppKey, obtained by registering an application on the Taobao Open Platform
v String Yes API version number, fixed as 2.0
format String Yes Return data format, fixed as json
method String Yes Interface method name, fixed as taobao.item.get
sign String Yes Signature, an MD5 encrypted string generated based on AppSecret + request parameters
timestamp Long Yes Timestamp (millisecond-level), used to prevent replay attacks
access_token String No Authorization token, used in store authorization scenarios, can be omitted for ordinary queries

2. Business Parameters (Core)

Parameter Name Type Mandatory Description
num_iid Long Yes Item ID (unique identifier of Taobao items), mandatory
fields String Yes List of fields to be returned, separated by commas, can be filtered as needed
is_promotion Int No Whether to return promotion information, 1 for yes, 0 for no, default 0
is_tmall Int No Whether to query only Tmall items, 1 for yes, 0 for no, default 0

3. Example of Common fields Fields

fields is a core parameter that controls the scope of returned data. Common fields are as follows (combined as needed):

plaintext

复制代码
title,price,num_iid,item_img,item_num,shop_name,location,desc,sku, seller_info,price,post_fee
  • title: Item title; price: Item price
  • item_img: Item main image URL; desc: Item detail page HTML
  • sku: Item specification parameters (color, size, etc.); seller_info: Store information

III. Python Request Example (Fully Runable)

1. Preliminary Preparation

  1. Register a Developer Account:By clicking on c0b.cc/nIAWD4 (wechat id: Taobaoapi2014), register an account, complete the enterprise certification, and obtain the AppKey and AppSecret (for identity verification during interface calls).

  2. Install Dependencies : Use the requests library to send requests and the json library to parse data.

    bash

    复制代码
    pip install requests

2. Complete Code Implementation

python

复制代码
import requests
import json
import hashlib
import time
from urllib.parse import urlencode

# ===================== Core Configuration (Replace with actual values) =====================
APP_KEY = "your_app_key"
APP_SECRET = "your_app_secret"
API_URL = "https://eco.taobao.com/router/rest"  # Interface address
NUM_IID = "642345678901234567"  # Target item ID (example)
# ==================================================================

def generate_sign(params):
    """Generate interface signature (MD5 encryption)"""
    sorted_params = sorted(params.items(), key=lambda x: x[0])
    sign_str = f"{APP_SECRET}{''.join([f'{k}{v}' for k, v in sorted_params])}{APP_SECRET}"
    return hashlib.md5(sign_str.encode("utf-8")).hexdigest().upper()

def get_taobao_item_detail():
    """Obtain Taobao item details"""
    # 1. Construct request parameters
    timestamp = str(int(time.time() * 1000))
    params = {
        "app_key": APP_KEY,
        "v": "2.0",
        "format": "json",
        "method": "taobao.item.get",
        "timestamp": timestamp,
        "num_iid": NUM_IID,
        "fields": "title,price,num_iid,item_img,item_num,shop_name,location,desc,sku",
        "is_promotion": 0
    }

    # 2. Generate signature
    params["sign"] = generate_sign(params)

    try:
        # 3. Send request
        response = requests.get(API_URL, params=params, timeout=10)
        response.raise_for_status()
        result = response.json()

        # 4. Parse results
        if "error_response" in result:
            print(f"Interface call failed: {result['error_response']['error_msg']}")
            return None
        # Extract item details
        item = result["item_get_response"]["item"]
        print("Item details obtained successfully!")
        return item
    except Exception as e:
        print(f"Request exception: {str(e)}")
        return None

# Call the interface
if __name__ == "__main__":
    item_detail = get_taobao_item_detail()
    if item_detail:
        # Print core information
        print(f"Item title: {item_detail.get('title', 'None')}")
        print(f"Item price: {item_detail.get('price', 'None')}")
        print(f"Item inventory: {item_detail.get('item_num', 'None')}")
        print(f"Store name: {item_detail.get('shop_name', 'None')}")
        print(f"Item main image: {item_detail.get('item_img', [{}])[0].get('url', 'None')}")
        # Print details (truncated to 100 characters)
        print(f"Item details: {str(item_detail.get('desc', 'None'))[:100]}...")

IV. Return Result Parsing

The interface returns data in JSON format, with the core structure as follows:

json

复制代码
{
    "item_get_response": {
        "item": {
            "title": "New Summer Short-Sleeve Loose Plus-Size Cotton T-Shirt for Men",
            "price": "99.00",
            "num_iid": "642345678901234567",
            "item_img": [{"url": "https://img.xxx.jpg"}],
            "item_num": "1000",
            "shop_name": "XX Clothing Flagship Store",
            "location": "Hangzhou, Zhejiang",
            "desc": "<div>HTML content of item details...</div>",
            "sku": [
                {"spec": "Black-XXL", "price": "99.00", "stock": "500"},
                {"spec": "White-XXL", "price": "99.00", "stock": "300"}
            ],
            "seller_info": {
                "nick": "XX Clothing Flagship Store",
                "shop_id": "12345678"
            }
        }
    }
}
  • Core Field Explanation :
    • title: Item title (used for search matching)
    • price: Item price (unit: RMB)
    • sku: Item specification list (required for multi-specification items)
    • desc: Item detail page HTML (can be directly used for display)
    • seller_info: Store information (used for merchant association)

V. Notes

  1. Permission Application : Ordinary developers need to apply for the item_get interface permission. For store authorization scenarios, an additional access_token needs to be applied for.
  2. Signature Generation : The signature must be generated strictly according to the rule of AppSecret + sorted parameters + AppSecret; otherwise, a "signature error" will be returned.
  3. Interface Frequency Limitations: The calling frequency is limited for a single IP/single application (default 5 times per second). The calling interval needs to be controlled to avoid triggering traffic limiting.
  4. Data Compliance: Only public item data can be obtained. It is prohibited to crawl or use unauthorized item information for commercial purposes, which may violate platform rules.
  5. Multi-Specification Item Processing : The specification parameters (such as color and size) need to be obtained through the sku field; otherwise, key information cannot be retrieved.

VI. Common Problems and Solutions

Problem Cause Solution
Signature Error Incorrect signature generation rules Strictly generate the MD5 signature according to the rule of AppSecret + sorted parameters + AppSecret
Invalid Item ID The input num_iid does not exist Confirm the correctness of the item ID, which can be queried through the taobao.item.search interface
Empty Field Return Incorrect configuration of the fields field Check whether the fields field exists and ensure that the field names are correct (case-sensitive)
Interface Call Failure Insufficient permissions Apply for the corresponding interface permission or obtain access_token through store authorization

VII. Interface Application Scenarios

  1. Item Data Collection: Batch acquisition of item information for e-commerce platform data synchronization and product selection analysis.
  2. Inventory Monitoring: Real-time query of item inventory to implement inventory early warning reminders.
  3. Price Tracking: Monitor price fluctuations of items to assist in adjusting pricing strategies.
  4. Item Detail Display: Display Taobao item details on third-party systems (requires compliant authorization).
相关推荐
东风破_13 小时前
React 受控组件与非受控组件:从一个输入框讲清表单数据流
前端
尤乐娃子13 小时前
进入大厂(厂子大)实习Day12
前端·笔记·实习
程序员爱钓鱼13 小时前
Rust Copy详解:隐式复制与轻量数据类型
前端·后端·rust
Patrick在香港14 小时前
Python Docker镜像从1.2GB到89MB:多阶段构建的完整优化实录
java·python·docker·信息可视化·容器·数据分析·ai编程
上海安当技术14 小时前
敏感数据怎么防拖库?信封加密(DEK+KEK 二层密钥)架构设计与 Java 实战
java·开发语言·python
我是唐青枫14 小时前
Java JCommander 实战详解:用注解解析命令行参数
java·开发语言
大鹏说大话14 小时前
C++ 内存布局详解:类、虚函数、虚表底层原理
java·开发语言
还是鼠鼠15 小时前
Spring AI连接DeepSeek与通义千问:application.yaml配置详解
java·通义千问·spring ai·deepseek
四六的六15 小时前
端侧模型多端部署实战:从格式转换到灰度发布,Web 和移动端统一部署流水线
前端·人工智能·大模型·ai编程·ai模型·ai产品·端侧ai
计算机小白一个16 小时前
蓝桥杯 Java B 组之哈希表应用(两数之和、重复元素判断)
java·数据结构·算法·蓝桥杯