提供:Japanese Scratch-Wiki

< 利用者:MagicAho

Wiki.png ここは利用者のサンドボックスです。編集を試したり下書きを置いておいたりするための場所であり、Wikiの記事ではありません。
この記事は英語版の記事、en:Scratch_API(3.0)から翻訳されています。

現在、翻訳中

テンプレート:Other version Scratch APIは、プログラマーとって簡単な方法でデータの様々なインスタンスにアクセスするためのインターフェースですScratchウェブサイトとの間でデータを送受信するアプリケーションを作成するために、さまざまな方法で使用することができる。現在のScratch APIのアドレスは、https://api.scratch.mit.edu

Warning
警告:
APIは、責任を持って、利用規約に合わせて使用すること。 APIの悪用は、BANにつながる可能性がある。{{:en:cite post|Paddle2See|15/11/2021|アカウントは間違いなくAPIを悪用するためにブロックされています。|post:5784428}}

api.scratch.mit.edu インターフェイス

api.scratch.mit.edu インターフェースは、Scratch API の最新版である。Scratchのウェブサイトに関する様々なデータを返すために使用できる。この API には以下の 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.

見出しタイトル

GET /

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


要求の例
GET https://api.scratch.mit.edu
応答の例


Health

GET /health

Used to return the status of the Scratch website.


要求の例
GET https://api.scratch.mit.edu/health
応答の例


News

GET /news

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


要求の例
GET https://api.scratch.mit.edu/news
応答の例


Projects

GET /projects/count/all

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


要求の例
GET https://api.scratch.mit.edu/projects/count/all
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/projects/142
応答の例


GET /projects/<project_id>/remixes

Returns an array of the project's remixes.


要求の例
GET https://api.scratch.mit.edu/projects/142/remixes
応答の例


Studios

GET /studios/<studio_id>

Returns information about the studio.


要求の例
GET https://api.scratch.mit.edu/studios/31659696
応答の例


GET /studios/<studio_id>/projects

Returns an array of projects in the studio.


要求の例
GET https://api.scratch.mit.edu/studios/31659696/projects
応答の例


GET /studios/<studio_id>/managers

Returns an array of the studio's managers.


要求の例
GET https://api.scratch.mit.edu/studios/31659696/managers
応答の例


GET /studios/<studio_id>/curators

Returns an array of the studio's curators.


要求の例
GET https://api.scratch.mit.edu/studios/31659696/curators
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/studios/31659696/activity?dateLimit=2022-07-09T13:35:07.000Z
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/studios/5342/comments
応答の例


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

Returns information about the studio comment.


要求の例
GET https://api.scratch.mit.edu/studios/5342/comments/121123167
応答の例


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

Returns an array of replies to the specified studio comment.


要求の例
GET https://api.scratch.mit.edu/studios/5342/comments/121123167/replies
応答の例


Proxy

GET /proxy/featured

Returns information regarding the projects currently visible on the front page of the website.


要求の例
GET https://api.scratch.mit.edu/proxy/featured
応答の例


Users

GET /users/<username>

Returns information about the specified user.


要求の例
GET https://api.scratch.mit.edu/users/mres
応答の例


GET /users/<username>/favorites

Returns an array of details regarding the projects that a given user has favourited on the website.


要求の例
GET https://api.scratch.mit.edu/users/mres/favorites
応答の例


GET /users/<username>/followers

Returns a list of a user's most recent followers.


要求の例
GET https://api.scratch.mit.edu/users/mres/followers
応答の例


GET /users/<username>/following

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


要求の例
GET https://api.scratch.mit.edu/users/mres/following
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/users/mres/messages/count
応答の例


GET /users/<username>/projects

Returns an array with information regarding the projects that a given user has shared on the Scratch website.


要求の例
GET https://api.scratch.mit.edu/users/mres/projects
応答の例


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

Returns information relevant to the given project.


要求の例
GET https://api.scratch.mit.edu/users/mres/projects/142
応答の例


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

Returns an array of studios the project is in.


要求の例
GET https://api.scratch.mit.edu/users/mres/projects/142/studios
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/users/mres/projects/142/comments
応答の例


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

Returns information about the project comment.


要求の例
GET https://api.scratch.mit.edu/users/mres/projects/142/comments/272303677
応答の例


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

Returns an array of replies to the specified project comment.


要求の例
GET https://api.scratch.mit.edu/users/mres/projects/142/comments/272303677/replies
応答の例


GET /users/<username>/studios/curate

Returns an array of studios curated by the user.


要求の例
GET https://api.scratch.mit.edu/users/mres/studios/curate
応答の例


Accounts

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.


要求の例
GET https://api.scratch.mit.edu/accounts/checkusername/mres
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/explore/projects?q=games&mode=trending&language=en
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/explore/studios?q=animations&mode=trending&language=en
応答の例


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.テンプレート:Cn


要求の例
GET https://api.scratch.mit.edu/search/projects?q=scratch%203.0&mode=popular&language=en
応答の例


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.テンプレート:Cn


要求の例
GET https://api.scratch.mit.edu/search/studios?q=scratch%20welcoming%20committee&mode=popular&language=en
応答の例


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. Each row now has its own API endpoint.


要求の例
GET https://api.scratch.mit.edu/proxy/users/167/featured
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/proxy/users/mres/activity
応答の例


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.


要求の例
GET https://api.scratch.mit.edu/proxy/users/mres/activity/count
応答の例


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.


要求の例
POST https://api.scratch.mit.edu/surprise
応答の例


GET /surprise

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


要求の例
GET https://api.scratch.mit.edu/surprise
応答の例


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.テンプレート:Cite post 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.


要求の例
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.


要求の例
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.


要求の例
GET https://scratch.mit.edu/site-api/comments/user/mres/
応答の例


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)

テンプレート:Obsolete feature

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.テンプレート:Cite postテンプレート:Dead link

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

GET /<project_id>

Returned information regarding the cloud data of a given project.


要求の例
GET https://scratch.mit.edu/varserver/10080213
応答の例


api/v1 Interface (Removed)

テンプレート:Obsolete feature 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.


要求の例
GET https://scratch.mit.edu/api/v1/
応答の例


Projects

GET /project/<project_id>/

Returns information regarding a project and its author.


要求の例
GET https://scratch.mit.edu/api/v1/project/142/
応答の例


GET /project/set/<project_ids>/

Returns information regarding a set of projects and their authors. Project IDs are separated with a semicolon.


要求の例
GET https://scratch.mit.edu/api/v1/project/set/142;864/
応答の例


Users

GET /user/<username>/

Returns information regarding the given user.


要求の例
GET https://scratch.mit.edu/api/v1/user/mres/
応答の例


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.


要求の例
GET https://scratch.mit.edu/api/v1/user/set/mres;ScratchCat/
応答の例


関連項目

External Links

テンプレート:External Programs

出典