小紅書用戶收藏的筆記 API (V1)
API 端點健康狀態
健康 可用 少量可用 基本不可用 暫無資料
正在載入健康狀態…
通過用戶ID和游標分頁獲取小紅書(RedNote)用戶收藏的筆記。用於查看用戶保存的內容和研究內容興趣。
使用提示
使用說明
第一頁、後續頁、空收藏和私密收藏的結果均計費。
請求參數
| 參數名 | 位置 | 類型 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|---|
token |
query | string |
是 | - | 此 API 服務的訪問令牌。 |
userId |
query | string |
是 | - | 小紅書用戶的唯一標識符。 |
lastCursor |
query | string |
否 | |
獲取下一頁時,請傳遞上一回應中的游標。獲取第一頁時,請省略該參數或傳遞空值。 |
程式碼範例
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/xiaohongshu/get-user-faved-note-list/v1?token=YOUR_API_KEY&userId=VALUE'
text
我想使用 JustOneAPI 提供的“用戶收藏的筆記 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/xiaohongshu/get-user-faved-note-list/v1?token=YOUR_API_KEY&userId=VALUE
接口地址: BASE_URL + /api/xiaohongshu/get-user-faved-note-list/v1?token=YOUR_API_KEY&userId=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/xiaohongshu-rednote/user-favorited-notes-v1-zh-hant.json
請求參數說明:
- token (query): 此 API 服務的訪問令牌。 (必填)
- userId (query): 小紅書用戶的唯一標識符。 (必填)
- lastCursor (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/xiaohongshu/get-user-faved-note-list/v1?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-faved-note-list/v1?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-faved-note-list/v1?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-faved-note-list/v1?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-faved-note-list/v1?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)的主要返回欄位。
筆記基礎信息13 個欄位
data.notes[]
收藏列表中的一條筆記。
| 欄位 | 類型 | 說明 |
|---|---|---|
id |
string |
收藏筆記的 ID。 |
display_title |
string |
收藏列表中展示的筆記標題。 |
title |
string |
筆記標題,有該值時返回。 |
desc |
string |
返回的筆記正文或描述。 |
type |
string |
小紅書返回的筆記類型。 |
create_time |
integer |
筆記創建時間,Unix 時間戳,單位為秒。 |
last_update_time |
integer |
筆記最後更新時間,Unix 時間戳,單位為秒。可能為 0。 |
ip_location |
string |
小紅書顯示的筆記 IP 屬地標識,有該值時返回。 |
is_goods_note |
boolean |
小紅書是否將該筆記標記為商品筆記。 |
xsec_token |
string |
小紅書筆記連結關聯的令牌,有該值時返回。 |
note_attributes |
array |
小紅書返回的筆記屬性列表。 |
note_attributes[] |
string |
小紅書返回的單個原始筆記屬性值。 |
ats |
array |
筆記中提及的帳號列表,有相關信息時返回。 |
列表與分頁3 個欄位
data
當 data 為對象時,包含收藏筆記列表和分頁信息。請求成功時也可能沒有資料。
| 欄位 | 類型 | 說明 |
|---|---|---|
cursor |
string |
下一頁的分頁游標。繼續請求時,將該值原樣傳入 lastCursor。該欄位可能省略或為空。 |
has_more |
boolean |
當前回應是否提示還有下一頁。 |
notes |
array |
目標用戶的收藏筆記列表。收藏列表無法獲取時也可能返回空數組。 |
互動資料3 個欄位
data.notes[]
| 欄位 | 類型 | 說明 |
|---|---|---|
comments_count |
integer |
筆記顯示的評論數。 |
collected_count |
integer |
平台返回的筆記收藏數。 |
share_count |
integer |
接口返回的筆記分享數。 |
作者7 個欄位
data.notes[].user
筆記作者。
| 欄位 | 類型 | 說明 |
|---|---|---|
user_id |
string |
筆記作者的帳號 ID。 |
images |
string |
作者頭像連結,有該值時返回。 |
nickname |
string |
作者暱稱。 |
followed |
boolean |
小紅書在當前回應上下文返回的關注狀態。 |
red_official_verified |
boolean |
小紅書返回的官方認證狀態。 |
red_official_verify_type |
integer |
小紅書返回的官方認證類別編碼。 |
show_red_official_verify_icon |
boolean |
是否顯示官方認證圖標的標記。 |
實況照片35 個欄位
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 |
平台返回的流音頻時長數值。 |
media.stream.h265[].size |
integer |
小紅書返回的流大小數值。 |
media.stream.h266 |
array |
小紅書返回的 H.266 流列表,可能為空。 |
media.stream.av1 |
array |
小紅書返回的 AV1 流列表,可能為空。 |
圖片8 個欄位
data.notes[].images_list[]
筆記的圖片資源,視頻筆記也可能返回封面圖。
| 欄位 | 類型 | 說明 |
|---|---|---|
url |
string |
圖片連結。 |
original |
string |
原圖欄位中的連結。 |
width |
integer |
圖片元資料中記錄的寬度,單位為像素。 |
height |
integer |
圖片元資料中記錄的高度,單位為像素。 |
fileid |
string |
圖片在平台上的文件 ID。 |
index |
integer |
平台返回的圖片順序索引。 |
url_size_large |
string |
大尺寸圖片版本的連結。 |
live_photo_file_id |
string |
平台返回的圖片實況照片文件 ID。 |
視頻信息7 個欄位
data.notes[].video_info_v2
部分視頻筆記返回的視頻媒體信息。
| 欄位 | 類型 | 說明 |
|---|---|---|
image |
object |
與視頻關聯的圖片。 |
image.thumbnail |
string |
視頻縮略圖連結,有該值時返回。 |
image.first_frame |
string |
視頻首幀圖片連結,有該值時返回。 |
media |
object |
筆記的視頻和播放流信息。 |
media.video_id |
integer |
小紅書返回的數字型視頻 ID。 |
capa |
object |
視頻的補充信息。 |
capa.duration |
integer |
該欄位記錄的視頻時長,單位為秒。 |
視頻流64 個欄位
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 視頻流列表,有相關信息時返回。 |
h266[] |
object |
單條 H.266 視頻流的信息。 |
h266[].master_url |
string |
平台為該流提供的主連結。 |
h266[].backup_urls |
array |
平台為該流提供的備用連結列表。 |
h266[].backup_urls[] |
string |
流的備用連結。 |
h266[].width |
integer |
流的寬度,單位為像素。 |
h266[].height |
integer |
流的高度,單位為像素。 |
h266[].fps |
integer |
平台返回的流幀率。 |
h266[].format |
string |
平台返回的流媒體格式。 |
h266[].video_codec |
string |
平台返回的流視頻編解碼格式。 |
h266[].audio_codec |
string |
平台返回的流音頻編解碼格式,可能為空。 |
h266[].audio_channels |
integer |
平台返回的流音頻聲道數。 |
h266[].avg_bitrate |
integer |
平台返回的流平均碼率數值。 |
h266[].video_bitrate |
integer |
平台返回的流視頻碼率數值。 |
h266[].audio_bitrate |
integer |
平台返回的流音頻碼率數值。 |
h266[].quality_type |
string |
平台返回的流原始畫質標籤。 |
h266[].stream_desc |
string |
小紅書提供的流說明。 |
h266[].duration |
integer |
流的總時長,單位為毫秒。 |
h266[].video_duration |
integer |
視頻軌道時長,單位為毫秒。 |
h266[].audio_duration |
integer |
音頻軌道時長,單位為毫秒。流不含音頻時可能為 0。 |
h266[].size |
integer |
流的資料大小,單位為字節。 |
av1 |
array |
小紅書返回的 AV1 流列表,可能為空。 |
音頻流14 個欄位
data.notes[].video_info_v2.media.audio_stream
按編解碼格式分組的音頻流,有相關信息時返回。
| 欄位 | 類型 | 說明 |
|---|---|---|
AAC |
array |
AAC 音頻流列表,有相關信息時返回。 |
AAC[] |
object |
- |
AAC[].audio_codec |
string |
音頻編解碼格式標籤。 |
AAC[].audio_channels |
integer |
音頻流的聲道數。 |
AAC[].master_url |
string |
音頻流的主要播放連結。 |
AAC[].backup_urls |
array |
音頻流的備用播放連結。 |
AAC[].backup_urls[] |
string |
- |
AAC[].format |
string |
平台返回的音頻流媒體格式。 |
AAC[].audio_profile |
string |
平台返回的音頻編碼配置(Profile)。 |
AAC[].audio_samplerate |
integer |
音頻採樣率,單位為赫茲(Hz)。 |
AAC[].audio_duration |
integer |
音頻流時長,單位為毫秒。 |
AAC[].size |
integer |
音頻流的資料大小,單位為字節。 |
AAC[].audio_bitrate |
integer |
平台返回的流音頻碼率數值。 |
AAC[].avg_bitrate |
integer |
平台返回的音頻流平均碼率數值。 |
其他欄位9 個欄位
| 欄位路徑 | 類型 | 說明 |
|---|---|---|
data.notes[].video_info_v2.media.video |
object |
視頻筆記中的視頻基本信息。 |
data.notes[].video_info_v2.media.video.width |
integer |
視頻寬度,單位為像素。 |
data.notes[].video_info_v2.media.video.height |
integer |
視頻高度,單位為像素。 |
data.notes[].video_info_v2.media.video.duration |
integer |
視頻時長,單位為秒。 |
data.notes[].video_info_v2.media.video.drm_type |
integer |
平台返回的視頻 DRM 原始類別編碼。 |
data.notes[].video_info_v2.media.video.hdr_type |
integer |
平台返回的視頻 HDR 原始類別編碼。 |
data.notes[].video_info_v2.media.video.stream_types |
array |
平台返回的視頻流類型編碼列表。 |
data.notes[].video_info_v2.media.video.stream_types[] |
integer |
平台返回的視頻原始流類型編碼。 |
data.notes[].video_info_v2.media.video.md5 |
string |
視頻元資料中返回的 MD5 值。 |
回應示例
正在載入回應範例…