Tur:Scratch API (2.0)

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. It can be used to return various types of data regarding the Scratch website. This API can be accessed via the following URL.

GET /
The root of the api-staging interface provides basic information regarding the API and the Scratch website.

Example Request

Example Response

GET /health
Used to return the status of the Scatch website.

Example Request

Example Response

GET /news
Returns information regarding the "Scratch News" section of the homepage.

Example Request

Example Response

GET /projects/count/all
Returns the total number of shared projects on the Scratch website.

Example Request

Example Response

GET /proxy/featured
Returns information regarding the projects currently visible on the front page of the website.

Example Request

Example Response

 {   "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//featured
Returns information regarding the "What's Happening?" section of the homepage for a given user.

Example Request

Example Response

 {     "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/ /activity
Returns information regarding the "What I've been doing" section of a given user's profile.

Example Request

Example Response

 [     {          "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  I'm A Cat AMV", "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   I'm A Cat AMV", "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 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   juanneco</a>", "extra_data":{ "followee_username":"juanneco" },       "type":0 },   ... ]

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/proxy/users/ /activity/count
This returns the number of unread messages a user currently has.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/
Returns information about the specified user.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/ /favorites
Returns an array of details regarding the projects that a given user has favourited on the website.

Example Request

Example Response

<pre style="white-space:pre-wrap;"> [   {        "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 <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/ /followers
Returns a list of a user's most recent followers.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/ /following
Returns a list of the users that the specified user has most recently followed.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/ /messages/count
This returns the number of unread messages a user currently has.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/ /projects
Returns an array with information regarding the projects that a given user has shared on the Scratch website.

Example Request

Example Response

<pre style="white-space:pre-wrap;"> [   {        "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 <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/ /projects/<project_id>
Returns information relevant to the given project.

Example Request

Example Response

= 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. 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.

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/comments/gallery/<studio_id>/
Returns the comments on a studio in the form of raw HTML.

Example Request

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/comments/project/<project_id>/
Returns the comments on a project in the form of raw HTML.

Example Request

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/comments/user/ /
Returns the comments on a given user's profile in the form of raw HTML.

Example Request

PUT <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/followers/ /add/
Follows a user.

Example Request

PUT <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/lovers/<project_id>/add/
Loves a project.

Example Request

PUT <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/users/favoriters/<project_id>/add/
Example Request

Request Headers
These are the request headers which may be filled out.

= 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.

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/<project_id>
Returns information regarding the cloud data of a given project.

Example Request

Example Response

= 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.

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/
The root of the API v1 interface provides basic information regarding the API.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/project/<project_id>/
Returns information regarding a project and its author.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/project/set/<project_ids>/
Returns information regarding a set of projects and their authors. Project IDs are separated with a semicolon.

Example Request

Example Response

<pre style="white-space:pre-wrap;"> {     "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" }   ] }

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/user/ /
Returns information regarding the given user.

Example Request

Example Response

GET <span style="background-color:rgba(0,0,0,0.04);padding:2px;font-family:monospace;">/user/set/ /
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

Example Response

= References =

= External Links =


 * Scratch REST API Wiki on GitHub
 * Unofficial Scratch API Documentation on GitHub
 * Scratch 2.0 Alpha API Documentation
 * Scratch API Implementation in Python on GitHub
 * Scratch API Implementation in Node.js on GitHub