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).
相关推荐
Jagger_29 分钟前
周末和AI肝了两天,终于知道:为什么要把AI当做实习生
前端
weixin_4561648331 分钟前
vue3 子组件向父组件传参
前端·vue.js
沉鱼.4435 分钟前
第十二届题目
java·前端·算法
Setsuna_F_Seiei1 小时前
CocosCreator 游戏开发 - 多维度状态机架构设计与实现
前端·cocos creator·游戏开发
Bigger1 小时前
CodeWalkers:让 AI 助手化身桌面宠物,陪你敲代码的赛博伙伴!
前端·app·ai编程
赫瑞1 小时前
数据结构中的排列组合 —— Java实现
java·开发语言·数据结构
安审若无2 小时前
运维知识框架
运维·服务器
cyclv2 小时前
无网络地图展示轨迹,地图瓦片下载,绘制管线
前端·javascript
周末也要写八哥3 小时前
多进程和多线程的特点和区别
java·开发语言·jvm
土豆12503 小时前
Tauri 入门与实践:用 Rust 构建你的下一个桌面应用
前端·rust