跳至主要內容

閒魚商品詳情 API (V1) ​

GET
API 端點健康狀態
健康 可用 少量可用 基本不可用 暫無資料
正在載入健康狀態…

通過商品ID獲取閒魚二手商品的公開詳情。用於在搜索或連結發現後檢查已知轉售商品。

請求參數 ​

參數名 位置 類型 必填 預設值 說明
token query string 是 - 此 API 服務的訪問令牌。
itemId query string 是 - 閒魚上的唯一商品標識符。

程式碼範例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/xianyu/get-item-detail/v1?token=YOUR_API_KEY&itemId=VALUE'
text
我想使用 JustOneAPI 提供的“商品詳情 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/xianyu/get-item-detail/v1?token=YOUR_API_KEY&itemId=VALUE
接口地址: BASE_URL + /api/xianyu/get-item-detail/v1?token=YOUR_API_KEY&itemId=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/xianyu-goofish/product-details-v1-zh-hant.json

請求參數說明:
- token (query): 此 API 服務的訪問令牌。 (必填)
- itemId (query): 閒魚上的唯一商品標識符。 (必填)

返回格式: 請根據實際 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/xianyu/get-item-detail/v1?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/xianyu/get-item-detail/v1?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/xianyu/get-item-detail/v1?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/xianyu/get-item-detail/v1?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/xianyu/get-item-detail/v1?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)的主要返回欄位。

商品與返回狀態4 個欄位

data

對象中包含商品詳情,也可能帶有下架等狀態。業務成功時還可能返回商品不可用的提示文本或 null。

欄位 類型 說明
itemDO object 查詢商品的詳情。
itemDO.itemId string 閒魚商品 ID。
itemDO.title string 商品標題。
itemDO.itemStatusStr string 商品狀態文案,可能提示商品已下架。
商品信息與類目16 個欄位

data.itemDO

欄位 類型 說明
desc string 商品的純文本描述。
richTextDesc string 商品的富文本描述。
itemType string 平台返回的商品類型。
itemStatus string 以字符串返回的商品狀態代碼。
gmtCreate string 商品創建時間,以 Unix 毫秒時間戳字符串返回。
GMT_CREATE_DATE_KEY string 商品創建日期文案。
quantity string 以字符串返回的商品數量。
categoryId string 商品所屬的類目 ID。
itemCatDTO object 商品關聯的類目標識。
itemCatDTO.catId string 類目對象中的類目 ID。
itemCatDTO.leafId string 末級類目 ID。
itemCatDTO.channelCatId string 閒魚頻道類目 ID。
itemCatDTO.rootChannelCatId string 閒魚頻道頂級類目 ID。
itemCatDTO.level2ChannelCatId string 閒魚頻道二級類目 ID。
itemCatDTO.level3ChannelCatId string 閒魚頻道三級類目 ID。
itemCatDTO.tbCatId string 關聯的淘寶類目 ID。
價格與運費12 個欄位

data.itemDO

欄位 類型 說明
soldPrice string 以十進制字符串返回的商品價格。商品已下架時也可能返回此欄位。
originalPrice string 以字符串返回的商品原價。
defaultPrice string 預設價格欄位以字符串返回,可能為空或包含非數字內容。
priceUnit string 價格單位的展示文案,可能為空。
transportFee string 以字符串返回的商品運費。
promotionPriceDO object 商品的促銷價格信息,可能省略。
promotionPriceDO.promotionName string 促銷價格的名稱。
promotionPriceDO.promotionPriceMin string 以字符串返回的最低促銷價。
promotionPriceDO.minDiscountFeeStr string 最低優惠金額的展示文案。
priceRelativeTags array 商品價格旁的展示標籤。
priceRelativeTags[] object 一項價格展示標籤。
priceRelativeTags[].text string 價格標籤的展示文案。
互動資料7 個欄位

data.itemDO

欄位 類型 說明
browseCnt string 以字符串返回的商品瀏覽數。
wantCnt string 以字符串返回的商品想要人數。
wantCntUnit string 想要人數的展示單位。
soldCnt string 以字符串返回的商品銷量。
collectCnt string 以字符串返回的商品收藏數。
favorCnt string 以字符串返回的商品收藏相關計數。
interactFavorCnt string 商品互動中的收藏相關計數,以字符串返回。
圖片與視頻19 個欄位

data.itemDO

欄位 類型 說明
defaultPicture string 商品的預設圖片地址。
noPicItem string 商品是否帶有無圖標記,以字符串返回。
imageInfos array 商品相冊圖片列表,可能為空。
imageInfos[] object 商品相冊中的一張圖片。
imageInfos[].major string 是否標記為主圖,以字符串返回。
imageInfos[].widthSize string 以字符串返回的圖片寬度,單位為像素。
imageInfos[].heightSize string 以字符串返回的圖片高度,單位為像素。
imageInfos[].type string 以字符串返回的圖片類型代碼。
imageInfos[].url string 相冊圖片地址。
videoPlayInfo object 商品視頻信息,可能省略。
videoPlayInfo.videoId string 商品視頻的標識。
videoPlayInfo.major string 是否標記為主視頻,以字符串返回。
videoPlayInfo.type string 以字符串返回的視頻類型代碼。
videoPlayInfo.widthSize string 以字符串返回的視頻寬度,單位為像素。
videoPlayInfo.heightSize string 以字符串返回的視頻高度,單位為像素。
videoPlayInfo.url string 視頻條目關聯的圖片地址。
videoPlayInfo.playUrl string 商品視頻播放地址。
videoPlayInfo.ld320pUrl string 320p 版本的視頻播放地址。
videoPlayInfo.sd480pUrl string 480p 版本的視頻播放地址。
屬性與話題26 個欄位

data.itemDO

欄位 類型 說明
commonTags array 商品的通用展示標籤。
commonTags[] object 一項通用展示標籤。
commonTags[].text string 通用標籤的展示文案。
itemLabelExtList array 商品的擴展標籤列表。
itemLabelExtList[] object 一項商品擴展標籤。
itemLabelExtList[].labelId string 此標籤的標識。
itemLabelExtList[].labelType string 此標籤的類型代碼。
itemLabelExtList[].propertyId string 標籤關聯的屬性 ID。
itemLabelExtList[].propertyText string 標籤關聯屬性的展示名稱。
itemLabelExtList[].valueId string 標籤值的標識。
itemLabelExtList[].valueText string 標籤值的展示文案。
itemLabelExtList[].text string 標籤的展示文案。
cpvLabels array 商品關聯的類目屬性標籤列表。
cpvLabels[] object 一項類目屬性標籤。
cpvLabels[].propertyId string 類目屬性 ID。
cpvLabels[].propertyName string 類目屬性名稱。
cpvLabels[].valueId string 類目屬性值 ID。
cpvLabels[].valueName string 類目屬性值的展示名稱。
cpvTopics array 與商品類目屬性關聯的話題列表。
cpvTopics[] object 一個類目屬性關聯話題。
cpvTopics[].id string 話題 ID。
cpvTopics[].name string 話題展示名稱。
cpvTopics[].pvList array 話題關聯的屬性與屬性值 ID 列表。
cpvTopics[].pvList[] object 話題關聯的一對屬性與屬性值。
cpvTopics[].pvList[].propertyId string 類目屬性 ID。
cpvTopics[].pvList[].valueId string 類目屬性值 ID。
商品服務與公益標記7 個欄位

data.itemDO

欄位 類型 說明
uiItemServiceDOList array 商品附帶的服務保障條目。
uiItemServiceDOList[] object 一項服務保障。
charitableItem string 商品是否帶有公益標記,以字符串返回。
charitableTag object 公益商品的展示標籤。
charitableTag.iconHeight string 以字符串返回的標籤圖標高度,單位為像素。
charitableTag.iconWidth string 以字符串返回的標籤圖標寬度,單位為像素。
charitableTag.iconUrl string 標籤圖標的圖片地址。
賣家資料12 個欄位

data.sellerDO

與商品關聯的賣家資料和服務信息。

欄位 類型 說明
sellerId string 閒魚賣家 ID。
nick string 賣家展示暱稱。
desensitizationNick string 脫敏後的賣家暱稱。
uniqueName string 平台返回的賣家唯一名稱。
portraitUrl string 賣家頭像地址。
city string 賣家資料中返回的城市。
publishCity string 商品發佈城市。
businessType string 平台返回的賣家經營類型。
userRegDay string 以字符串返回的賣家註冊天數。
registerTime string 以時間戳字符串返回的賣家註冊時間。
itemCount string 以字符串返回的賣家商品數。
hasSoldNumInteger string 以字符串返回的賣家已售商品數。
賣家回覆與評價9 個欄位

data.sellerDO

欄位 類型 說明
newGoodRatioRate string 賣家好評率的展示文案。
replyRatio24h string 賣家 24 小時內回覆率的展示文案。
replyIn24hRatioDouble string 以數字字符串返回的 24 小時內回覆率。
replyInterval string 賣家回覆間隔的展示文案。
avgReply30dLong string 以字符串返回的賣家近 30 天平均回覆時長。
remarkDO object 賣家各類評價的計數。
remarkDO.sellerDefaultRemarkCnt string 以字符串返回的賣家預設評價數。
remarkDO.sellerGoodRemarkCnt string 以字符串返回的賣家好評數。
remarkDO.sellerBadRemarkCnt string 以字符串返回的賣家差評數。
賣家標識26 個欄位

data.sellerDO

欄位 類型 說明
idleFishCreditTag object 賣家展示的閒魚信用標識。
idleFishCreditTag.iconHeight string 以字符串返回的標籤圖標高度,單位為像素。
idleFishCreditTag.iconWidth string 以字符串返回的標籤圖標寬度,單位為像素。
idleFishCreditTag.iconUrl string 標籤圖標的圖片地址。
sellerInfoTags array 隨商品展示的賣家信息標籤列表。
sellerInfoTags[] object 一項賣家信息標籤。
sellerInfoTags[].iconHeight string 以字符串返回的標籤圖標高度,單位為像素。
sellerInfoTags[].iconWidth string 以字符串返回的標籤圖標寬度,單位為像素。
sellerInfoTags[].iconUrl string 標籤圖標的圖片地址。
sellerInfoTags[].text string 賣家信息標籤的展示文案。
identityTags array 賣家身份的展示標籤列表。
identityTags[] object 一項賣家身份標籤。
identityTags[].iconHeight string 以字符串返回的標籤圖標高度,單位為像素。
identityTags[].iconWidth string 以字符串返回的標籤圖標寬度,單位為像素。
identityTags[].iconUrl string 標籤圖標的圖片地址。
identityTags[].text string 賣家身份標籤的展示文案。
levelTags array 賣家等級的展示標籤列表。
levelTags[] object 一項賣家等級標籤。
levelTags[].iconHeight string 以字符串返回的標籤圖標高度,單位為像素。
levelTags[].iconWidth string 以字符串返回的標籤圖標寬度,單位為像素。
levelTags[].iconUrl string 標籤圖標的圖片地址。
goodSellerTag object 賣家資料附帶的優質賣家標識,可能省略。
goodSellerTag.iconHeight string 以字符串返回的標籤圖標高度,單位為像素。
goodSellerTag.iconWidth string 以字符串返回的標籤圖標寬度,單位為像素。
goodSellerTag.iconUrl string 標籤圖標的圖片地址。
goodSellerTag.text string 優質賣家標識的展示文案。
賣家其他商品7 個欄位

data.sellerDO

欄位 類型 說明
sellerItems array 賣家其他商品的展示條目,可能為空,也可能包含沒有商品 ID 的條目。
sellerItems[] object 賣家其他商品列表中的一個條目。
sellerItems[].itemId string 關聯商品的 ID,可能省略。
sellerItems[].title string 關聯商品的展示標題。
sellerItems[].text string 關聯商品條目的展示文案。
sellerItems[].iconUrl string 關聯商品條目附帶的圖片地址。
sellerItems[].type string 關聯商品條目的類型代碼。

回應示例 ​

正在載入回應範例…