@Senl
2018-01-25T13:29:01.000000Z
字数 6122
阅读 1885
需求
请求方法 GET
请求参数 无
请求实例 http://news-at.zhihu.com/api/4/news/latest
{date: "20170419",stories: [{title: "哭着吃过饭的人,是可以一起走下去的",ga_prefix: "041921",images: ["https://pic2.zhimg.com/v2-92d45bbb970f332a682edd43edfb8935.jpg"],multipic: true,type: 0,id: 9366416},......],top_stories: [{image: "https://pic2.zhimg.com/v2-63740b573f8ed42be05cb935944883a9.jpg",type: 0,id: 9354748,ga_prefix: "041915",title: "柜子一推变桌子、大床折叠能上墙的「变形家具」,真正用起来可能会累哭"},{image: "https://pic2.zhimg.com/v2-78421626cadc2959e3484ba8f04c4859.jpg",type: 0,id: 9367712,ga_prefix: "041907",title: "最早明天,中国首个货运飞船「天舟一号」就要发射"},......]}
stories: 今日的新闻
top_stories: 今日新闻热点
http://news-at.zhihu.com/api/4/news/id (id为对应新闻的id)
请求方法 GET
请求参数 id (新闻id)
请求实例 http://news-at.zhihu.com/api/4/news/9366416
新闻id为9366416的示例:
{ body: "<div class="main-wrap content-wrap"> <di ........ 省略 </div>",image_source: "《四重奏》",title: "哭着吃过饭的人,是可以一起走下去的",image: "https://pic3.zhimg.com/v2-76aced1dff64aee731544531eb98c5b6.jpg",share_url: "http://daily.zhihu.com/story/9366416",js: [ ],ga_prefix: "041921",section: {thumbnail: "https://pic2.zhimg.com/v2-92d45bbb970f332a682edd43edfb8935.jpg",id: 28,name: "放映机"},images: ["https://pic2.zhimg.com/v2-92d45bbb970f332a682edd43edfb8935.jpg"],type: 0,id: 9366416,css: ["http://news-at.zhihu.com/css/news_qa.auto.css?v=4b3e3"]}
在较为特殊的情况下,该新闻可能是直接引用自其他网站,此时返回的 JSON 数据缺少 body,image-source,image,js 属性。多出 theme_name,editor_name,theme_id 三个属性。type 由 0 变为 1。
这种情况下较难处理,不设要求。
请求方法 GET
请求参数 date (日期)
请求示例 http://news-at.zhihu.com/api/4/news/before/20170419 (获取的是18号的新闻)
获取2017年4月18日的新闻示例 :
{date: "20170418",stories: [{images: ["https://pic2.zhimg.com/v2-b747ef8bef08eaa541f7b473d0881371.jpg"],type: 0,id: 9367409,ga_prefix: "041822",title: "小事 · 老陈与小陈"},{images: ["https://pic4.zhimg.com/v2-804e863c8fcb42118410ad8eb4f77347.jpg"],type: 0,id: 9367059,ga_prefix: "041821",title: "这就是我心中最好的国产战争剧,没有之一"},]}
请求方法 GET
请求参数 无
请求实例 http://news-at.zhihu.com/api/4/themes
{limit: 1000,subscribed: [ ],others: [{color: 15007,thumbnail: "http://pic3.zhimg.com/0e71e90fd6be47630399d63c58beebfc.jpg",description: "了解自己和别人,了解彼此的欲望和局限。",id: 13,name: "日常心理学"},{color: 8307764,thumbnail: "http://pic4.zhimg.com/2c38a96e84b5cc8331a901920a87ea71.jpg",description: "内容由知乎用户推荐,海纳主题百万,趣味上天入地",id: 12,name: "用户推荐日报"},{color: 14483535,thumbnail: "http://pic3.zhimg.com/00eba01080138a5ac861d581a64ff9bd.jpg",description: "除了经典和新片,我们还关注技术和产业",id: 3,name: "电影日报"},...]}
http://news-at.zhihu.com/api/4/theme/id (新闻类型的id)
请求方法 GET
请求参数 id (新闻类型的id)
请求示例 http://news-at.zhihu.com/api/4/theme/3
例如上面电影日报的id为3, 所以获取电影日报新闻列表的url为
{stories: [{type: 0,id: 7483361,title: "更多电影内容,都在读读日报里"},{type: 0,id: 7400530,title: "哪些电影有浓厚的建筑人文意味?"},],description: "除了经典和新片,我们还关注技术和产业",background: "http://p1.zhimg.com/80/0b/800b79a4821a535de31b349ffdc9eabb.jpg",color: 14483535,name: "电影日报",image: "http://p1.zhimg.com/dd/f1/ddf10a04227ea50fd59746dbcd13c728.jpg",image_source: "",editors: [{url: "http://www.zhihu.com/people/deng-ruo-xu",bio: "好奇心日报",id: 82,avatar: "http://pic2.zhimg.com/d3b31fa32_m.jpg",name: "邓若虚"},{images: ["http://pic4.zhimg.com/e43e1f7d8dfce546c4e95e944bcfb6cb_t.jpg"]url: "http://www.zhihu.com/people/yu-ke-er",bio: "电影产业研究者",id: 40,avatar: "http://pic4.zhimg.com/9d9e1f217_m.jpg",name: "余柯儿"},]}
stories: 新闻列表
description: 该类型新闻的描述
image_source: 图片来源
editors 推荐该类型新闻的编辑
注意: 上面editors字段的不强制要求使用
建议: 关于类型新闻的设计, 可以参考知乎日报
额外信息包括: 评论数量, 点赞数量, 这部分不强制要求做, 适合作为进阶需求
请求方法 GET
请求参数 id (新闻id)
请求实例 http://news-at.zhihu.com/api/4/story-extra/9367409
获取新闻id为9367409的额外信息
{long_comments: 5,popularity: 1107,short_comments: 112,comments: 117}
http://news-at.zhihu.com/api/4/story/id/long-comments (新闻id)
请求方法 GET
请求参数 id (新闻id)
请求示例 http://news-at.zhihu.com/api/4/story/9367409/long-comments
获取新闻id为9367409的长评论:
{comments: [{author: "Accordion渣男小昭",content: "一个个嘲讽这篇文章和节选这篇文章的键盘能说点有用的话?或者干脆就闭嘴?一天到晚纯粹在发泄并说没有意义的话这是一种暴力ok?既然觉得有问题和差,提出来,具体是哪,怎么去改,而不是一边免费享受着别人的劳动成果一边满口喷粪",avatar: "http://pic2.zhimg.com/9aed18bc1820be5baa2548d07bdf9d6d_im.jpg",time: 1492577911,id: 28749191,likes: 3,reply_to:{content:"第二个机灵抖的还是有逻辑问题,不该说忘了,应该说没喝过啊我也不知道",status:0,id:27275308,author:"2233155495"},},....]}
http://news-at.zhihu.com/api/4/story/id/short-comments (新闻id)
请求方法 GET
请求参数 id (新闻id)
请求示例 http://news-at.zhihu.com/api/4/story/9367409/short-comments
获取新闻id为9367409的短评论
{comments: [{author: "Accordion渣男小昭",content: "好好说话的好言相劝,一个月前的日报就看到这种吐槽的喷子了,天天看怪恶心的,忍不了",avatar: "http://pic2.zhimg.com/9aed18bc1820be5baa2548d07bdf9d6d_im.jpg",time: 1492613095,reply_to: {content: "说话这么冲,小心伤肝",status: 0,id: 28750394,author: "项靠谱"},id: 28754459,likes: 0},{author: "茶色蔓延",content: "只有我一个人看出基腐的味道来嘛…",avatar: "http://pic1.zhimg.com/a512f02200239b4f456349119a4b10dc_im.jpg",time: 1492606359,id: 28753381,likes: 0},...]}