我们主要关心以下页面的API:
- 社区主页:
https://scratch.mit.edu/
- 发现页:
https://scratch.mit.edu/explore/projects/all
我们可以把这些API视为项目查询接口,查询社区用户已创建的项目(Projects), 这些接口的不同只是查询的条件不同。
社区主页
已登陆用户和未登录用户看到的社区主页,略有不同,我们分别分析。
未登录用户
GET https://api.scratch.mit.edu/proxy/featured
已登陆用户
GET https://api.scratch.mit.edu/proxy/featured
返回数据相同。
已登陆用户会请求更多的API:
新闻接口:
GET https://api.scratch.mit.edu/news?limit=3
返回:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
[
{
"id": 181868395058,
"stamp": "2019-01-09T13:53:40.000Z",
"headline": "Updates and Bug Fixes!",
"url": "https://scratch.mit.edu/discuss/topic/331439/",
"image": "https://66.media.tumblr.com/2bbe2bc9317585c1de96c91f56bb061b/tumblr_inline_pad1ik8d2k1tqsk9m_540.png",
"copy": "We have some updates and bug fixes for you! See here for more information…"
},
{
"id": 181645899223,
"stamp": "2019-01-02T14:49:48.000Z",
"headline": "Scratch 3.0 is here!",
"url": "https://scratch.mit.edu/discuss/topic/326861/",
"image": "https://66.media.tumblr.com/2bbe2bc9317585c1de96c91f56bb061b/tumblr_inline_pad1ik8d2k1tqsk9m_540.png",
"copy": "Scratch 3.0 has launched! See here for more information…"
},
{
"id": 181645869948,
"stamp": "2019-01-02T14:48:22.000Z",
"headline": "First Scratch Design Studio in 3.0",
"url": "https://scratch.mit.edu/studios/5801323/",
"image": "https://66.media.tumblr.com/ee9c9705a8c0334c07c6a32303ec0748/tumblr_inline_p7in9yfrIU1tqsk9m_540.png",
"copy": "Have you ever wondered what life might be like in the year 3000? Here is your chance to share your dreams and wishes for the future! "
}
]
|
关注者赞过的项目
GET https://api.scratch.mit.edu/users/wwj718/following/users/loves
返回:
关注的工作室的项目
GET https://api.scratch.mit.edu/users/wwj718/following/studios/projects
返回:
发现页
发现页可以用于发现项目
和工作室
。工作室(Studio)目前官方还没有迁移完,我们暂时不关心。(工作室非常接近知乎收藏夹
的概念)。
默认请求
GET https://api.scratch.mit.edu/explore/projects?limit=16&offset=0&language=zh-cn&mode=trending&q=*
默认情况下,选择了全部
、热门的
、简体中文
(页底),从url参数你可以看到这些。
最受欢迎的动画
GET https://api.scratch.mit.edu/explore/projects?limit=16&offset=0&language=zh-cn&mode=popular&q=animations
观察URL参数,我们便搞懂了发现页的API细节了。