京東商品詳情 API (V4)
API 端點健康狀態
健康 可用 少量可用 基本不可用 暫無資料
正在載入健康狀態…
通過商品 ID 獲取京東商品詳情。可用於查看商品信息和圖片,以進行商品目錄研究或電商分析。
分頁獲取買家評論請參閱京東商品評論 API(V1)。
使用提示
支持能力 · 價格
商品價格信息可用。
支持能力 · 屬性
提供分組商品參數表。
支持能力 · SKU 選項
提供 SKU 標識符、選項名稱和圖片。
支持能力 · 主圖和輪播圖
提供所選 SKU 的主圖和輪播圖。
適用條件 · 描述圖片
img_list 可能將主圖與一些描述圖或示意圖混在一起。使用 V3 獲取單獨、更完整的描述圖片列表。
請求參數
| 參數名 | 位置 | 類型 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|---|
token |
query | string |
是 | - | 此 API 服務的訪問令牌。 |
itemId |
query | string |
是 | - | 京東商品的唯一產品標識符(商品ID)。 |
程式碼範例
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=VALUE'
text
我想使用 JustOneAPI 提供的“商品詳情 (V4)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=VALUE
接口地址: BASE_URL + /api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/jdcom/product-details-v4-zh-hant.json
請求參數說明:
- token (query): 此 API 服務的訪問令牌。 (必填)
- itemId (query): 京東商品的唯一產品標識符(商品ID)。 (必填)
返回格式: 請根據實際 Content-Type 安全處理 JSON 或文本回應。
回應處理與錯誤代碼:
1. 需通過返回體中的 "code" 欄位判斷業務結果(code 為 0 表示成功)。
2. 逾時建議:建議將請求逾時時間設置為 120 秒;如果 120 秒偏長,請至少設置為 60 秒,但可能會有少量請求因逾時而未接收到結果。
3. 業務碼說明:
- 0: 成功
- 100: Token 無效或已失效
- 301: 採集失敗,請重試
- 302: 超出速率限制
- 303: 超出每日配額
- 400: 參數錯誤
- 500: 內部伺服器錯誤
- 600: 權限不足
- 601: 帳戶餘額不足
- 602: TOKEN 限額超限
4. code 601 表示帳戶共享餘額不足。code 602 表示當前 API TOKEN 自身的累計消費上限已達到。TOKEN 限額不是資金劃撥,多個 TOKEN 仍共享同一個帳戶餘額。
請幫我用我擅長的編程語言寫一個腳本來呼叫這個接口,並處理返回結果。
python
import requests
BASE_URL = "https://api.justoneapi.com" # 由 OpenAPI servers 提供
url = BASE_URL + "/api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=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 servers 提供
const url = BASE_URL + "/api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=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 servers 提供
final String url = BASE_URL + "/api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=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 servers 提供
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=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 servers 提供
$url = $BASE_URL . '/api/jd/get-item-detail/v4?token=YOUR_API_KEY&itemId=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)的主要返回欄位。
商品摘要8 個欄位
data.itemOnly
商品摘要及品牌、類目和可選 SKU。
| 欄位 | 類型 | 說明 |
|---|---|---|
skuId |
string |
所查詢的京東 SKU ID,以字符串返回。 |
skuName |
string |
商品摘要返回的 SKU 標題。 |
brandId |
string |
京東品牌 ID,以字符串返回。 |
brandName |
string |
京東商品目錄中的品牌名稱。 |
category |
array |
此 SKU 所屬類目路徑中的京東類目 ID。 |
category[] |
string |
單個京東類目 ID。 |
venderID |
string |
京東商家 ID,以字符串返回。 |
isPop |
boolean |
京東返回的第三方商家銷售標記。 |
可選規格15 個欄位
data.itemOnly
| 欄位 | 類型 | 說明 |
|---|---|---|
newColorSize |
array |
商品列出的可選 SKU,列表中也可包含本次查詢的 SKU。 |
newColorSize[] |
object |
一條可選 SKU 及其規格值。 |
newColorSize[].skuId |
string |
此規格對應的京東 SKU ID。 |
newColorSize[].color |
string |
此規格顯示的顏色或第一項規格名稱。 |
newColorSize[].size |
string |
可用時返回該規格的尺碼、容量或第二項規格名稱。 |
newColorSize[].spec |
string |
可用時返回該規格的附加規格值。 |
newColorSize[].specName |
string |
可用時返回附加規格的名稱。 |
newColorSize[].imagePath |
string |
此規格的圖片引用。 |
saleProp |
object |
以銷售屬性 ID 為鍵、屬性展示名稱為值的對象。 |
saleProp.{key} |
string |
此銷售屬性的展示名稱。 |
salePropSeq |
object |
以銷售屬性 ID 為鍵、按順序排列的規格值列表為值的對象。 |
salePropSeq.{key} |
array |
此銷售屬性下按順序排列的規格值。 |
salePropSeq.{key}[] |
string |
一條規格值字符串。 |
spAttr |
object |
以規格名稱為鍵、SKU 的規格展示值為值的對象。 |
spAttr.{key} |
string |
此規格的展示值。 |
當前 SKU 詳情20 個欄位
data.itemInfo.product
商品詳情及當前 SKU 信息。
| 欄位 | 類型 | 說明 |
|---|---|---|
skuId |
string |
商品詳情結構中的京東 SKU ID。 |
skuName |
string |
商品詳情結構中的標題,可能與商品摘要標題不同。 |
realSpuId |
string |
京東返回的 SPU ID,以字符串返回。 |
brandId |
string |
商品詳情結構中的京東品牌 ID。 |
brandName |
string |
商品詳情結構中的品牌名稱。 |
cat1 |
string |
京東一級類目 ID。 |
cat2 |
string |
京東二級類目 ID。 |
cat3 |
string |
京東三級類目 ID。 |
color |
string |
當前 SKU 的顏色或第一項規格名稱。 |
size |
string |
可用時返回當前 SKU 的尺碼、容量或第二項規格名稱。 |
spec |
string |
可用時返回當前 SKU 的附加規格值。 |
specName |
string |
可用時返回當前 SKU 附加規格的名稱。 |
imageurl |
string |
商品詳情結構中的當前 SKU 圖片引用。 |
venderId |
string |
商品詳情結構中的商家 ID,以字符串返回。 |
shopId |
string |
商品詳情結構中的店鋪 ID,以字符串返回。 |
model |
string |
可用時返回商品型號。 |
length |
string |
京東報告的商品長度,以字符串返回。 |
width |
string |
京東報告的商品寬度,以字符串返回。 |
height |
string |
京東報告的商品高度,以字符串返回。 |
weight |
string |
京東報告的商品重量,以字符串返回。 |
價格10 個欄位
data
| 欄位 | 類型 | 說明 |
|---|---|---|
itemInfo.priceFloor |
object |
商品詳情結構中的價格展示信息。 |
itemInfo.priceFloor.price |
string |
京東價格展示文本,可能返回非小數格式的值。 |
itemInfo.priceFloor.ext |
object |
補充價格展示信息。 |
itemInfo.priceFloor.ext.jdPrice |
string |
補充價格展示信息中的京東價格文本。 |
priceInfo |
object |
此 SKU 的價格資料。 |
priceInfo.skuId |
integer |
此價格記錄對應的京東 SKU ID,以整數返回。 |
priceInfo.jdPrice |
number |
此價格結構返回的京東價格,類型為數值。 |
priceInfo.productPrice |
object |
補充商品價格資料。 |
priceInfo.productPrice.jdPrice |
number |
商品價格詳情中的京東價格,類型為數值。 |
priceInfo.productPrice.marketPrice |
number |
可用時返回京東報告的市場參考價。 |
圖片與詳情描述5 個欄位
data
| 欄位 | 類型 | 說明 |
|---|---|---|
itemOnly.image |
array |
商品摘要中的圖片引用。 |
itemOnly.image[] |
string |
一條摘要圖片引用。 |
img_list |
array |
獨立於商品摘要返回的商品圖片列表。 |
img_list[] |
string |
一條商品圖片引用。 |
description |
string |
京東商品詳情描述,以 HTML 字符串返回。 |
商品屬性16 個欄位
data
| 欄位 | 類型 | 說明 |
|---|---|---|
products_introduction |
array |
分組的結構化商品屬性。 |
products_introduction[] |
object |
一個商品屬性組。 |
products_introduction[].groupName |
string |
可用時返回商品屬性組的展示名稱。 |
products_introduction[].atts |
array |
此組包含的屬性。 |
products_introduction[].atts[] |
object |
一條有名稱的商品屬性。 |
products_introduction[].atts[].attName |
string |
屬性的展示名稱。 |
products_introduction[].atts[].categoryGroupAttId |
string |
類目屬性組中的屬性 ID,以字符串返回。 |
products_introduction[].atts[].attRemark |
string |
可用時返回此屬性的備註。 |
products_introduction[].atts[].vals |
array |
此屬性的展示值列表。 |
products_introduction[].atts[].vals[] |
string |
一條屬性展示值字符串。 |
products_introduction[].atts[].attVals |
array |
此屬性的結構化值。 |
products_introduction[].atts[].attVals[] |
object |
一條結構化屬性值。 |
products_introduction[].atts[].attVals[].attValId |
integer |
可用時返回屬性值 ID。 |
products_introduction[].atts[].attVals[].attValName |
string |
屬性值的展示名稱。 |
products_introduction[].atts[].attVals[].attValueDefinition |
string |
可用時返回此屬性值的定義文本。 |
products_introduction[].atts[].attVals[].orderSort |
integer |
京東返回的屬性值排序位置。 |
店鋪與商家5 個欄位
data
| 欄位 | 類型 | 說明 |
|---|---|---|
shop_infos |
object |
隨 SKU 返回的京東店鋪和商家信息。 |
shop_infos.shopId |
integer |
京東店鋪 ID,以整數返回。 |
shop_infos.shopName |
string |
店鋪展示名稱。 |
shop_infos.venderId |
integer |
京東商家 ID,以整數返回。 |
shop_infos.vender |
string |
京東顯示的商家名稱。 |
回應示例
正在載入回應範例…