Skip to content

小红书 API - 笔记搜索 (V2)

prod-global
GET
/api/xiaohongshu/search-note/v2

根据关键词和可选筛选条件搜索小红书笔记,返回分页结果集。 每个结果通常包含笔记基本信息(如笔记ID、标题/文本片段、封面/媒体信息)、作者信号(如可用)以及互动数据(如可用)。

典型应用场景:

  • 主题/关键词研究与趋势分析
  • 发现用于监控、分析和数据集构建的笔记
  • 营销活动与竞品内容发现

请求参数

参数名位置类型必填说明
tokenquerystring此 API 服务的访问令牌。
keywordquerystring搜索关键词。
pagequeryinteger用于分页的页码。
sortquerystring结果集的排序方式。

可选值:
- general:综合排序
- popularity_descending:热度降序
- time_descending:时间降序
- comment_descending:评论数降序
- collect_descending:收藏数降序
noteTypequerystring笔记类型过滤器。

可用值:
- _0: 通用
- _1: 视频
- _2: 普通
noteTimequerystring按发布时间筛选。

可用值:
- 一天内: Within one day
- 一周内: Within a week
- 半年内: Within half a year

代码示例

💡 环境说明

默认示例使用 https://api.justoneapi.com (prod-global)。中国大陆地区建议替换为 http://47.117.133.51:30015 (prod-cn) 以获得更好的访问体验。详见 环境选择

bash
# 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
curl -X GET "https://api.justoneapi.com/api/xiaohongshu/search-note/v2?token=YOUR_API_KEY&keyword=VALUE"
text
我想使用 Just One API 提供的“笔记搜索 (V2)”接口。
接口地址: https://api.justoneapi.com/api/xiaohongshu/search-note/v2
HTTP 方法: GET
身份验证: 在 URL 后添加查询参数“?token=您的API密钥”。
OpenAPI 定义: https://docs.justoneapi.com/openapi/xiaohongshu-apis/note-search-v2-zh.json

请求参数说明:
- token (query): 此 API 服务的访问令牌。 (必填)
- keyword (query): 搜索关键词。 (必填)
- page (query): 用于分页的页码。
- sort (query): 结果集的排序方式。

可选值:
- `general`:综合排序
- `popularity_descending`:热度降序
- `time_descending`:时间降序
- `comment_descending`:评论数降序
- `collect_descending`:收藏数降序
- noteType (query): 笔记类型过滤器。

可用值:
- `_0`: 通用
- `_1`: 视频
- `_2`: 普通
- noteTime (query): 按发布时间筛选。

可用值:
- `一天内`: Within one day
- `一周内`: Within a week
- `半年内`: Within half a year

返回格式: JSON

响应处理与错误码:
1. 需通过返回体中的 "code" 字段判断业务结果(code 为 0 表示成功)。
2. 超时建议:建议将请求超时时间设置为至少 60 秒。
3. 业务码说明:
   - 0: 成功
   - 100: Token 无效或已失效
   - 301: 采集失败,请重试
   - 302: 超出速率限制
   - 303: 超出每日配额
   - 400: 参数错误
   - 500: 内部服务器错误
   - 600: 权限不足
   - 601: 余额不足

请帮我用我擅长的编程语言写一个脚本来调用这个接口,并处理返回结果。
python
# 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
import requests

url = "https://api.justoneapi.com/api/xiaohongshu/search-note/v2?token=YOUR_API_KEY&keyword=VALUE"
response = requests.get(url)
print(response.json())
js
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
const response = await fetch("https://api.justoneapi.com/api/xiaohongshu/search-note/v2?token=YOUR_API_KEY&keyword=VALUE", {
  method: "GET"
});
const data = await response.json();
console.log(data);
java
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.justoneapi.com/api/xiaohongshu/search-note/v2?token=YOUR_API_KEY&keyword=VALUE"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
go
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	client := &http.Client{}
	url := "https://api.justoneapi.com/api/xiaohongshu/search-note/v2?token=YOUR_API_KEY&keyword=VALUE"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
php
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.justoneapi.com/api/xiaohongshu/search-note/v2?token=YOUR_API_KEY&keyword=VALUE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
curl_close($ch);
echo $response;

响应结果

json
{
  "code": 0,
  "data": {
    "items": [
      {
        "model_type": "note",
        "note": {
          "extract_text_enabled": 0,
          "nice_count": 0,
          "update_time": 1772963261000,
          "xsec_token": "YBtw6gvZIq7-ULy_Lt2R72ZheGwXy_ackAgZ_tUQf29go=",
          "interaction_area": {
            "text": "15",
            "type": 1,
            "status": false
          },
          "result_from": "",
          "type": "normal",
          "last_update_time": 0,
          "geo_info": {
            "distance": ""
          },
          "niced": false,
          "liked_count": 15,
          "corner_tag_info": [
            {
              "location": -1,
              "type": "ubt_sig_token",
              "icon": "",
              "text": "RAEKW4jTGbEtq0o0SM0BLG9Bqwn5t0uW/U5en9Ay3eOLTeRj09CE7PPMHORYNYaqNzAHnF908P1/UXS1oKWOz0EDuSfTJgash8",
              "text_en": "",
              "style": 0
            }
          ],
          "collected": false,
          "collected_count": 9,
          "timestamp": 1772861202,
          "user": {
            "followed": false,
            "red_official_verify_type": 0,
            "track_duration": 0,
            "show_red_official_verify_icon": false,
            "red_official_verified": false,
            "userid": "6276a4d10000000021026c1f",
            "red_id": "1527435277",
            "nickname": "郑州卖海信电视容声冰箱团购处",
            "images": "https://sns-avatar-qc.xhscdn.com/avatar/1040g2jo31gf10nru3s0g5ojmkj8ocr0v47fj5ro?imageView2/2/w/80/f..."
          },
          "has_music": false,
          "desc": "#海信洗衣机 这是海信全家筒·棉花糖U7S,一款全球首创的6合1热泵洗护站,主打“衣鞋同净、分区健康洗护”。 核心亮点",
          "tag_info": {
            "title": "",
            "type": ""
          },
          "cover_image_index": 0,
          "advanced_widgets_groups": {
            "groups": [
              {
                "mode": 1,
                "fetch_types": [
                  "guos_test"
                ]
              }
            ]
          },
          "id": "69abb712000000001600a32a",
          "images_list": [
            {
              "need_load_original_image": false,
              "fileid": "notes_uhdr/1040g3qg31tdcat495m005ojmkj8ocr0v9fjbf2g",
              "height": 5712,
              "width": 4284,
              "url": "https://sns-na-i8-a.xhscdn.com/notes_uhdr/1040g3qg31tdcat495m005ojmkj8ocr0v9fjbf2g?imageView2/2/w/60...",
              "url_size_large": "https://sns-na-i8-a.xhscdn.com/notes_uhdr/1040g3qg31tdcat495m005ojmkj8ocr0v9fjbf2g?imageView2/2/w/14...",
              "original": "",
              "trace_id": "notes_uhdr/1040g3qg31tdcat495m005ojmkj8ocr0v9fjbf2g"
            }
          ],
          "debug_info_str": "",
          "widgets_context": "{\"flags\":{},\"author_id\":\"6276a4d10000000021026c1f\",\"author_name\":\"郑州卖海信电视容声冰箱团购处\"}",
          "liked": false,
          "shared_count": 14,
          "comments_count": 25,
          "note_attributes": []
        }
      }
    ],
    "query_type": 0,
    "query_intent": {
      "goodsIntent": 3,
      "search_ask_intent": true,
      "low_supply_intent": false
    },
    "service_status": "{\"filter\":\"not_required\",\"note\":\"success\",\"onebox\":\"not_required\",\"cost\":{\"all\":700,\"zone\":\"rcsh1\"}}",
    "strategy_info": {
      "query_can_guide_to_feed": true,
      "query_average_impression_count": 19
    },
    "dqa_authorized_user_by_shared": false,
    "show_single_col": false,
    "search_request_id": "ff0597830871a638",
    "ai_mode_enable": false,
    "cur_cut_number": 0,
    "query_debug_info": {
      "is_forbidden": false
    },
    "is_broad_query": true,
    "search_pull_down_opt_exp": 1,
    "request_dqa_instant": true,
    "search_dqa_new_page_exp": 1,
    "dqa_instant_sid": "mGb86N4g1J",
    "can_cut": false,
    "request_dqa": 0
  }
}

💡 提示:为简化展示,列表类数据样例仅保留 1-2 条记录,实际返回条数以接口响应为准。