跳至主要內容

小紅書用戶筆記 API (V4) ​

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

通過用戶 ID 或支持的個人主頁 URL,讀取小紅書(RedNote)用戶已發佈的公開筆記,支持 lastCursor 分頁。此接口不會創建、上傳或發佈筆記。

請求參數 ​

參數名 位置 類型 必填 預設值 說明
token query string 是 - 此 API 服務的訪問令牌。
userId query string 是 - 小紅書用戶ID或包含 /user/profile/ 的個人資料URL。
lastCursor query string 否 - 首次請求不傳此參數。請求下一頁時,傳入上一頁回應中最後一條筆記的 cursor 值。

程式碼範例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=VALUE'
text
我想使用 JustOneAPI 提供的“用戶筆記 (V4)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=VALUE
接口地址: BASE_URL + /api/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/xiaohongshu-rednote/user-published-notes-v4-zh-hant.json

請求參數說明:
- token (query): 此 API 服務的訪問令牌。 (必填)
- userId (query): 小紅書用戶ID或包含 /user/profile/ 的個人資料URL。 (必填)
- lastCursor (query): 首次請求不傳此參數。請求下一頁時,傳入上一頁回應中最後一條筆記的 cursor 值。

返回格式: 請根據實際 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/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=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/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=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/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=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/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=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/xiaohongshu/get-user-note-list/v4?token=YOUR_API_KEY&userId=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

成功回應的 data 為對象時,包含已發佈筆記和分頁欄位。

欄位 類型 說明
has_more boolean 是否還有更多筆記。返回 false 時停止翻頁。
cursor string 可選的頁面級游標。has_more 為 true 時,將當前頁最後一條筆記的 cursor 作為 lastCursor 傳入。
notes array 目標用戶公開發布的筆記。分頁結束時可能返回空列表。
tags array 隨當前頁返回的標籤列表,可能為空。
筆記基礎信息12 個欄位

data.notes[]

當前頁中的一條已發佈筆記。

欄位 類型 說明
id string 小紅書筆記 ID。
cursor string 每條筆記對應的游標。has_more 為 true 時,將最後一條筆記的游標作為 lastCursor 傳入。
display_title string 在列表中展示的筆記標題。
title string 小紅書返回的筆記標題。
desc string 返回的筆記正文或描述。
type string 小紅書返回的筆記類型。已觀察到圖文筆記為 normal,視頻筆記為 video。
sticky boolean 小紅書是否將該筆記標記為置頂。
is_goods_note boolean 小紅書是否將該筆記標記為商品筆記。
create_time integer 筆記創建時間,Unix 時間戳,單位為秒。
last_update_time integer 筆記最後更新時間,Unix 時間戳,單位為秒。可能為 0。
time_desc string 平台返回的筆記日期展示文本。
ip_location string 筆記的地區標識,有該值時返回。
互動資料4 個欄位

data.notes[]

欄位 類型 說明
likes integer likes 欄位中返回的點贊數。
comments_count integer 筆記顯示的評論數。
collected_count integer 平台返回的筆記收藏數。
share_count integer 平台返回的筆記分享數。
作者與提及10 個欄位

data.notes[]

欄位 類型 說明
user object 隨筆記返回的作者信息。
user.userid string 筆記作者的小紅書帳號 ID。
user.nickname string 頁面展示的作者暱稱。
user.images string 作者頭像連結。
user.red_official_verify_type integer 平台返回的作者官方認證類別編碼。
ats array 筆記中提及的帳號列表。
ats[] object 筆記中提及的一個帳號。
ats[].id string 被提及用戶的小紅書帳號 ID。
ats[].name string 平台返回的被提及帳號名稱。
ats[].nickname string 平台返回的被提及帳號暱稱。
實況照片37 個欄位

data.notes[].images_list[].live_photo

圖片的實況照片信息。有相關信息時返回。

欄位 類型 說明
media object 平台提供的實況照片播放信息。
media.video_id string 平台返回的實況照片媒體視頻 ID。
media.video object 與實況照片關聯的視頻信息。
media.video.width integer 視頻寬度,單位為像素。
media.video.height integer 視頻高度,單位為像素。
media.video.duration integer 視頻時長,按整秒返回。
media.video.drm_type integer 平台返回的視頻 DRM 原始類別編碼。
media.video.hdr_type integer 平台返回的視頻 HDR 原始類別編碼。
media.video.stream_types array 平台返回的視頻流類型編碼列表。
media.video.stream_types[] integer 平台返回的視頻原始流類型編碼。
media.stream object 按小紅書返回的編解碼標籤分組的流版本。
media.stream.h264 array 實況照片的 H.264 流列表。
media.stream.h265 array 實況照片的 H.265 流列表。
media.stream.h265[] object 單條實況照片 H.265 流的信息。
media.stream.h265[].master_url string 平台為該流提供的主連結。
media.stream.h265[].backup_urls array 平台為該流提供的備用連結列表。
media.stream.h265[].backup_urls[] string 流的備用連結。
media.stream.h265[].width integer 流的寬度,單位為像素。
media.stream.h265[].height integer 流的高度,單位為像素。
media.stream.h265[].fps integer 平台返回的視頻幀率,單位為幀每秒。
media.stream.h265[].format string 平台返回的流媒體格式。
media.stream.h265[].video_codec string 平台返回的流視頻編解碼格式。
media.stream.h265[].audio_codec string 平台返回的流音頻編解碼格式,可能為空。
media.stream.h265[].audio_channels integer 平台返回的流音頻聲道數。
media.stream.h265[].avg_bitrate integer 媒體流平均碼率,單位為比特每秒。
media.stream.h265[].video_bitrate integer 視頻軌道碼率,單位為比特每秒。
media.stream.h265[].audio_bitrate integer 音頻軌道碼率,單位為比特每秒。
media.stream.h265[].quality_type string 平台返回的流原始畫質標籤。
media.stream.h265[].stream_desc string 小紅書提供的流說明。
media.stream.h265[].duration integer 媒體流總時長,單位為毫秒。
media.stream.h265[].video_duration integer 視頻軌道時長,單位為毫秒。
media.stream.h265[].audio_duration integer 音頻軌道時長,單位為毫秒。0 可能表示沒有音頻軌道。
media.stream.h265[].size integer 媒體流文件大小,單位為字節。
media.stream.h266 array 小紅書返回的 H.266 流列表,可能為空。
media.stream.av1 array 小紅書返回的 AV1 流列表,可能為空。
consumer object 實況照片的播放選項。
consumer.can_super_resolution boolean 播放信息是否標記支持超分辨率。
圖片7 個欄位

data.notes[].images_list[]

欄位 類型 說明
url string 圖片連結。該欄位為空時,大尺寸圖片連結仍可能有值。
original string 原圖連結欄位,可能為空。
width integer 圖片元資料中記錄的寬度,單位為像素。
height integer 圖片元資料中記錄的高度,單位為像素。
fileid string 圖片在平台上的文件 ID。
url_size_large string 大尺寸圖片版本的連結。
live_photo_file_id string 平台返回的圖片實況照片文件 ID。
視頻流44 個欄位

data.notes[].video_info_v2.media.stream

按小紅書返回的編解碼標籤分組的流版本。

欄位 類型 說明
h264 array 視頻筆記的 H.264 視頻流列表。
h264[] object 單條 H.264 視頻流的信息。
h264[].master_url string 平台為該流提供的主連結。
h264[].backup_urls array 平台為該流提供的備用連結列表。
h264[].backup_urls[] string 流的備用連結。
h264[].width integer 流的寬度,單位為像素。
h264[].height integer 流的高度,單位為像素。
h264[].fps integer 平台返回的視頻幀率,單位為幀每秒。
h264[].format string 平台返回的流媒體格式。
h264[].video_codec string 平台返回的流視頻編解碼格式。
h264[].audio_codec string 平台返回的流音頻編解碼格式,可能為空。
h264[].audio_channels integer 平台返回的流音頻聲道數。
h264[].avg_bitrate integer 媒體流平均碼率,單位為比特每秒。
h264[].video_bitrate integer 視頻軌道碼率,單位為比特每秒。
h264[].audio_bitrate integer 音頻軌道碼率,單位為比特每秒。
h264[].quality_type string 平台返回的流原始畫質標籤。
h264[].stream_desc string 小紅書提供的流說明。
h264[].duration integer 媒體流總時長,單位為毫秒。
h264[].video_duration integer 視頻軌道時長,單位為毫秒。
h264[].audio_duration integer 音頻軌道時長,單位為毫秒。0 可能表示沒有音頻軌道。
h264[].size integer 媒體流文件大小,單位為字節。
h265 array 視頻筆記的 H.265 視頻流列表。
h265[] object 單條 H.265 視頻流的信息。
h265[].master_url string 平台為該流提供的主連結。
h265[].backup_urls array 平台為該流提供的備用連結列表。
h265[].backup_urls[] string 流的備用連結。
h265[].width integer 流的寬度,單位為像素。
h265[].height integer 流的高度,單位為像素。
h265[].fps integer 平台返回的視頻幀率,單位為幀每秒。
h265[].format string 平台返回的流媒體格式。
h265[].video_codec string 平台返回的流視頻編解碼格式。
h265[].audio_codec string 平台返回的流音頻編解碼格式,可能為空。
h265[].audio_channels integer 平台返回的流音頻聲道數。
h265[].avg_bitrate integer 媒體流平均碼率,單位為比特每秒。
h265[].video_bitrate integer 視頻軌道碼率,單位為比特每秒。
h265[].audio_bitrate integer 音頻軌道碼率,單位為比特每秒。
h265[].quality_type string 平台返回的流原始畫質標籤。
h265[].stream_desc string 小紅書提供的流說明。
h265[].duration integer 媒體流總時長,單位為毫秒。
h265[].video_duration integer 視頻軌道時長,單位為毫秒。
h265[].audio_duration integer 音頻軌道時長,單位為毫秒。0 可能表示沒有音頻軌道。
h265[].size integer 媒體流文件大小,單位為字節。
h266 array 小紅書返回的 H.266 流列表,可能為空。
av1 array 小紅書返回的 AV1 流列表,可能為空。
音頻16 個欄位

data.notes[].video_info_v2.media

欄位 類型 說明
audio_stream object 按編解碼格式分組的音頻流,有相關信息時返回。
audio_stream.AAC array AAC 音頻流列表,有相關信息時返回。
audio_stream.AAC[] object 單條 AAC 音頻流的信息。
audio_stream.AAC[].audio_codec string 音頻編解碼格式標籤。
audio_stream.AAC[].audio_channels integer 音頻流的聲道數。
audio_stream.AAC[].master_url string 音頻流的主要播放連結。
audio_stream.AAC[].backup_urls array 音頻流的備用播放連結。
audio_stream.AAC[].backup_urls[] string 媒體流的備用連結。
audio_stream.AAC[].format string 平台返回的音頻流封裝格式。
audio_stream.AAC[].audio_bitrate integer 音頻軌道碼率,單位為比特每秒。
audio_stream.AAC[].audio_samplerate integer 平台返回的音軌採樣率。
audio_stream.AAC[].audio_duration integer 音頻軌道時長,單位為毫秒。
audio_stream.AAC[].size integer 音頻流文件大小,單位為字節。
audio_info object 有關可用音頻流類型的信息。
audio_info.stream_types array 音頻流類型編碼列表。
audio_info.stream_types[] integer 單個音頻流類型原始編碼。
字幕18 個欄位

data.notes[].video_info_v2.media.video.subtitles

按回應中的語言鍵分組的字幕軌道。

欄位 類型 說明
source array 原始語言字幕軌道。
source[] object 該語言對應的一條字幕軌道。
source[].language string 平台返回的字幕語言標識。
source[].url string 字幕軌道連結。
source[].format integer 字幕格式原始編碼。
source[].type integer 字幕類型原始編碼。
zh-CN array 簡體中文字幕軌道,有相關信息時返回。
zh-CN[] object 該語言對應的一條字幕軌道。
zh-CN[].language string 平台返回的字幕語言標識。
zh-CN[].url string 字幕軌道連結。
zh-CN[].format integer 字幕格式原始編碼。
zh-CN[].type integer 字幕類型原始編碼。
en-US array 美式英語字幕軌道,有相關信息時返回。
en-US[] object 該語言對應的一條字幕軌道。
en-US[].language string 平台返回的字幕語言標識。
en-US[].url string 字幕軌道連結。
en-US[].format integer 字幕格式原始編碼。
en-US[].type integer 字幕類型原始編碼。
視頻19 個欄位

data.notes[].video_info_v2

部分視頻筆記返回的視頻媒體信息。

欄位 類型 說明
image object 與視頻關聯的圖片。
image.thumbnail string 視頻縮略圖連結,有該值時返回。
image.first_frame string 視頻首幀圖片連結,有該值時返回。
image.thumbnail_dim string 視頻的另一種縮略圖連結。
media object 筆記的視頻和播放流信息。
media.video object 視頻筆記中的視頻基本信息。
media.video.width integer 視頻寬度,單位為像素。
media.video.height integer 視頻高度,單位為像素。
media.video.duration integer 視頻時長,按整秒返回。
media.video.drm_type integer 平台返回的視頻 DRM 原始類別編碼。
media.video.hdr_type integer 平台返回的視頻 HDR 原始類別編碼。
media.video.stream_types array 平台返回的視頻流類型編碼列表。
media.video.stream_types[] integer 平台返回的視頻原始流類型編碼。
media.video.md5 string 視頻元資料中返回的 MD5 值。
media.video_id string 平台返回的筆記媒體視頻 ID。
capa object 視頻的補充信息。
capa.duration integer 該欄位記錄的視頻時長,單位為秒。
consumer object 平台返回的視頻播放選項。
consumer.can_super_resolution boolean 播放信息是否標記支持超分辨率。
其他欄位2 個欄位
欄位路徑 類型 說明
data.notes[].images_list array 筆記的圖片資源,視頻筆記也可能返回封面圖。
data.notes[].images_list[] object 筆記關聯的一張圖片。

回應示例 ​

正在載入回應範例…