豆瓣 API 使用参考
本文只记录豆瓣接口本身的调用方式,供后续重写项目时参考。
用户影视兴趣列表#
请求地址#
GET https://frodo.douban.com/api/v2/user/{userId}/interests{userId} 是豆瓣用户 ID。
可用 API Key 参考:
054022eaeae0b00e0fc068c0c0a2102aQuery 参数#
| 参数 | 示例 | 说明 |
|---|---|---|
type | movie | 兴趣类型。拉取影视记录时使用 movie |
status | done | 状态,可用 done、doing、mark |
start | 1 | 分页起点 |
count | 50 | 每页数量,建议最大使用 50 |
apiKey | your-api-key | 豆瓣 Frodo API key |
状态值#
| status | 含义 |
|---|---|
done | 看过 |
doing | 在看 |
mark | 想看 |
请求示例#
https://frodo.douban.com/api/v2/user/USER_ID/interests?type=movie&status=done&start=1&count=50&apiKey=API_KEY推荐请求头#
Host: frodo.douban.comUser-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001023) NetType/WIFI Language/zh_CNReferer: https://servicewechat.com/wx2f9b06c1de1ccfca/99/page-frame.htmlAccept: application/json, text/plain, */*Accept-Language: zh-CN,zh;q=0.9,en;q=0.8响应结构#
接口返回分页信息和兴趣列表。
interface DoubanInterestsResponse { count: number start: number total: number interests?: DoubanInterest[]}Interest 字段#
interface DoubanInterest { id: number | string status: 'done' | 'doing' | 'mark' comment?: string | null create_time?: string | null is_private?: boolean rating?: { value?: number | null } subject: DoubanSubject}常用字段说明:
| 字段 | 说明 |
|---|---|
id | 用户兴趣记录 ID |
status | 观看状态 |
comment | 用户短评 |
create_time | 创建/标记时间 |
is_private | 是否私密 |
rating.value | 用户评分,通常为 1-5 |
subject | 影视条目信息 |
Subject 字段#
interface DoubanSubject { id: string title: string year?: string | null type?: string | null subtype?: string | null genres?: string[] directors?: Array<{ name: string }> actors?: Array<{ name: string }> cover_url?: string | null url?: string | null pic?: { large?: string | null normal?: string | null } rating?: { value?: number | null count?: number | null } pubdate?: string[]}常用字段说明:
| 字段 | 说明 |
|---|---|
id | 豆瓣条目 ID |
title | 标题 |
year | 年份 |
type / subtype | 条目类型,例如 movie |
genres | 类型标签 |
directors[].name | 导演名 |
actors[].name | 演员名 |
cover_url | 封面图 |
pic.large / pic.normal | 备用封面图 |
url | 豆瓣网页地址 |
rating.value | 豆瓣平均分 |
rating.count | 评分人数 |
pubdate | 上映日期列表 |
分页#
响应中包含:
count: numberstart: numbertotal: number下一页可以这样计算:
const nextStart = start + countconst hasMore = nextStart <= total请求下一页时继续传:
start={nextStart}&count=50响应示例#
{ "count": 1, "start": 1, "total": 880, "interests": [ { "id": 4496137804, "comment": "", "create_time": "2026-01-28 19:51:19", "status": "done", "is_private": false, "rating": { "value": 4 }, "subject": { "id": "35712804", "title": "首尔之春", "year": "2023", "type": "movie", "subtype": "movie", "genres": ["剧情"], "directors": [{ "name": "金性洙" }], "actors": [{ "name": "黄政民" }, { "name": "郑雨盛" }], "cover_url": "https://img2.doubanio.com/view/photo/m_ratio_poster/public/p2905141611.jpg", "url": "https://movie.douban.com/subject/35712804/", "rating": { "value": 8.8, "count": 307074 }, "pubdate": ["2023-11-22(韩国)"] } } ]}简单 Fetch 示例#
async function fetchDoubanInterests(input: { apiKey: string userId: string status: 'done' | 'doing' | 'mark' start?: number count?: number}) { const url = new URL(`https://frodo.douban.com/api/v2/user/${input.userId}/interests`)
url.searchParams.set('type', 'movie') url.searchParams.set('status', input.status) url.searchParams.set('start', String(input.start ?? 1)) url.searchParams.set('count', String(Math.min(input.count ?? 50, 50))) url.searchParams.set('apiKey', input.apiKey)
const response = await fetch(url, { headers: { Host: 'frodo.douban.com', 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001023) NetType/WIFI Language/zh_CN', Referer: 'https://servicewechat.com/wx2f9b06c1de1ccfca/99/page-frame.html', Accept: 'application/json, text/plain, */*', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', }, })
if (!response.ok) { throw new Error(`Douban request failed: ${response.status}`) }
return response.json()}