万邦淘宝/天猫搜索相似的商品 API 返回值说明

item_search_similar-搜索相似的商品 [查看演示] API测试工具

onebound.taobao.item_search_similar

公共参数

请求地址: https://api-gw.onebound.cn/taobao/item_search_similar

名称 类型 必须 描述
keyString调用key(必须以GET方式拼接在URL中)
secretString调用密钥
api_nameStringAPI接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等]
cacheString[yes,no]默认yes,将调用缓存的数据,速度比较快
result_typeString[json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读
langString[cn,en,ru]翻译语言,默认cn简体中文
versionStringAPI版本
请求参数

请求参数:sample_id=-1005300893&num_iid=527655087864&page=1&sort=&page_size=

参数说明:sample_id:商品风格标识ID
num_iid:商品ID

响应参数
名称 类型 示例值 描述
item
item[] 搜索相似的商品
请求示例
	
-- 请求示例 url 默认请求参数已经URL编码处理
curl -i "https://api-gw.onebound.cn/taobao/item_search_similar/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&sample_id=-1005300893&num_iid=527655087864&page=1&sort=&page_size="
<?php

// 请求示例 url 默认请求参数已经URL编码处理
// 本示例代码未加密secret参数明文传输,若要加密请参考:https://api.onebound.cn/taobao/demo/sdk2020/demo-sign.php
$method = "GET";
$url = "https://api-gw.onebound.cn/taobao/item_search_similar/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&sample_id=-1005300893&num_iid=527655087864&page=1&sort=&page_size=";
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
var_dump(curl_exec($curl));
?>
<?php
//定义缓存目录和引入文件
define("DIR_RUNTIME","runtime/");
define("DIR_ERROR","runtime/");
define("SECACHE_SIZE","0");
//SDK下载地址 http://api-gw.onebound.cn/taobao/demo/sdk2020/onebound-api-sdk.zip
include ("ObApiClient.php");

$obapi = new otao\ObApiClient();
$obapi->api_url = "http://api-gw.onebound.cn/";
$obapi->api_urls = array("http://api-gw.onebound.cn/","http://api-1.onebound.cn/");//备用API服务器
$obapi->api_urls_on = true;//当网络错误时,是否启用备用API服务器
$obapi->api_key = "<您自己的apiKey>";
$obapi->api_secret = "<您自己的apiSecret>";
$obapi->api_version ="";
$obapi->secache_path ="runtime/";
$obapi->secache_time ="86400";
$obapi->cache = true;

$api_data = $obapi->exec(
                array(
	                "api_type" =>"taobao",
	                "api_name" =>"item_search_similar",
	                "api_params"=>array (
  'sample_id' => '-1005300893',
  'num_iid' => '527655087864',
  'page' => '1',
  'sort' => '',
  'page_size' => '',
)
                )
            );
 var_dump($api_data);
?>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.PrintWriter;
import java.net.URLConnection;

public class Example {
	private static String readAll(Reader rd) throws IOException {
		StringBuilder sb = new StringBuilder();
		int cp;
		while ((cp = rd.read()) != -1) {
			sb.append((char) cp);
		}
		return  sb.toString();
	}
	public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {
		URL realUrl = new URL(url);
		URLConnection conn = realUrl.openConnection();
		conn.setDoOutput(true);
		conn.setDoInput(true);
		PrintWriter out = new PrintWriter(conn.getOutputStream());
		out.print(body);
		out.flush();
		InputStream instream = conn.getInputStream();
		try {
			BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
			String jsonText = readAll(rd);
			JSONObject json = new JSONObject(jsonText);
			return json;
		} finally {
			instream.close();
		}
	}
	public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {
		URL realUrl = new URL(url);
		URLConnection conn = realUrl.openConnection();
		InputStream instream = conn.getInputStream();
		try {
			BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
			String jsonText = readAll(rd);
			JSONObject json = new JSONObject(jsonText);
			return json;
		} finally {
			instream.close();
		}
	}
	public static void main(String[] args) throws IOException, JSONException {
		// 请求示例 url 默认请求参数已经URL编码处理
		String url = "https://api-gw.onebound.cn/taobao/item_search_similar/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&sample_id=-1005300893&num_iid=527655087864&page=1&sort=&page_size=";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;
private const String method = "GET";
static void Main(string[] args)
{
	String bodys = "";
	// 请求示例 url 默认请求参数已经做URL编码
	String url = "https://api-gw.onebound.cn/taobao/item_search_similar/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&sample_id=-1005300893&num_iid=527655087864&page=1&sort=&page_size=";
	HttpWebRequest httpRequest = null;
	HttpWebResponse httpResponse = null; 
	if (url.Contains("https://"))
	{
		ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
		httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
	}
	else
	{
		httpRequest = (HttpWebRequest)WebRequest.Create(url);
	}
	httpRequest.Method = method;
	if (0 < bodys.Length)
	{
		byte[] data = Encoding.UTF8.GetBytes(bodys);
		using (Stream stream = httpRequest.GetRequestStream())
		{
		stream.Write(data, 0, data.Length);
		}
	}
	try
	{
		httpResponse = (HttpWebResponse)httpRequest.GetResponse();
	}
	catch (WebException ex)
	{
		httpResponse = (HttpWebResponse)ex.Response;
	}
	Console.WriteLine(httpResponse.StatusCode);
	Console.WriteLine(httpResponse.Method);
	Console.WriteLine(httpResponse.Headers);
	Stream st = httpResponse.GetResponseStream();
	StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
	Console.WriteLine(reader.ReadToEnd());
	Console.WriteLine("\n");
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
	return true;
}
# 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_similar/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&sample_id=-1005300893&num_iid=527655087864&page=1&sort=&page_size="
headers = {
    "Accept-Encoding": "gzip",
    "Connection": "close"
}
if __name__ == "__main__":
    r = requests.get(url, headers=headers)
    json_obj = r.json()
    print(json_obj)
响应示例
{
	"num_iid": "607352440001",
	"page": "1",
	"page_size": 20,
	"pagecount": 5,
	"total_results": 100,
	"item": [
		{
			"title": "假两件卫衣女春秋薄款韩版宽松圆领套头无帽百搭外套2021新款爆款",
			"pic_url": "//img.alicdn.com/bao/uploaded/i3/2086267238/O1CN01clA7s923L3MrKMQRd_!!0-item_pic.jpg",
			"promotion_price": "89.0",
			"price": "89.0",
			"sales": "210",
			"num_iid": "632241743184",
			"shop_name": "索尔莉旗舰店",
			"seller_id": "2086267238",
			"detail_url": "//item.taobao.com/item.htm?id=632241743184&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "加绒卫衣女加厚冬2020新款爆款宽松韩版假两件拼接长袖秋冬时尚",
			"pic_url": "//img.alicdn.com/bao/uploaded/i4/2065145886/O1CN01Jjs4Sf1tLprzMWIz1_!!0-item_pic.jpg",
			"promotion_price": "89.0",
			"price": "89.0",
			"sales": "401",
			"num_iid": "628610996650",
			"shop_name": "红惑旗舰店",
			"seller_id": "2065145886",
			"detail_url": "//item.taobao.com/item.htm?id=628610996650&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "卫衣女士2020年春秋装新款韩版宽松拼色设计感2021洋气上衣ins潮",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/3174935830/O1CN01e7ePZw1swBgaQ5z6X_!!3174935830-0-lubanu-s.jpg",
			"promotion_price": "119.0",
			"price": "119.0",
			"sales": "1465",
			"num_iid": "626573304751",
			"shop_name": "七十二变服饰旗舰店",
			"seller_id": "3174935830",
			"detail_url": "//item.taobao.com/item.htm?id=626573304751&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "假两件卫衣女士春秋2020年新款韩版宽松2021春装太空棉上衣ins潮",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/3174935830/O1CN0173wb2U1swBh9IVO3a_!!0-item_pic.jpg",
			"promotion_price": "139.0",
			"price": "139.0",
			"sales": "928",
			"num_iid": "630271954353",
			"shop_name": "七十二变服饰旗舰店",
			"seller_id": "3174935830",
			"detail_url": "//item.taobao.com/item.htm?id=630271954353&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "圆领套头春秋薄卫衣女ins韩版慵懒百搭宽松春装刺绣新款2021爆款",
			"pic_url": "//img.alicdn.com/bao/uploaded/i3/1764284674/O1CN012PvNq01kOjrcD1ubO_!!0-item_pic.jpg",
			"promotion_price": "89.0",
			"price": "89.0",
			"sales": "129",
			"num_iid": "635852769049",
			"shop_name": "青花羊旗舰店",
			"seller_id": "1764284674",
			"detail_url": "//item.taobao.com/item.htm?id=635852769049&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "连帽卫衣女加厚慵懒风宽松保暖带帽外穿春秋季保暖外套女2021新款",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/2086267238/O1CN01P40SY723L3MMXTHc1_!!0-item_pic.jpg",
			"promotion_price": "98.0",
			"price": "98.0",
			"sales": "61",
			"num_iid": "631068137961",
			"shop_name": "索尔莉旗舰店",
			"seller_id": "2086267238",
			"detail_url": "//item.taobao.com/item.htm?id=631068137961&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "卫衣加绒加厚女装秋冬2020年新款冬装宽松韩版假两件外套港风复古",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/2199028539/O1CN01kB3k652Cwue7NJP70_!!0-item_pic.jpg",
			"promotion_price": "158.0",
			"price": "158.0",
			"sales": "28",
			"num_iid": "633091334117",
			"shop_name": null,
			"seller_id": "2199028539",
			"detail_url": "//item.taobao.com/item.htm?id=633091334117&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "中长款卡通卫衣女薄款2021春秋新款韩版ins上衣春季外套百搭慵懒",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/1764284674/O1CN01oeMYvu1kOjmd4qYzg_!!0-item_pic.jpg",
			"promotion_price": "88.0",
			"price": "88.0",
			"sales": "327",
			"num_iid": "606849586024",
			"shop_name": "青花羊旗舰店",
			"seller_id": "1764284674",
			"detail_url": "//item.taobao.com/item.htm?id=606849586024&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "加绒卫衣女2020秋冬新款半高领假两件宽松韩版加厚时尚上衣外套潮",
			"pic_url": "//img.alicdn.com/bao/uploaded/i2/2208354291612/O1CN01h1Fmlm1NmL5TfEgyj_!!0-item_pic.jpg",
			"promotion_price": "75.0",
			"price": "75.0",
			"sales": "3",
			"num_iid": "630545270653",
			"shop_name": "蓓登美旗舰店",
			"seller_id": "2208354291612",
			"detail_url": "//item.taobao.com/item.htm?id=630545270653&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "超火卫衣女潮ins时尚圆领宽松韩版春装2021年新款套头假两件上衣",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/3065077568/O1CN01249fc625mC3GpFSOA_!!0-item_pic.jpg",
			"promotion_price": "89.0",
			"price": "89.0",
			"sales": "3363",
			"num_iid": "629476958656",
			"shop_name": "舍妃旗舰店",
			"seller_id": "3065077568",
			"detail_url": "//item.taobao.com/item.htm?id=629476958656&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "假两件加绒卫衣女2020秋冬新款韩版宽松高领拼接加厚上衣百搭外套",
			"pic_url": "//img.alicdn.com/bao/uploaded/i3/1764284674/O1CN01C8wUbC1kOjmWWn3rP_!!0-item_pic.jpg",
			"promotion_price": "89.0",
			"price": "89.0",
			"sales": "12",
			"num_iid": "607888159832",
			"shop_name": "青花羊旗舰店",
			"seller_id": "1764284674",
			"detail_url": "//item.taobao.com/item.htm?id=607888159832&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "韩版女装2021年新款春装春款宽松女士卫衣服外套ins潮春秋冬薄款",
			"pic_url": "//img.alicdn.com/bao/uploaded/i2/3040716662/O1CN01aVa9zH1z5FB6iVaE4_!!0-item_pic.jpg",
			"promotion_price": "99.0",
			"price": "99.0",
			"sales": "107",
			"num_iid": "612874272479",
			"shop_name": "雪梵希旗舰店",
			"seller_id": "3040716662",
			"detail_url": "//item.taobao.com/item.htm?id=612874272479&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "韩版女装2021年新款春装春款宽松女士卫衣服外套ins潮春秋冬薄款",
			"pic_url": "//img.alicdn.com/bao/uploaded/i2/3040716662/O1CN01xBWBdg1z5F9uVIjZT_!!0-item_pic.jpg",
			"promotion_price": "109.0",
			"price": "109.0",
			"sales": "349",
			"num_iid": "606461273522",
			"shop_name": "雪梵希旗舰店",
			"seller_id": "3040716662",
			"detail_url": "//item.taobao.com/item.htm?id=606461273522&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "2020冬季新款小高领卫衣女韩版宽松百搭加绒加厚保暖圆领套头外套",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/3357210085/O1CN01xz36iN1CUyIEFU6ow_!!3357210085.jpg",
			"promotion_price": "68.0",
			"price": "68.0",
			"sales": "44",
			"num_iid": "629239454358",
			"shop_name": "极简时尚 JIjianshishang",
			"seller_id": "3357210085",
			"detail_url": "//item.taobao.com/item.htm?id=629239454358&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "卫衣新款2021春款加绒加厚女宽松韩版春秋冬小熊连帽女士薄款上衣",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/2201509970722/O1CN01hRixQ01HCiauLEtev_!!0-item_pic.jpg",
			"promotion_price": "83.0",
			"price": "83.0",
			"sales": "5915",
			"num_iid": "630814269819",
			"shop_name": "淘森女旗舰店",
			"seller_id": "2201509970722",
			"detail_url": "//item.taobao.com/item.htm?id=630814269819&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "加绒卫衣女加厚冬季2021新款爆款宽松韩版半高领无帽ins慵懒上衣",
			"pic_url": "//img.alicdn.com/bao/uploaded/i1/2086267238/O1CN01xGYh2a23L3MWGoDIF_!!0-item_pic.jpg",
			"promotion_price": "89.0",
			"price": "89.0",
			"sales": "26",
			"num_iid": "632483311127",
			"shop_name": "索尔莉旗舰店",
			"seller_id": "2086267238",
			"detail_url": "//item.taobao.com/item.htm?id=632483311127&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "韩版女装2021年新款春装春款宽松女士卫衣服外套ins潮潮春秋薄款",
			"pic_url": "//img.alicdn.com/bao/uploaded/i4/4076686869/O1CN01ZT4OTp20c38AaljCb_!!0-item_pic.jpg",
			"promotion_price": "69.0",
			"price": "69.0",
			"sales": "1079",
			"num_iid": "589987391029",
			"shop_name": "书见旗舰店",
			"seller_id": "4076686869",
			"detail_url": "//item.taobao.com/item.htm?id=589987391029&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "假两件卫衣女加绒加厚2020秋冬新款韩版字母高领上衣宽松百搭潮",
			"pic_url": "//img.alicdn.com/bao/uploaded/i2/3423807556/O1CN01qQ4gKv25ghJKSTvMI_!!0-item_pic.jpg",
			"promotion_price": "75.0",
			"price": "75.0",
			"sales": "269",
			"num_iid": "631572624853",
			"shop_name": "梵魅琳旗舰店",
			"seller_id": "3423807556",
			"detail_url": "//item.taobao.com/item.htm?id=631572624853&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "爆款2021年春秋薄款短款蕾丝卫衣女士新款宽松韩版打底套头潮ins",
			"pic_url": "//img.alicdn.com/bao/uploaded/i3/1133873553/O1CN013yRrSk1c7JscknRtn_!!0-item_pic.jpg",
			"promotion_price": "69.0",
			"price": "69.0",
			"sales": "898",
			"num_iid": "588492137896",
			"shop_name": "温暖驿站旗舰店",
			"seller_id": "1133873553",
			"detail_url": "//item.taobao.com/item.htm?id=588492137896&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		},
		{
			"title": "铜扣记高领加绒卫衣女加厚宽松韩版字母刺绣大码显瘦假两件上衣冬",
			"pic_url": "//img.alicdn.com/bao/uploaded/i3/47964711/O1CN01wCOdvM1kfgV7a7sGd_!!0-item_pic.jpg",
			"promotion_price": "129.0",
			"price": "129.0",
			"sales": "50",
			"num_iid": "630488581009",
			"shop_name": "铜扣记原创文艺女装",
			"seller_id": "47964711",
			"detail_url": "//item.taobao.com/item.htm?id=630488581009&scm=1007.19709.149904.0&pvid=a41d9117-076f-4135-888d-70104057996a"
		}
	],
	"data_from": "app",
	"translate_status": "",
	"translate_time": 0,
	"language": {
		"default_lang": "cn",
		"current_lang": "cn"
	},
	"error": "",
	"reason": "",
	"error_code": "0000",
	"cache": 0,
	"api_info": "today:46 max:10000",
	"execution_time": 0.553,
	"server_time": "Beijing/2021-03-10 11:19:12",
	"client_ip": "106.6.35.144",
	"call_args": {
		"sample_id": "-1005300893",
		"num_iid": "607352440001",
		"page": "1"
	},
	"api_type": "taobao",
	"translate_language": "zh-CN",
	"translate_engine": "google_cn",
	"server_memory": "5.3MB",
	"request_id": "gw-4.60483ab02e281"
}
异常示例
{
  "error": "item-not-found",
  "reason": "商品没找到",
  "error_code": "2000",
  "success": 0,
  "cache": 0,
  "api_info": "today:0 max:10000",
  "execution_time": 0.081,
  "server_time": "Beijing/2020-06-10 23:44:00",
  "call_args": [],
  "api_type": "taobao",
  "request_id": "15ee0ffc041242"}
相关资料
错误码解释
状态代码(error_code) 状态信息 详细描述 是否收费
0000success接口调用成功并返回相关数据
2000Search success but no result接口访问成功,但是搜索没有结果
4000Server internal error服务器内部错误
4001Network error网络错误
4002Target server error目标服务器错误
4003Param error用户输入参数错误
4004Account not found用户帐号不存在
4005Invalid authentication credentials授权失败
4006API stopped您的当前API已停用
4007Account stopped您的账户已停用
4008API rate limit exceeded并发已达上限
4009API maintenanceAPI维护中
4010API not found with these valuesAPI不存在
4012Please add api first请先添加api
4013Number of calls exceeded调用次数超限
4014Missing url param参数缺失
4015Wrong pageToken参数pageToken有误
4016Insufficient balance余额不足
4017timeout error请求超时
5000unknown error未知错误
API 工具
如何获得此API
立即开通 有疑问联系客服QQ:QQ:583964941583964941(微信同号)