@ranger-01
2019-06-16T00:46:33.000000Z
字数 2396
阅读 804
mimi_program
豆瓣图书API URL prefix: https://api.douban.com/v2/book/
URL: /:book_id?apikey=0df993c66c0c636e29ecbb5344252a4a
method: GET
ret: {
...
}
返回结果直接参考:https://api.douban.com/v2/book/33411838?apikey=0df993c66c0c636e29ecbb5344252a4a
URL: /isbn/:book_id?apikey=0df993c66c0c636e29ecbb5344252a4a
method: GET
ret: {
...
}
返回结果直接参考:https://api.douban.com/v2/book/isbn/9787521204569?apikey=0df993c66c0c636e29ecbb5344252a4a
URL: /search/tag=<text>?apikey=0df993c66c0c636e29ecbb5344252a4a
or
URL: /search/q=<text>?apikey=0df993c66c0c636e29ecbb5344252a4a
method: GET
ret: {
...
}
返回结果直接参考:
https://library.pipiju.net/douban/v2/book/search?tag=%E7%BC%96%E7%A8%8B&apikey=0df993c66c0c636e29ecbb5344252a4a
https://library.pipiju.net/douban/v2/book/search?q=ai&apikey=0df993c66c0c636e29ecbb5344252a4a
# 进入小程序后,该微信用户需要向后台认证
url(r'^api/wxlogin/$', views.wx_login)
url(r'^api/v1/buy/$', views.buy),
url(r'^api/v1/wish/$', views.make_wish),
url(r'^api/v1/borrow_book/$', views.borrow_book),
url(r'^api/v1/return_book/$', views.return_book),
# 获取图书馆中已经购买的图书
url(r'^api/v1/books/$', views.get_book_list),
# 获取心愿单中的图书
url(r'^api/v1/wish/books/$', views.get_wish_book_list),
# 由于豆瓣API有调用次数限制,后台缓存了图书详情
url(r'^api/v1/books/(?P<pk>[0-9]+)/$', views.get_book_info)
# login from mini program
URL: /api/v1/wxlogin/
method: POST
Data:
{
'code': 'xxxxxxx',
'userinfo': {
{
"nickName": "NICKNAME",
"gender": GENDER,
"city": "CITY",
"province": "PROVINCE",
"country": "COUNTRY",
"avatarUrl": "AVATARURL",
}
}
ret:
{
"token": token.token,
"token_type": "Bearer",
"user_type": pu.type,
"user_id": u.id
}
# operation on a book
URL: /api/v1/book/
operation: 'wish, buy, borrow, return',
method: POST
Data:
{
'book_id': '123'
}
ret:
{
'book_info': book_info,
'status': book.status,
'owner': book_owner,
'wishers': book.wishers.all().values(
'id', 'pyuser__nickname', 'pyuser__avatarUrl'
)
}
# get book list info
URL: /api/v1/books/
method: GET
type: 'wish, all',
ret:
{
data: [
{
'book_info': str_book_info,
'status': book.status,
'owner': {
'id': book.owner.id,
'nickname': book.owner.pyuser.nickname,
'avatarUrl': book.owner.pyuser.avatarUrl
},
'wishers': book.wishers.all().values(
'id', 'pyuser__nickname', 'pyuser__avatarUrl'
)
},
]
}