This article or section documents the current version of Scratch (version 3.0). For this article in Scratch 1.4, see Scratch API (1.4).


An example of the Scratch API.

The Scratch API is an application programming interface which provides access to data stored by Scratch in a developer-friendly format. It can be used in many different ways in order to create applications which can send and extract data to and from the Scratch Website. The address of the current Scratch API is https://api.scratch.mit.edu.


Note Warning: Use the API responsibly and in keeping with the Terms of Use. Abuse of the API may result in a ban.[1]

api.scratch.mit.edu Interface

The api.scratch.mit.edu 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.

https://api.scratch.mit.edu

All endpoints that return an array accept query parameters named limit and offset, except /studios/<studio_id>/activity which only supports limit. limit is the maximum number of items in the response (up to 40). offset is the zero-based index of the first item in the response. For example, /users/mres/projects/142/comments?limit=3&offset=10 returns the 11th, 12th and 13th comment. The default limit is 20 and the default offset is 0.

Some endpoints need an authentication token, which can be specified as a query parameter or header named x-token. The token can be obtained by making a GET request to https://scratch.mit.edu/session/ with the scratchsessionsid cookie set.

Requests with methods other than GET also need a header named X-CSRFToken, which must have the same value as the scratchcsrftoken cookie.

GET /

The root of the api interface provides basic information regarding the API and the Scratch website.


Example Request
GET https://api.scratch.mit.edu
Example Response


Accounts

POST /accounts/checkpassword

Checks if a password is valid. The "msg" property of the response object is "valid password" or "invalid password".


Example Request
GET https://api.scratch.mit.edu/accounts/checkpassword

{
    "password": "..."
}
Example Response


GET /accounts/checkusername/<username>

Checks if a username can be registered. The "msg" property of the response object is "valid username" if it is available, "invalid username" if it is too short, too long or contains invalid characters, "username exists" if it is taken and "bad username" if it is inappropriate.


Example Request
GET https://api.scratch.mit.edu/accounts/checkusername/mres
Example Response


Explore

GET /explore/projects?q=<query>&mode=<mode>&language=<language_code>

Returns an array of projects displayed on the Projects tab of the Explore page. The query (q parameter) specifies which keywords to search for. It can be set to * or omitted to get all projects. The mode can be popular (default) or trending. A language code can be specified to prefer results in a certain language.


Example Request
GET https://api.scratch.mit.edu/explore/projects?q=games&mode=trending&language=en
Example Response


GET /explore/studios?q=<query>&mode=<mode>&language=<language_code>

Returns an array of studios displayed on the Studios tab of the Explore page. The query (q parameter) specifies which keywords to search for. It can be set to * or omitted to get all studios. The mode can be popular (default) or trending. A language code can be specified to prefer results in a certain language.


Example Request
GET https://api.scratch.mit.edu/explore/studios?q=animations&mode=trending&language=en
Example Response


Health

GET /health

Used to return the status of the Scratch website.


Example Request
GET https://api.scratch.mit.edu/health
Example Response


News

GET /news

Returns information regarding the "Scratch News" section of the homepage.


Example Request
GET https://api.scratch.mit.edu/news
Example Response


Projects

GET /projects/count/all

Returns the total number of shared projects on the Scratch website.


Example Request
GET https://api.scratch.mit.edu/projects/count/all
Example Response


GET /projects/<project_id>

Returns information about the project. The response is the same as /users/<username>/projects/<project_id> except that it includes the author's username.


Example Request
GET https://api.scratch.mit.edu/projects/142
Example Response


PUT /projects/<project_id>

Changes the name, Instructions, or Notes and Credits of a project. Returns the updated project information. Requires authentication.


Example Request
PUT https://api.scratch.mit.edu/projects/737565268

{
    "title": "New title",
    "instructions": "New instructions",
    "description": "New Notes and Credits"
}
Example Response


GET /projects/<project_id>/favorites/user/<username>

Checks if the project has been favorited by the user. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/projects/142/favorites/user/Maximouse
Example Response


GET /projects/<project_id>/loves/user/<username>

Checks if the project has been loved by the user. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/projects/142/loves/user/Maximouse
Example Response


GET /projects/<project_id>/remixes

Returns an array of the project's remixes.


Example Request
GET https://api.scratch.mit.edu/projects/142/remixes
Example Response


Proxy

POST /proxy/comments/project/<project_id>

Posts a comment on the project page and returns information about the comment. Requires authentication.


Example Request
POST https://api.scratch.mit.edu/proxy/comments/project/142

{
    "content": "Comment text",
    "parent_id": "",
    "commentee_id": ""
}
Example Response


DELETE /proxy/comments/project/<project_id>/comment/<comment_id>

Deletes the project comment. Requires authentication.


Example Request
DELETE https://api.scratch.mit.edu/proxy/comments/project/142/comment/272303677
Example Response


POST /proxy/comments/studio/<studio_id>

Posts a comment in the studio and returns information about the comment. Requires authentication.


Example Request
POST https://api.scratch.mit.edu/proxy/comments/studio/5342

{
    "content": "Comment text",
    "parent_id": "",
    "commentee_id": ""
}
Example Response


DELETE /proxy/comments/studio/<studio_id>/comment/<comment_id>

Deletes the studio comment. Requires authentication.


Example Request
DELETE https://api.scratch.mit.edu/proxy/comments/studio/5342/comment/243636139
Example Response


GET /proxy/featured

Returns information regarding the projects currently visible on the Front Page of the website.


Example Request
GET https://api.scratch.mit.edu/proxy/featured
Example Response


POST /proxy/projects/<project_id>/favorites/user/<username>

Favorites the project. Requires authentication.


Example Request
POST https://api.scratch.mit.edu/proxy/projects/142/favorites/user/Maximouse
X-Requested-With: XMLHttpRequest
Example Response


DELETE /proxy/projects/<project_id>/favorites/user/<username>

Unfavorites the project. Requires authentication.


Example Request
DELETE https://api.scratch.mit.edu/proxy/projects/142/favorites/user/Maximouse
X-Requested-With: XMLHttpRequest
Example Response


POST /proxy/projects/<project_id>/loves/user/<username>

Loves the project. Requires authentication.


Example Request
POST https://api.scratch.mit.edu/proxy/projects/142/loves/user/Maximouse
X-Requested-With: XMLHttpRequest
Example Response


DELETE /proxy/projects/<project_id>/loves/user/<username>

Unloves the project. Requires authentication.


Example Request
DELETE https://api.scratch.mit.edu/proxy/projects/142/loves/user/Maximouse
X-Requested-With: XMLHttpRequest
Example Response


PUT /proxy/projects/<project_id>/share

Shares the project. Requires authentication.


Example Request
PUT https://api.scratch.mit.edu/proxy/projects/737565268/share
Example Response


Search

GET /search/projects?q=<query>&mode=<mode>&language=<language_code>

Searches for projects that match the query (q parameter). The mode can be popular (default) or trending. A language code can be specified but it does not affect the results.[citation needed]


Example Request
GET https://api.scratch.mit.edu/search/projects?q=scratch%203.0&mode=popular&language=en
Example Response


GET /search/studios?q=<query>&mode=<mode>&language=<language_code>

Searches for studios that match the query (q parameter). The mode can be popular (default) or trending. A language code can be specified but it does not affect the results.[citation needed]


Example Request
GET https://api.scratch.mit.edu/search/studios?q=scratch%20welcoming%20committee&mode=popular&language=en
Example Response


Studios

GET /studios/<studio_id>

Returns information about the studio.


Example Request
GET https://api.scratch.mit.edu/studios/31659696
Example Response


GET /studios/<studio_id>/activity?dateLimit=<date>

Returns an array of events related to the studio's activity. The dateLimit is optional: if specified, the response will contain events at least as old as the limit.


Example Request
GET https://api.scratch.mit.edu/studios/31659696/activity?dateLimit=2022-07-09T13:35:07.000Z
Example Response


GET /studios/<studio_id>/comments

Returns an array of comments posted in the studio. Replies are not included in the response, so a separate request needs to be made for each comment with a "reply_count" greater than 0.


Example Request
GET https://api.scratch.mit.edu/studios/5342/comments
Example Response


GET /studios/<studio_id>/comments/<comment_id>

Returns information about the studio comment.


Example Request
GET https://api.scratch.mit.edu/studios/5342/comments/121123167
Example Response


GET /studios/<studio_id>/comments/<comment_id>/replies

Returns an array of replies to the specified studio comment.


Example Request
GET https://api.scratch.mit.edu/studios/5342/comments/121123167/replies
Example Response


GET /studios/<studio_id>/curators

Returns an array of the studio's curators.


Example Request
GET https://api.scratch.mit.edu/studios/31659696/curators
Example Response


GET /studios/<studio_id>/managers

Returns an array of the studio's managers.


Example Request
GET https://api.scratch.mit.edu/studios/31659696/managers
Example Response


GET /studios/<studio_id>/projects

Returns an array of projects in the studio.


Example Request
GET https://api.scratch.mit.edu/studios/31659696/projects
Example Response


POST /studios/<studio_id>/project/<project_id>

Adds the project to the studio and returns information about the activity. Requires authentication.


Example Request
POST https://api.scratch.mit.edu/studios/31749150/project/142
Example Response


DELETE /studios/<studio_id>/project/<project_id>

Removes the project from the studio. Requires authentication.


Example Request
DELETE https://api.scratch.mit.edu/studios/31749150/project/142
Example Response


PUT /studios/<studio_id>/transfer/<username>

Makes the specified user the host of the studio.


Example Request
GET https://api.scratch.mit.edu/studios/31749150/transfer/__mm_test__

{
    "password": "..."
}
Example Response


GET /studios/<studio_id>/users/<username>

Returns information about the user's role in the studio. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/studios/31659696/users/Maximouse
Example Response


Users

GET /users/<username>

Returns information about the specified user.


Example Request
GET https://api.scratch.mit.edu/users/mres
Example Response


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.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.scratch.mit.edu/users/mres/followers
Example Response


GET /users/<username>/following

Returns a list of the users that the specified user has most recently followed.


Example Request
GET https://api.scratch.mit.edu/users/mres/following
Example Response


GET /users/<username>/following/studios/projects

Returns information regarding the Projects in Studios I'm Following row on the front page. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/following/studios/projects
Example Response


GET /users/<username>/following/users/activity

Returns information regarding the "What's Happening?" section of the homepage for a given user. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/following/users/activity
Example Response


GET /users/<username>/following/users/loves

Returns information regarding the Projects Loved by Scratchers I'm Following row on the front page. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/following/users/loves
Example Response


GET /users/<username>/following/users/projects

Returns information regarding the Projects by Scratchers I'm Following row on the front page. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/following/users/projects
Example Response


GET /users/<username>/invites

If the user is invited to become a Scratcher, returns details about the invitation. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/invites
Example Response


GET /users/<username>/messages?filter=<filter>

Returns an array of the user's messages. The filter can be comments, projects, studios, or forums. If it is omitted, the response will include all categories of messages. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/messages?filter=projects
Example Response


GET /users/<username>/messages/admin

Returns an array of the user's unread alerts. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/messages/admin
Example Response


GET /users/<username>/messages/count

This returns the number of unread messages a user currently has. This is what the system looks for showing the message count.


Example Request
GET https://api.scratch.mit.edu/users/mres/messages/count
Example Response


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.scratch.mit.edu/users/mres/projects
Example Response


GET /users/<username>/projects/recentlyviewed

Returns an array of projects the user has recently viewed. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/projects/recentlyviewed
Example Response


GET /users/<username>/projects/<project_id>

Returns information relevant to the given project.


Example Request
GET https://api.scratch.mit.edu/users/mres/projects/142
Example Response


GET /users/<username>/projects/<project_id>/comments

Returns an array of comments posted on the project. Replies are not included in the response, so a separate request needs to be made for each comment with a "reply_count" greater than 0.


Example Request
GET https://api.scratch.mit.edu/users/mres/projects/142/comments
Example Response


GET /users/<username>/projects/<project_id>/comments/<comment_id>

Returns information about the project comment.


Example Request
GET https://api.scratch.mit.edu/users/mres/projects/142/comments/272303677
Example Response


GET /users/<username>/projects/<project_id>/comments/<comment_id>/replies

Returns an array of replies to the specified project comment.


Example Request
GET https://api.scratch.mit.edu/users/mres/projects/142/comments/272303677/replies
Example Response


GET /users/<username>/projects/<project_id>/studios

Returns an array of studios the project is in.


Example Request
GET https://api.scratch.mit.edu/users/mres/projects/142/studios
Example Response


POST /users/<username>/projects/<project_id>/views

Increments the project's view count. If the project has already been viewed by the same user, the request will fail with the error code 429 (Too Many Requests). Requires authentication.


Example Request
POST https://api.scratch.mit.edu/users/mres/projects/142/views
Example Response


GET /users/<username>/projects/<project_id>/visibility

Returns additional information about an unshared project. Requires authentication.


Example Request
GET https://api.scratch.mit.edu/users/Maximouse/projects/737565268/visibility
Example Response


GET /users/<username>/studios/curate

Returns an array of studios curated by the user.


Example Request
GET https://api.scratch.mit.edu/users/mres/studios/curate
Example Response


Removed endpoints

GET /proxy/users/<user_id>/featured

Returned information regarding the Projects by Scratchers I'm Following, Projects Loved by Scratchers I'm Following and Projects in Studios I'm Following rows on the front page. Moved to /users/<username>/following/users/projects, /users/<username>/following/users/loves, and /users/<username>/following/studios/projects.


Example Request
GET https://api.scratch.mit.edu/proxy/users/167/featured
Example Response


GET /proxy/users/<username>/activity

Returned information regarding the "What's Happening?" section of the homepage for a given user. Moved to /users/<username>/following/users/activity.


Example Request
GET https://api.scratch.mit.edu/proxy/users/mres/activity
Example Response


GET /proxy/users/<username>/activity/count

Was used to return the number of unread messages a user currently has. Moved to /users/<username>/messages/count.


Example Request
GET https://api.scratch.mit.edu/proxy/users/mres/activity/count
Example Response


April Fools' Day, 2018

As an easter egg for April Fools' Day 2018, a counter endpoint was added.

POST /surprise

Increments the counter and returns its current value.


Example Request
POST https://api.scratch.mit.edu/surprise
Example Response


GET /surprise

Returns the counter's current value. This is cached on the server, and so might return an earlier value.


Example Request
GET https://api.scratch.mit.edu/surprise
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.[2] It is still available though, and is used by some parts of the Scratch website. 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/
Example Response


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/
Example Response


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/
Example Response


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 (Removed)

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.


The varserver API could be utilised to request the values of cloud variables in projects. This API could be accessed via the following URL. It is no longer available, and future requests will return 404 errors.[3][dead link]

https://scratch.mit.edu/varserver/

GET /<project_id>

Returned information regarding the cloud data of a given project.


Example Request
GET https://scratch.mit.edu/varserver/10080213
Example Response


api/v1 Interface (Removed)

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.

As of 23 April 2018, the API v1 interface no longer exists queries to this path are immediately met with HTTP 403 errors.

The API v1 interface is a legacy interface which was originally built during the development of Scratch 2.0. It was 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


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


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


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;ScratchCat/
Example Response


See Also

External Links

SandCastleIcon.png This section has links to websites or programs outside of Scratch and Wikipedia. Remember to stay safe while using the internet, as we cannot guarantee the safety of other websites.

References

  1. Paddle2See. (15/11/2021). "Accounts have most definitely been blocked for abusing the API." post:5784428
  2. thisandagain. (26/10/2015). "The “site-api” endpoints are all deprecated as of today." post:1552554
  3. thisandagain. (22/5/2018). "Yup. That legacy system has been removed." users:thisandagain/#comments-45728731
Cookies help us deliver our services. By using our services, you agree to our use of cookies.