From Test-Scratch-Wiki
The Scratch API is an interface which provides access to various instances of data in a mostly programmer-friendly manner. It can be used in many different ways in order to create applications which can send and extract data from the Scratch Website.
api-staging Interface
The api-staging interface is the latest revision of the Scratch API.[1] It can be used to return various types of data regarding the Scratch website. This API can be accessed via the following URL.
https://api-staging.scratch.mit.edu
GET /
The root of the api-staging interface provides basic information regarding the API and the Scratch website.
Example Request
GET https://api-staging.scratch.mit.edu
Example Response
{
"website":"scratch.mit.edu",
"api":"api.scratch.mit.edu",
"help":"help@scratch.mit.edu"
}
Health
GET /health
Used to return the status of the Scatch website.
Example Request
GET https://api-staging.scratch.mit.edu/health
Example Response
{
"version":"2d7d8b5e9c7a72cfe15a97ebcc5818ec7380374c",
"uptime":11791451,
"load":[
0.0283203125,
0.03515625,
0.04541015625
],
"sql":{
"ssl":true,
"started":"2016-03-03T20:54:19.798Z",
"min":0,
"max":20
}
}
News
GET /news
Returns information regarding the "Scratch News" section of the homepage.
Example Request
GET https://api-staging.scratch.mit.edu/news
Example Response
[
{
"id":140458468423,
"stamp":"2016-03-04T19:08:01.000Z",
"headline":"Scratch Video Update Ep. 14",
"url":"https://scratch.mit.edu/discuss/topic/186558/",
"image":"https://40.media.tumblr.com/b563e9425dfca8ac53396d997db312ba/tumblr_inline_nwua1f4Chy1szpavb_540.png",
"copy":"Want to know what's happening on Scratch? Check out the latest video update!"
},
{
"id":140391071468,
"stamp":"2016-03-03T15:13:27.000Z",
"headline":"New Community Blog Post!",
"url":"https://scratch.mit.edu/discuss/topic/186359/",
"image":"https://36.media.tumblr.com/b8e8bc37f38a135a0f873a6fe7788701/tumblr_inline_nwuak8hOun1szpavb_540.png",
"copy":"6 Dance Parties on Scratch To Join Right Now!"
},
...
]
Projects
GET /projects/count/all
Returns the total number of shared projects on the Scratch website.
Example Request
GET https://api-staging.scratch.mit.edu/projects/count/all
Example Response
{
"count":13561186
}
Proxy
GET /proxy/featured
Returns information regarding the projects currently visible on the front page of the website.
Example Request
GET https://api-staging.scratch.mit.edu/proxy/featured
Example Response
Extended content |
---|
{ "community_newest_projects":[ { "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/10157/8493.png", "title":"Take To The Sky- CC ~OPEN~ remix", "creator":"Sapphire19", "type":"project", "id":101578493, "love_count":0 }, { "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/10157/8191.png", "title":"Untitled", "creator":"Sally_Williams-", "type":"project", "id":101578191, "love_count":0 }, ... ], "community_most_remixed_projects":[ { "title":"Oreo!!!", "type":"project", "remixers_count":429, "love_count":11395, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/2625/7525.png", "creator":"FunnyAnimatorJimTV", "id":26257525 }, ... ], "scratch_design_studio":[ { "gallery_id":1859165, "creator":"NaturalmotionStudios", "remixers_count":0, "gallery_title":"Remix-A-Thon", "love_count":8, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/9805/1641.png", "title":"My Dream House - SDS", "type":"project", "id":98051641 }, ... ], "curator_top_projects":[ { "title":"Colour Dash! ", "creator":"enderbrick", "love_count":30, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/9647/1680.png", "curator_name":"Cirrus-", "type":"project", "id":96471680 }, ... ], "community_featured_studios":[ { "thumbnail_url":"//cdn.scratch.mit.edu/static/site/galleries/thumbnails/139/9754.png", "type":"gallery", "id":1399754, "title":"Robots, Androids, and Artificial Intelligence" }, ... ], "community_most_loved_projects":[ { "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/10022/2418.png", "title":"Instrument Sprites", "creator":"ceebee", "type":"project", "id":100222418, "love_count":104 }, ... ], "community_featured_projects":[ { "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/9486/8644.png", "title":"Cavern | Platformer", "creator":"Influenzi", "type":"project", "id":94868644, "love_count":334 }, ... ] } |
GET /proxy/users/<user_id>/featured
Returns information regarding the "What's Happening?" section of the homepage for a given user.
Example Request
GET https://api-staging.scratch.mit.edu/proxy/users/167/featured
Example Response
Extended content |
---|
{ "custom_projects_by_following":[ { "title":"Justify", "type":"project", "remixers_count":"0", "love_count":"17", "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/10012/2918.png", "creator":"NickyNouse", "id":"100122918" }, { "title":"Cosmic Narwhal ", "type":"project", "remixers_count":"0", "love_count":"10", "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/10090/1960.png", "creator":"petrichord", "id":"100901960" }, ... ], "custom_projects_in_studios_following":[ { "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/10098/9479.png", "title":"Life", "creator":"Shoujo-ai", "type":"project", "id":"100989479", "love_count":"22" }, ... ], "custom_projects_loved_by_following":[ { "creator":"Meap77", "remixers_count":"32", "love_count":"1099", "thumbnail_url":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/9530/1826.png", "title":"Can You Remember? (the game)", "type":"project", "id":"95301826" }, ... ] } |
GET /proxy/users/<username>/activity
Returns information regarding the "What I've been doing" section of a given user's profile.
Example Request
GET https://api-staging.scratch.mit.edu/proxy/users/mres/activity
Example Response
Extended content |
---|
[ { "obj_id":100736613, "datetime_created":"2016-03-14T12:09:49", "actor":{ "username":"ceebee", "pk":2755634, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/users/avatars/275/5634.png", "admin":true }, "pk":227790976, "message":"\nfavorited\n <a href=\"/projects/100736613/\">I'm A Cat AMV</a>", "extra_data":{ "project_title":"I'm A Cat AMV" }, "type":3 }, { "obj_id":100736613, "datetime_created":"2016-03-14T12:09:49", "actor":{ "username":"ceebee", "pk":2755634, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/users/avatars/275/5634.png", "admin":true }, "pk":227790975, "message":"\nloved\n <a href=\"/projects/100736613/\">I'm A Cat AMV</a>", "extra_data":{ "project_title":"I'm A Cat AMV" }, "type":2 }, { "obj_id":101537695, "datetime_created":"2016-03-14T07:13:36", "actor":{ "username":"ericr", "pk":159, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/users/avatars/0/0159.png", "admin":false }, "pk":227767012, "message":"\nshared the project \n <a href=\"/projects/101537695/\" data-tag=\"object\">a little band</a>", "extra_data":{ "project_title":"a little band" }, "type":10 }, { "obj_id":13182467, "datetime_created":"2016-03-14T04:33:18", "actor":{ "username":"ericr", "pk":159, "thumbnail_url":"//cdn.scratch.mit.edu/static/site/users/avatars/0/0159.png", "admin":false }, "pk":227757062, "message":"\nis now following\n <a href=\"/users/juanneco/\">juanneco</a>", "extra_data":{ "followee_username":"juanneco" }, "type":0 }, ... ] |
GET /proxy/users/<username>/activity/count
This returns the number of unread messages a user currently has.
Example Request
GET https://api-staging.scratch.mit.edu/proxy/users/mres/activity/count
Example Response
{
"msg_count":12
}
Users
GET /users/<username>
Returns information about the specified user.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres
Example Response
{
"id":167,
"username":"mres",
"history":{
"joined":"2007-03-07T03:50:14.000Z"
},
"profile":{
"id":29,
"avatar":"0/0167.png",
"status":"I'm working on new technologies and activities to support the four P's of creative learning: Projects, Peers, Passion, and Play",
"bio":"I'm a professor at the MIT Media Lab. But more important: I'm a member of the Scratch Team! \n\nCheck out my TED talk about Scratch: http://bit.ly/mres-ted-talk",
"country":"United States"
}
}
GET /users/<username>/favorites
Returns an array of details regarding the projects that a given user has favourited on the website.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres/favorites
Example Response
Extended content |
---|
[ { "id":291, "title":"Collision detection example", "description":"My 10-year-old was asking how to have sprite detect when they collide. There are two parts to the answer.\r\rThe first part is to use the sensing block \"touching (other sprite)\", although you could also use \"distance to (other sprite)\"\r\rThe second part is when you want both sprites to detect the collision. The problem I encountered was that one sprite would detect the collision, turn and move away, before the other sprite sensed that they'd collided. This wouldn't be a problem in some circumstances, and I could have solved it by re-ordering when bouncing and moving happened, but instead I used the control block \"broadcast (message)\" to send a bounce message, then both sprites turn when they receive this message.\r\rA simple example that I hope helps someone.", "instructions":"", "history":{ "created":"2007-03-11T21:13:46.000Z", "modified":"2007-03-11T21:13:46.000Z", "shared":"2007-03-11T21:13:46.000Z" }, "stats":{ "views":8567, "loves":17, "favorites":10, "comments":24 } }, { "id":495, "title":"Digital Logic Toolkit", "description":"INSTRUCTIONS\rDrag out and connect your parts any way you want. Click the rotate button to turn parts.\r\rPARTS\rRed and blue power squares.\rLong wire and short wire with yellow inputs.\rAnd gate and Or gate with yellow inputs.\rTriangular inverter with yellow input.\r\rLEARN MORE\rhttp://jjackson.eng.ua.edu/courses/ece380/lectures/\r\rFUTURE DIRECTIONS\rWhat other toolkits could be built in Scratch?", "instructions":"", "history":{ "created":"2007-03-16T03:45:07.000Z", "modified":"2007-03-16T03:45:07.000Z", "shared":"2007-03-16T03:45:07.000Z" }, "stats":{ "views":739, "loves":32, "favorites":25, "comments":15 } }, ... ] |
GET /users/<username>/followers
Returns a list of a user's most recent followers.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres/followers
Example Response
[
{
"id":15833514,
"username":"Dylan_Test",
"history":{
"joined":"2016-03-15T12:27:56.000Z"
},
"profile":{
"id":15833514,
"avatar":"1583/3514.png",
"status":"",
"bio":"I just test things out here\nMy real account ",
"country":"Antarctica"
}
},
{
"id":4149226,
"username":"ILoveGerbils25",
"history":{
"joined":"2014-05-16T23:08:00.000Z"
},
"profile":{
"id":4149226,
"avatar":"414/9226.png",
"status":"I am back\nAT:closed \n\nf4f: sure <33\ncollabs:closed\n\nrequests: closed",
"bio":"Raven/She/13/\n\nHi I'm ILoveGerbils25 and I love Sonic, creepypasta, harry potter, pokemon, pusheen,and Splatoon.\nFlockmod:RavenFire66\nMood:Bouncing off the walls ",
"country":"United States"
}
},
...
]
GET /users/<username>/following
Returns a list of the users that the specified user has most recently followed.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres/following
Example Response
[
{
"id":1197797,
"username":"bubble103",
"history":{
"joined":"2012-02-16T06:26:12.000Z"
},
"profile":{
"id":1197797,
"avatar":"119/7797.png",
"status":"✩-- Colour Divide ep2 - 100%\n✩-- Collab with @Driftwood14\n\nMy evil clone >> @bubbIe103",
"bio":"Hi there! I'm a shy extrovert.\n------✩-★-✩------\nI love using programming to express myself and my ideas! Scratch is awesome!\n------✩-★-✩------\n",
"country":"South Africa"
}
},
{
"id":10707222,
"username":"-MarzBarz-",
"history":{
"joined":"2015-06-18T23:00:09.000Z"
},
"profile":{
"id":10707222,
"avatar":"1070/7222.png",
"status":"Right now I'm kind of experimenting with my art style so everything's gonna look weird for a while\n*sigh*",
"bio":"helloooooooo",
"country":"United States"
}
},
...
]
GET /users/<username>/messages/count
This returns the number of unread messages a user currently has.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres/messages/count
Example Response
{
"count":12
}
GET /users/<username>/projects
Returns an array with information regarding the projects that a given user has shared on the Scratch website.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres/projects
Example Response
Extended content |
---|
[ { "id":142, "title":"PlayWithYourFace", "description":"INSTRUCTIONS \r\nClick the Green Flag. Move the mouse over the photos to play with different image effects. Click the Green Flag again to restart. \r\n\r\nHOW I MADE THIS \r\nIn some photos (like the top middle), the mouse position controls the amount of the image effect. In other photos (like the bottom middle), the mouse position controls the rate of change in the image effect. The first case uses the SET EFFECT block; the second cases uses the CHANGE EFFECT block. \r\n\r\nMORE IDEAS\r\nIn these examples, one image effect is applied to each photo. You might want to apply two (or more) image effects to the same photo. For example, make the x-position control one effect and make the y-position control another effect.", "instructions":"", "history":{ "created":"2007-03-07T14:48:22.000Z", "modified":"2007-03-07T14:48:22.000Z", "shared":"2007-03-07T14:48:22.000Z" }, "stats":{ "views":669, "loves":19, "favorites":19, "comments":58 } }, { "id":864, "title":"OceanMusicBox", "description":"This project was inspired by Toshio Iwai, an innovative artist and software designer from Japan. \r\n\r\nINSTRUCTIONS \r\nClick the Green Flag to start. Move the starfish and urchins to change the tune. (You can also use the ones at the bottom of the screen.) Place starfish higher and lower on the screen to play different notes. Move urchins higher and lower on the screen to get different drum sounds. Try changing the SPEED and INSTRUMENT sliders", "instructions":"", "history":{ "created":"2007-03-28T14:01:50.000Z", "modified":"2007-03-28T14:01:50.000Z", "shared":"2007-03-28T14:01:50.000Z" }, "stats":{ "views":239, "loves":21, "favorites":18, "comments":11 } }, ... ] |
GET /users/<username>/projects/<project_id>
Returns information relevant to the given project.
Example Request
GET https://api-staging.scratch.mit.edu/users/mres/projects/142
Example Response
{
"id":142,
"title":"PlayWithYourFace",
"description":"INSTRUCTIONS \r\nClick the Green Flag. Move the mouse over the photos to play with different image effects. Click the Green Flag again to restart. \r\n\r\nHOW I MADE THIS \r\nIn some photos (like the top middle), the mouse position controls the amount of the image effect. In other photos (like the bottom middle), the mouse position controls the rate of change in the image effect. The first case uses the SET EFFECT block; the second cases uses the CHANGE EFFECT block. \r\n\r\nMORE IDEAS\r\nIn these examples, one image effect is applied to each photo. You might want to apply two (or more) image effects to the same photo. For example, make the x-position control one effect and make the y-position control another effect.",
"instructions":"",
"history":{
"created":"2007-03-07T14:48:22.000Z",
"modified":"2007-03-07T14:48:22.000Z",
"shared":"2007-03-07T14:48:22.000Z"
},
"stats":{
"views":669,
"loves":19,
"favorites":19,
"comments":58
}
}
site-api Interface (Deprecated)
The site-api is a legacy interface which was officially deprecated on 25 October 2015, as announced by Scratch Team member, thisandagain.[2] Although the interface is deprecated, there are still a few features which remain to be useful. This API can be accessed via the following URL.
https://scratch.mit.edu/site-api/
Comments
GET /comments/gallery/<studio_id>/
Returns the comments on a studio in the form of raw HTML.
Example Request
GET https://scratch.mit.edu/site-api/comments/gallery/5342/
GET /comments/project/<project_id>/
Returns the comments on a project in the form of raw HTML.
Example Request
GET https://scratch.mit.edu/site-api/comments/project/142/
GET /comments/user/<username>/
Returns the comments on a given user's profile in the form of raw HTML.
Example Request
GET https://scratch.mit.edu/site-api/comments/user/mres/
Users
PUT /users/followers/<username>/add/
Follows a user.
Example Request
PUT https://scratch.mit.edu/site-api/users/followers/mres/add/
Projects
PUT /users/lovers/<project_id>/add/
Loves a project.
Example Request
PUT https://scratch.mit.edu/site-api/users/lovers/104/add/
PUT /users/favoriters/<project_id>/add/
Example Request
PUT https://scratch.mit.edu/site-api/users/favoriters/104/add/
Request Headers
These are the request headers which may be filled out.
Host:
User-Agent:
Accept:
Accept-Language:
Accept-Encoding:
Content-Type:
X-CSRFToken:
X-Requested-With:
Referer:
Content-Length:
Cookie:
Connection:
varserver Interface
The varserver API can be utilised to request the values of cloud variables in projects. This API can be accessed via the following URL.
https://scratch.mit.edu/varserver/
GET /<project_id>
Returns information regarding the cloud data of a given project.
Example Request
GET https://scratch.mit.edu/varserver/10080213
Example Response
{
"variables":[
{
"name":"☁ Scratch Cat",
"value":"2"
},
{
"name":"☁ Tera",
"value":"6"
},
{
"name":"☁ Gobo",
"value":"1"
}
],
"lists":[
]
}
api/v1 Interface (Deprecated)
The API v1 interface is a legacy interface which was originally built during the development of Scratch 2.0. It can be accessed via the following URL.
https://scratch.mit.edu/api/v1/
GET /
The root of the API v1 interface provides basic information regarding the API.
Example Request
GET https://scratch.mit.edu/api/v1/
Example Response
{
"project":{
"list_endpoint":"/api/v1/project/",
"schema":"/api/v1/project/schema/"
},
"projecttag":{
"list_endpoint":"/api/v1/projecttag/",
"schema":"/api/v1/projecttag/schema/"
},
"tag":{
"list_endpoint":"/api/v1/tag/",
"schema":"/api/v1/tag/schema/"
},
"user":{
"list_endpoint":"/api/v1/user/",
"schema":"/api/v1/user/schema/"
}
}
Projects
GET /project/<project_id>/
Returns information regarding a project and its author.
Example Request
GET https://scratch.mit.edu/api/v1/project/142/
Example Response
{
"creator":{
"username":"mres",
"userprofile":{
"bio":"I'm a professor at the MIT Media Lab. But more important: I'm a member of the Scratch Team! \n\nCheck out my TED talk about Scratch: http://bit.ly/mres-ted-talk",
"country":"United States",
"status":"I'm working on new technologies and activities to support the four P's of creative learning: Projects, Peers, Passion, and Play"
}
},
"datetime_shared":"2007-03-07T14:48:22",
"description":"INSTRUCTIONS \r\nClick the Green Flag. Move the mouse over the photos to play with different image effects. Click the Green Flag again to restart. \r\n\r\nHOW I MADE THIS \r\nIn some photos (like the top middle), the mouse position controls the amount of the image effect. In other photos (like the bottom middle), the mouse position controls the rate of change in the image effect. The first case uses the SET EFFECT block; the second cases uses the CHANGE EFFECT block. \r\n\r\nMORE IDEAS\r\nIn these examples, one image effect is applied to each photo. You might want to apply two (or more) image effects to the same photo. For example, make the x-position control one effect and make the y-position control another effect.",
"favorite_count":"19",
"id":142,
"love_count":"19",
"resource_uri":"/api/v1/project/142/",
"thumbnail":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/0/0142.png",
"title":"PlayWithYourFace",
"view_count":"669"
}
GET /project/set/<project_ids>/
Returns information regarding a set of projects and their authors. Project IDs are separated with a semicolon.
Example Request
GET https://scratch.mit.edu/api/v1/project/set/142;864/
Example Response
Extended content |
---|
{ "objects":[ { "creator":{ "username":"mres", "userprofile":{ "bio":"I'm a professor at the MIT Media Lab. But more important: I'm a member of the Scratch Team! \n\nCheck out my TED talk about Scratch: http://bit.ly/mres-ted-talk", "country":"United States", "status":"I'm working on new technologies and activities to support the four P's of creative learning: Projects, Peers, Passion, and Play" } }, "datetime_shared":"2007-03-07T14:48:22", "description":"INSTRUCTIONS \r\nClick the Green Flag. Move the mouse over the photos to play with different image effects. Click the Green Flag again to restart. \r\n\r\nHOW I MADE THIS \r\nIn some photos (like the top middle), the mouse position controls the amount of the image effect. In other photos (like the bottom middle), the mouse position controls the rate of change in the image effect. The first case uses the SET EFFECT block; the second cases uses the CHANGE EFFECT block. \r\n\r\nMORE IDEAS\r\nIn these examples, one image effect is applied to each photo. You might want to apply two (or more) image effects to the same photo. For example, make the x-position control one effect and make the y-position control another effect.", "favorite_count":"19", "id":142, "love_count":"19", "resource_uri":"/api/v1/project/142/", "thumbnail":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/0/0142.png", "title":"PlayWithYourFace", "view_count":"669" }, { "creator":{ "username":"mres", "userprofile":{ "bio":"I'm a professor at the MIT Media Lab. But more important: I'm a member of the Scratch Team! \n\nCheck out my TED talk about Scratch: http://bit.ly/mres-ted-talk", "country":"United States", "status":"I'm working on new technologies and activities to support the four P's of creative learning: Projects, Peers, Passion, and Play" } }, "datetime_shared":"2007-03-28T14:01:50", "description":"This project was inspired by Toshio Iwai, an innovative artist and software designer from Japan. \r\n\r\nINSTRUCTIONS \r\nClick the Green Flag to start. Move the starfish and urchins to change the tune. (You can also use the ones at the bottom of the screen.) Place starfish higher and lower on the screen to play different notes. Move urchins higher and lower on the screen to get different drum sounds. Try changing the SPEED and INSTRUMENT sliders", "favorite_count":"18", "id":864, "love_count":"21", "resource_uri":"/api/v1/project/864/", "thumbnail":"//cdn.scratch.mit.edu/static/site/projects/thumbnails/0/0864.png", "title":"OceanMusicBox", "view_count":"239" } ] } |
Users
GET /user/<username>/
Returns information regarding the given user.
Example Request
GET https://scratch.mit.edu/api/v1/user/mres/
Example Response
{
"username":"mres",
"userprofile":{
"bio":"I'm a professor at the MIT Media Lab. But more important: I'm a member of the Scratch Team! \n\nCheck out my TED talk about Scratch: http://bit.ly/mres-ted-talk",
"country":"United States",
"status":"I'm working on new technologies and activities to support the four P's of creative learning: Projects, Peers, Passion, and Play"
}
}
GET /user/set/<usernames>/
Returns information regarding the given users. Names should be separated with semicolons. The "userprofile" value for each user object is currently empty making this feature of the API effectively useless. One should note that the single user feature remains functional.
Example Request
GET https://scratch.mit.edu/api/v1/user/set/mres;Gaza101/
Example Response
{
"objects":[
{
"username":"mres",
"userprofile":""
},
{
"username":"Gaza101",
"userprofile":""
}
]
}