From Test-Scratch-Wiki

Translate: - English - Türkçe 

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

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

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

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

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

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

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":"" } ] }

References

  1. https://scratch.mit.edu/discuss/post/1552554/
  2. https://scratch.mit.edu/discuss/post/1552554/

External Links