首页 > 大数据 > 数据分析 > 小红书获取笔记详情API接口运用指南
red.note.detail.get或
v1/notes/{note_id})。App Key、
App Secret及
access_token(有效期通常2小时,需通过OAuth2.0刷新)。https://api.xiaohongshu.com/note/detail?note_id={note_id}&access_token={access_token}https://api.xiaohongshu.com/v1/notes/{note_id}(需替换
{note_id}为实际笔记ID)。| 参数 | 说明 |
|---|---|
note_id |
笔记唯一ID(可从笔记URL或分享链接中提取) |
access_token |
通过认证获取的令牌(需通过OAuth2.0授权流程) |
app_key |
应用的唯一标识 |
fields |
指定返回字段(如
title,content,like_count),减少数据量 |
timestamp |
当前时间戳(防重放攻击) |
sign |
签名(按小红书规则生成,验证请求合法性) |
pythonimport requestsimport jsondef get_note_detail(app_key, access_token, note_id): url = f"https://api.xiaohongshu.com/note/detail?note_id={note_id}&access_token={access_token}" headers = {"Accept-Encoding": "gzip", "Connection": "close"} response = requests.get(url, headers=headers) if response.status_code == 200: return response.json() else: print(f"请求失败, 状态码: {response.status_code}") return None# 替换为实际值app_key = "YOUR_APP_KEY"access_token = "YOUR_ACCESS_TOKEN" # 需通过授权流程获取note_id = "123456789" # 示例笔记IDresult = get_note_detail(app_key, access_token, note_id)if result: print(json.dumps(result, indent=2, ensure_ascii=False))
json{ "note_id": "123456789", "title": "示例笔记标题", "content": "这里是笔记正文内容...", "tags": ["标签1", "标签2"], "like_count": 100, "comment_count": 20, "author": { "user_id": "987654321", "nickname": "作者昵称", "avatar_url": "https://example.com/avatar.jpg" }, "media": [ {"type": "image", "url": "https://example.com/image1.jpg"}, {"type": "video", "url": "https://example.com/video1.mp4"} ]}requests.exceptions.RequestException)。access_token有效期,使用OAuth2.0刷新令牌避免过期。App Key和
App Secret,禁止泄露或硬编码在前端。通过以上流程,可合法、高效地获取小红书笔记详情数据,支撑内容分析、用户行为研究等场景。如遇权限申请被拒,需检查申请信息完整性(如应用场景描述),补充材料后重新提交。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70046834/viewspace-3099332/ ,如需转载,请注明出处,否则将追究法律责任。