豆瓣 API 参考手册

收藏

获取收藏信息

通过API授权后,可以获得授权用户自己的私人收藏

GET http://api.douban.com/collection/{collectionID}
    

例如

GET http://api.douban.com/collection/2154164

返回格式

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005"
xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/"
xmlns:db="http://www.douban.com/xmlns/">
<author>
    <link rel="self" href="http://api.douban.com/people/sakinijino" />
    <link rel="alternate"
        href="http://www.douban.com/people/sakinijino/" />
    <link rel="icon" href="http://www.douban.com/icon/u1107186.jpg" />
    <uri>http://api.douban.com/people/1107186</uri>
    <name>霏昀</name>
</author>
<title>霏昀 看过 Sleepy Hollow</title>
<updated>2006-03-29T10:35:50+08:00</updated>
<db:tag name="TimBurton" />
<db:tag name="美国" />
<db:tag name="JohnnyDepp" />
<db:tag name="惊悚" />
<db:subject>
    <category scheme="http://www.douban.com/2007#kind"
        term="http://www.douban.com/2007#movie" />
    <author>
        <name>蒂姆 伯顿 (Tim Burton)</name>
    </author>
    <title>Sleepy Hollow</title>
    <summary>
        十八世纪末期的纽约,警察们还延用古老的办案方式,对罪犯刑讯逼供,年青的警察伊卡布·克瑞恩(约翰尼·戴普
        饰)笃信科学的办案方式,因此受到市内同行的排挤,被派到一 ...
    </summary>
    <link rel="self"
        href="http://api.douban.com/movie/subject/1296078" />
    <link rel="alternate"
        href="http://movie.douban.com/subject/1296078/" />
    <link rel="image"
        href="http://t.douban.com/spic/s1890860.jpg" />
    <db:attribute name="country">德国</db:attribute>
    <db:attribute name="country">美国</db:attribute>
    <db:attribute name="pubdate">1999</db:attribute>
    <db:attribute name="cast">Johnny Depp</db:attribute>
    <db:attribute name="cast">Christina Ricci</db:attribute>
    <db:attribute name="language">English</db:attribute>
    <db:attribute name="language">Latin</db:attribute>
    <db:attribute name="imdb">
         http://www.imdb.com/title/tt0162661/
    </db:attribute>
    <db:attribute lang="zh_CN" name="aka">断头谷</db:attribute>
    <id>http://api.douban.com/movie/subject/1296078</id>
</db:subject>
<db:status>watched</db:status>
<id>http://api.douban.com/collection/2154164</id>
<gd:rating min="1" value="4" max="5" />
</entry>
    

获取用户收藏信息

通过API授权后,可以获得授权用户自己的私人收藏(注:电影收藏只能获取前十条)

GET http://api.douban.com/people/{userID}/collection?cat=book
GET http://api.douban.com/people/{userID}/collection?cat=movie
GET http://api.douban.com/people/{userID}/collection?cat=music
    

请求参数

参数 意义 备注
tag 搜索特定tag的收藏
status 搜索特定状态的收藏 book:wish, reading, read
movie:wish, watched
tv:wish, watching, watched
music:wish, listening, listened
start-index 起始元素
max-results 返回结果的数量
updated-max 收藏的最晚时间 格式: 2007-12-28T21:47:00+08:00
updated-min 收藏的最早时间 格式: 2007-12-28T21:47:00+08:00

例如

GET http://api.douban.com/people/sakinijino/collection?cat=movie&start-index=1&max-results=2&tag=TimBurton

返回格式

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005"
xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/"
xmlns:db="http://www.douban.com/xmlns/">
<author>
    <link rel="self" href="http://api.douban.com/people/sakinijino" />
    <link rel="alternate"
        href="http://www.douban.com/people/sakinijino/" />
    <link rel="icon" href="http://www.douban.com/icon/u1107186.jpg" />
    <uri>http://api.douban.com/people/1107186</uri>
    <name>霏昀</name>
</author>
<opensearch:totalResults>1</opensearch:totalResults>
<title>霏昀 的收藏</title>
<opensearch:startIndex>1</opensearch:startIndex>
<entry>
    <updated>2006-03-29T10:35:50+08:00</updated>
    <db:tag name="TimBurton" />
    <db:tag name="美国" />
    <db:tag name="JohnnyDepp" />
    <db:tag name="惊悚" />
    <title>霏昀 看过 Sleepy Hollow</title>
    <db:subject>
        <category scheme="http://www.douban.com/2007#kind"
            term="http://www.douban.com/2007#movie" />
        <author>
            <name>蒂姆 伯顿 (Tim Burton)</name>
        </author>
        <title>Sleepy Hollow</title>
        <summary>
            十八世纪末期的纽约,警察们还延用古老的办案方式,对罪犯刑讯逼供,年青的警察伊卡布·克瑞恩(约翰尼·戴普
            饰)笃信科学的办案方式,因此受到市内同行的排挤,被派到一 ...
        </summary>
        <link rel="self"
            href="http://api.douban.com/movie/subject/1296078" />
        <link rel="alternate"
            href="http://movie.douban.com/subject/1296078/" />
        <link rel="image"
            href="http://t.douban.com/spic/s1890860.jpg" />
        <db:attribute name="country">德国</db:attribute>
        <db:attribute name="country">美国</db:attribute>
        <db:attribute name="pubdate">1999</db:attribute>
        <db:attribute name="cast">Johnny Depp</db:attribute>
        <db:attribute name="cast">Christina Ricci</db:attribute>
        <db:attribute name="language">English</db:attribute>
        <db:attribute name="language">Latin</db:attribute>
        <db:attribute name="imdb">
            http://www.imdb.com/title/tt0162661/
        </db:attribute>
        <db:attribute lang="zh_CN" name="aka">断头谷</db:attribute>
        <id>http://api.douban.com/movie/subject/1296078</id>
    </db:subject>
    <db:status>watched</db:status>
    <id>http://api.douban.com/collection/2154164</id>
    <gd:rating min="1" value="4" max="5" />
</entry>
<opensearch:itemsPerPage>2</opensearch:itemsPerPage>
</feed>
    

添加收藏

添加收藏必须先进行API认证授权,关于API认证授权的信息请参阅API 授权说明

通过添加<db:attribute name="privacy">private</db:attribute>元素来说明私人收藏

POST http://api.douban.com/collection

实例

POST http://api.douban.com/collection

请求为一个Entry

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/">
<db:status>watched</db:status>
<db:tag name="动画" />
<db:tag name="渡边信一郎" />
<db:tag name="日本" />
<gd:rating xmlns:gd="http://schemas.google.com/g/2005" value="5" />
<content>神作</content>
<db:subject>
<id>http://api.douban.com/movie/subject/1424406</id>
</db:subject>
<db:attribute name="privacy">private</db:attribute>
</entry>
                

成功返回

201 CREATED

更新收藏信息

更新收藏信息必须先进行API认证授权,关于API认证授权的信息请参阅API 授权说明

PUT http://api.douban.com/collection/{collectionID}

实例

PUT http://api.douban.com/collection/12345678

请求为一个Entry

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/">
<id>http://api.douban.com/collection/12345678</id>
<db:status>watched</db:status>
<db:tag name="动画" />
<db:tag name="渡边信一郎" />
<db:tag name="日本" />
<gd:rating xmlns:gd="http://schemas.google.com/g/2005" value="5" />
<content>神作</content>
<db:subject>
<id>http://api.douban.com/movie/subject/1424406</id>
</db:subject>
</entry>
                

成功返回

202 ACCEPTED

删除收藏

删除收藏必须先进行API认证授权,关于API认证授权的信息请参阅API 授权说明

DELETE http://api.douban.com/collection/{collectionID}

实例

DELETE http://api.douban.com/collection/12345678

成功返回

200 OK