Taobao และ Tmall การค้นหาสินค้า API (V1)
สถานะสุขภาพของ API
สถานะดี มีสภาพ จำกัด ส่วนใหญ่ไม่มีสภาพ ไม่มีข้อมูล
กำลังโหลดสถานะสุขภาพ...
ค้นหาสินค้าจาก Taobao และ Tmall โดยใช้คีย์เวิร์ด พร้อมการแบ่งหน้า การจัดเรียง ตัวเลือกการค้นหาเฉพาะ Tmall และการกรองราคาพร้อมขอบเขต ใช้เพื่อค้นหาสินค้าและจำกัดการค้นหาเพื่อการวิจัยด้านอีคอมเมิร์ซ
พารามิเตอร์
| ชื่อ | ตำแหน่ง | ชนิดข้อมูล | จำเป็น | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|---|---|
token |
query | string |
ใช่ | - | โทเค็นการเข้าถึงสำหรับบริการ API นี้ |
keyword |
query | string |
ใช่ | - | คำสำคัญสำหรับการค้นหา. |
sort |
query | string |
ไม่ใช่ | _sale |
ลำดับการจัดเรียงผลลัพธ์. ค่าที่มีอยู่: - _sale: ขายดี- _bid: ราคา: จากสูงไปต่ำ- bid: ราคา: จากต่ำไปสูง- _coefp: ทั่วไป |
tmall |
query | boolean |
ไม่ใช่ | false |
ว่าจะกรองผลลัพธ์เฉพาะสำหรับ Taobao เท่านั้นหรือไม่. |
startPrice |
query | string |
ไม่ใช่ | - | ราคาขั้นต่ำสำหรับการกรอง (รวมอยู่ด้วย). |
endPrice |
query | string |
ไม่ใช่ | - | ราคาสูงสุดสำหรับการกรอง (รวมอยู่ด้วย). |
page |
query | integer |
ไม่ใช่ | 1 |
หมายเลขหน้าสำหรับการพับหน้า。 |
ตัวอย่างโค้ด
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE'
text
ฉันต้องการใช้ API "การค้นหาสินค้า (V1)" จาก JustOneAPI.
URL หลัก: https://api.justoneapi.com.
เส้นทาง API: /api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE
เอนด์พอยต์ API: BASE_URL + /api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE
เมธอด HTTP: GET
การยืนยันตัวตน: เพิ่มพารามิเตอร์ "token" เข้าไปใน URL.
คำนิยาม OpenAPI: https://docs.justoneapi.com/openapi/taobao-and-tmall/product-search-v1-th.json
พารามิเตอร์:
- token (query): โทเค็นการเข้าถึงสำหรับบริการ API นี้ (จำเป็น)
- keyword (query): คำสำคัญสำหรับการค้นหา. (จำเป็น)
- sort (query): ลำดับการจัดเรียงผลลัพธ์.
ค่าที่มีอยู่:
- `_sale`: ขายดี
- `_bid`: ราคา: จากสูงไปต่ำ
- `bid`: ราคา: จากต่ำไปสูง
- `_coefp`: ทั่วไป
- tmall (query): ว่าจะกรองผลลัพธ์เฉพาะสำหรับ Taobao เท่านั้นหรือไม่.
- startPrice (query): ราคาขั้นต่ำสำหรับการกรอง (รวมอยู่ด้วย).
- endPrice (query): ราคาสูงสุดสำหรับการกรอง (รวมอยู่ด้วย).
- page (query): หมายเลขหน้าสำหรับการพับหน้า。
รูปแบบที่ส่งกลับ: จัดการ JSON หรือข้อความอย่างปลอดภัยตามค่า Content-Type ที่ได้รับจริง
การจัดการผลตอบกลับและรหัสข้อผิดพลาด:
1. ตรวจสอบผลการทำงานจากฟิลด์ "code" ในผลตอบกลับ (รหัส 0 หมายถึงสำเร็จ)
2. แนะนำให้ตั้งระยะเวลารอ 120 วินาที หาก 120 วินาทีนานเกินไป ให้ตั้งอย่างน้อย 60 วินาที แต่คำขอบางรายการอาจหมดเวลาก่อนได้รับผลลัพธ์
3. รหัสผลลัพธ์:
- 0: สำเร็จ
- 100: โทเคนไม่ถูกต้องหรือถูกปิดใช้งาน
- 301: ดึงข้อมูลไม่สำเร็จ โปรดลองอีกครั้ง
- 302: เกินขีดจำกัดอัตราการเรียก
- 303: ใช้โควตารายวันครบแล้ว
- 400: พารามิเตอร์ไม่ถูกต้อง
- 500: ข้อผิดพลาดภายในเซิร์ฟเวอร์
- 600: ไม่มีสิทธิ์เข้าถึง
- 601: ยอดเงินคงเหลือไม่เพียงพอ
- 602: ถึงวงเงินของโทเคนแล้ว
4. รหัส 601 หมายถึงยอดเงินที่ใช้ร่วมกันของบัญชีไม่เพียงพอ รหัส 602 หมายถึงโทเคน API ถึงวงเงินสะสมของตนเองแล้ว การกำหนดวงเงินโทเคนจะไม่โอนเงินออกจากยอดเงินที่ใช้ร่วมกันของบัญชี
กรุณาช่วยเขียนสคริปต์ในภาษาโปรแกรมที่ฉันชื่นชอบเพื่อเรียกใช้ API และจัดการการตอบกลับ.
python
import requests
BASE_URL = "https://api.justoneapi.com" # ให้โดยเซิร์ฟเวอร์ OpenAPI
url = BASE_URL + "/api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
content_type = response.headers.get("content-type", "").lower()
if "json" in content_type:
try:
print(response.json())
except ValueError:
print(response.text)
elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
print(response.text)
else:
with open("response.bin", "wb") as output:
output.write(response.content)
print(f"Saved {len(response.content)} bytes to response.bin")
js
const BASE_URL = "https://api.justoneapi.com"; // ให้โดยเซิร์ฟเวอร์ OpenAPI
const url = BASE_URL + "/api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE";
const response = await fetch(url, {
method: "GET",
signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
const contentType = (response.headers.get("content-type") || "").toLowerCase();
const mediaType = contentType.split(";", 1)[0].trim();
const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
if (textual) {
const responseText = new TextDecoder().decode(responseBytes);
let data = responseText;
if (contentType.includes("json")) {
try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
}
console.log(data);
} else {
console.log(`Received ${responseBytes.byteLength} binary bytes`);
}
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws Exception {
final String BASE_URL = "https://api.justoneapi.com"; // ให้โดยเซิร์ฟเวอร์ OpenAPI
final String url = BASE_URL + "/api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE";
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(120))
.method("GET", HttpRequest.BodyPublishers.noBody());
HttpRequest request = builder.build();
HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
System.out.println(response.statusCode());
String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
String mediaType = contentType.split(";", 2)[0].trim();
if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
System.out.println(new String(response.body(), StandardCharsets.UTF_8));
} else {
Files.write(Path.of("response.bin"), response.body());
System.out.println("Saved " + response.body().length + " bytes to response.bin");
}
}
}
go
package main
import (
"fmt"
"io"
"os"
"strings"
"net/http"
"time"
)
const BASE_URL = "https://api.justoneapi.com" // ให้โดยเซิร์ฟเวอร์ OpenAPI
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE"
req, _ := http.NewRequest("GET", url, nil)
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println(resp.StatusCode)
bodyBytes, _ := io.ReadAll(resp.Body)
contentType := strings.ToLower(resp.Header.Get("Content-Type"))
mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
fmt.Println(string(bodyBytes))
} else {
os.WriteFile("response.bin", bodyBytes, 0600)
fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
}
}
php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // ให้โดยเซิร์ฟเวอร์ OpenAPI
$url = $BASE_URL . '/api/taobao/search-item-list/v1?token=YOUR_API_KEY&keyword=VALUE';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
echo $response;
} else {
file_put_contents('response.bin', $response);
echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}
ฟิลด์ที่ได้รับการตอบกลับ
ฟิลด์สำคัญในผลการตอบกลับที่สำเร็จ (code = 0).
ผลลัพธ์และการแสดงผลแบบแบ่งหน้า15 ฟิลด์
data
ผลการค้นหาสินค้าบน Taobao สำหรับหน้าแสดงผลที่ต้องการ พร้อมข้อมูลการแสดงผลและตัวเลือกการค้นหา
| ฟิลด์ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|
code |
string |
รหัสสถานะผลการค้นหาที่ส่งกลับมาในข้อมูลการตอบกลับ |
model |
object |
วัตถุผลการค้นหาที่ประกอบด้วยหน้าแสดงผลปัจจุบัน สินค้า และตัวเลือกการค้นหา |
model.success |
boolean |
สัญลักษณ์การสำเร็จที่รายงานในวัตถุผลการค้นหา |
model.responseStatus |
integer |
รหัสสถานะตัวเลขที่รายงานในวัตถุผลการค้นหา |
model.itemList |
array |
รายการสินค้าที่ส่งกลับมาสำหรับหน้าแสดงผลปัจจุบัน รายการนี้อาจว่างเปล่าได้ |
model.itemList[] |
object |
รายการสินค้าหนึ่งรายการจากหน้าแสดงผลการค้นหาในปัจจุบัน |
model.page |
object |
หมายเลขการแสดงผลและจำนวนผลลัพธ์ที่รายงานโดยการค้นหา |
model.page.pageNo |
integer |
หมายเลขหน้าที่ปัจจุบันที่รายงานโดยการค้นหา |
model.page.pageSize |
integer |
ขนาดของหน้าที่รายงานโดยการค้นหา |
model.page.prevNo |
integer |
หมายเลขหน้าที่แล้วที่รายงานโดยการค้นหา |
model.page.nextNo |
integer |
หมายเลขหน้าถัดไปที่รายงานโดยการค้นหา |
model.page.showBegin |
integer |
ตำแหน่งเริ่มต้นในช่วงการแสดงผลที่รายงาน |
model.page.showEnd |
integer |
ตำแหน่งสิ้นสุดในช่วงการแสดงผลที่รายงาน |
model.page.totalItems |
integer |
จำนวนผลลัพธ์ทั้งหมดที่รายงานโดยการค้นหา อาจเป็นบวกเมื่อรายการสินค้าปัจจุบันว่างเปล่า |
model.page.totalPages |
integer |
จำนวนหน้าทั้งหมดที่รายงานโดยการค้นหา |
รายละเอียดผลิตภัณฑ์14 ฟิลด์
data.model.itemList[]
| ฟิลด์ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|
itemId |
integer |
ID ของรายการใน Marketplace ที่ส่งกลับมาในรูปแบบตัวเลข |
prodId |
integer |
ID ของสินค้าที่เกี่ยวข้องกับรายการเมื่อส่งกลับมา |
spuId |
integer |
ID ของหน่วยสินค้ามาตรฐาน (SPU) ที่เกี่ยวข้องกับรายการ |
itemName |
string |
ชื่อรายการที่แสดงในผลการค้นหา |
itemSubName |
string |
ชื่อรายการเสริม ซึ่งอาจว่างเปล่าได้ |
itemType |
string |
รหัสประเภทของรายการใน Marketplace ที่ถูกเก็บไว้ในรูปแบบข้อความ |
itemLoc |
string |
ที่อยู่ที่แสดงสำหรับรายการ |
frontStock |
integer |
จำนวนสินค้าที่รายงานในผลการค้นหา |
hasTongkuan |
boolean |
ว่ามีการแสดงรายการที่ตรงกับสินค้าเดียวกันหรือไม่ |
hasXiangsi |
boolean |
ว่ามีการแสดงรายการที่คล้ายกันหรือไม่ |
picUrl |
string |
URL ของรูปภาพรายการหลักที่ค้นหาได้ |
picUrlFull |
string |
URL เต็มของรูปภาพรายการหลัก |
picUrlList |
array |
URL ของรูปภาพรายการอื่นๆ เมื่อส่งกลับมา |
picUrlList[] |
string |
URL ของรูปรายการที่แสดง |
ราคาและกิจกรรมการสั่งซื้อ8 ฟิลด์
data.model.itemList[]
| ฟิลด์ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|
priceFen |
integer |
ราคาเบื้องต้นในรูปแบบตัวเลขที่ผลการค้นหาส่งกลับมา |
priceYuanDouble |
number |
ราคาเบื้องต้นในรูปแบบทศนิยมที่ผลการค้นหาส่งกลับมา |
priceZKFen |
integer |
ราคาพิเศษในรูปแบบตัวเลขที่ผลการค้นหาส่งกลับมา |
priceZKYuanDouble |
number |
ราคาพิเศษในรูปแบบทศนิยมที่ผลการค้นหาส่งกลับมา |
discntPriceYuan |
number |
ราคาพิเศษที่รายงานสำหรับรายการสินค้า |
discntRate |
integer |
ค่าดัชนีส่วนลดในมาตราส่วนต้นฉบับที่ใช้ในการค้นหา |
discntType |
string |
รหัสประเภทส่วนลดที่รายงานสำหรับรายการสินค้า |
orderPayUV |
string |
จำนวนผู้ซื้อที่จ่ายเงินที่แสดงเป็นข้อความที่อาจรวมถึงเครื่องหมายบวก |
ร้านค้าและคะแนนรีวิว8 ฟิลด์
data.model.itemList[]
| ฟิลด์ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|
shopId |
integer |
ID ของร้านค้าที่เกี่ยวข้องกับรายการสินค้า ถูกส่งกลับมาในรูปแบบตัวเลข |
shopName |
string |
ชื่อที่ปรากฏของร้านค้าในผลการค้นหา |
sellerLoc |
string |
ที่อยู่ที่แสดงสำหรับผู้ขาย |
sellerLevel |
integer |
รหัสระดับผู้ขายที่รายงานโดยตลาด |
sellerGoodrat |
integer |
ค่าความพอใจของผู้ขายในมาตราส่วนที่รายงานโดยตลาด |
miaoshuDsr |
string |
ระดับการให้คะแนนของผู้ขายสำหรับความถูกต้องของคำอธิบายสินค้า ถูกส่งกลับมาในรูปแบบข้อความ |
fuwuDsr |
string |
ระดับการให้คะแนนด้านบริการของผู้ขาย ถูกส่งกลับมาในรูปแบบข้อความ |
fahuoDsr |
string |
ระดับการให้คะแนนด้านการจัดส่งของผู้ขาย ถูกส่งกลับมาในรูปแบบข้อความ |
ตัวกรองแบรนด์และคุณสมบัติ14 ฟิลด์
data.model
| ฟิลด์ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|
brandList |
array |
ยี่ห้อที่รายงานเป็นตัวกรองการค้นหา |
brandList[] |
object |
ตัวเลือกตัวกรองยี่ห้อ |
brandList[].brandId |
integer |
ID ของยี่ห้อสำหรับตัวเลือกตัวกรอง |
brandList[].brandName |
string |
ชื่อที่แสดงของตัวเลือกตัวกรองแบรนด์ |
brandList[].count |
integer |
จำนวนผลลัพธ์ที่รายงานสำหรับตัวเลือกตัวกรองยี่ห้อนี้ |
propertyList |
array |
คุณสมบัติของผลิตภัณฑ์ที่รายงานเป็นตัวกรองการค้นหา。 |
propertyList[] |
object |
คุณสมบัติของผลิตภัณฑ์ที่สามารถกรองได้。 |
propertyList[].pid |
integer |
ID ของแอตทริบิวต์สินค้าที่ใช้กรองได้ |
propertyList[].pname |
string |
ชื่อที่แสดงของแอตทริบิวต์สินค้าที่ใช้กรองได้ |
propertyList[].valueList |
array |
ค่าที่รายงานสำหรับตัวกรองคุณสมบัติ。 |
propertyList[].valueList[] |
object |
ค่าตัวกรองที่มีอยู่สำหรับคุณสมบัตินี้。 |
propertyList[].valueList[].vid |
integer |
ID ของค่าตัวกรองแอตทริบิวต์ |
propertyList[].valueList[].vname |
string |
ชื่อที่แสดงของค่าตัวกรองแอตทริบิวต์ |
propertyList[].valueList[].count |
integer |
จำนวนผลลัพธ์ที่รายงานสำหรับค่าคุณสมบัตินี้。 |
ตัวอย่างผลการตอบกลับ
กำลังโหลดตัวอย่างการตอบกลับ...