The Taobao keyword search interface restores that when we are shopping on Taobao, we can enter keywords in the search bar to get a list of related products. The product information is complete and supports page-turning display. At the same time, the input parameter sort can be sorted by price, and can also filter the products corresponding to the price range. Commodity information is diverse.
Interface name: item_search
Request address: https://o0b.cn/jennif
Request parameters:
- q: search keywords
- cat: Category ID
- start_price: start price
- end_price: end price
- sort: sort [bid,_bid,bid2,_bid2,_sale,_credit]
- (bid: total price, bid2: commodity price, sale: sales volume, credit credit, add _ prefix to sort from large to small)
- page: number of pages
Response parameters:
Version: Date:
name | type | must | example value | describe |
---|---|---|---|---|
title |
String | 0 | French retro Yamamoto super fairy chic fairy Hepburn net red early spring very fairy French niche skirt two-piece suit | product title |
pic_url |
String | 0 | //img.alicdn.com/bao/uploaded/i3/3083218865/O1CN012FMDaiwxkenJGaM_!!0-item_pic.jpg | baby pictures |
promotion_price |
Float | 0 | 178.00 | discounted price |
price |
Float | 0 | 178.00 | price |
sales |
Int | 0 | 890 | Sales |
num_id |
Bigint | 0 | 577437133060 | Baby ID |
sample_id |
String | 0 | Commodity style identification ID | |
seller_nick |
String | 0 | Chumu Flagship Store | Shopkeeper Nickname |
post_fee |
Float | 0 | 10.00 | Logistics costs |
area |
String | 0 | Shandong | store location |
detail_url |
String | 0 | //detail.tmall.com/item.htm?id=586794298909&ns=1&abbucket=0 | baby link |
seller_info |
Mix | 0 | {"level": 99, "shop_type": "B", "user_num_id": "2217148345", "cid": 0, "delivery_score": "", "item_score": "", "score_p": ""} | seller info |
Call example:
curl method
-- 请求示例 url 默认请求参数已经URL编码处理
curl -i "https://api-服务器.cn/taobao/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter="
PHP
<?php
// 请求示例 url 默认请求参数已经URL编码处理
// 获取本示例服务器地址请参考:https://o0b.cn/jennif
$method = "GET";
$url = "https://api-服务器.cn/taobao/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter=";
$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));
?>
PHPsdk
<?php
//定义缓存目录和引入文件
define("DIR_RUNTIME","runtime/");
define("DIR_ERROR","runtime/");
define("SECACHE_SIZE","0");
//SDK下载地址 https://o0b.cn/jennif
include ("ObApiClient.php");
$obapi = new otao\ObApiClient();
$obapi->api_url = "http://api-服务器.cn/";
$obapi->api_urls = array("http://api-服务器.cn/","http://api-服务器1.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",
"api_params"=>array (
'q' => '女装',
'start_price' => '0',
'end_price' => '0',
'page' => '1',
'cat' => '0',
'discount_only' => '',
'sort' => '',
'page_size' => '',
'seller_info' => '',
'nick' => '',
'ppath' => '',
'imgid' => '',
'filter' => '',
)
)
);
var_dump($api_data);
?>
Java
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-服务器.cn/taobao/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter=";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}