Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Scratch API
- kashifau
- New to Scratch
22 posts
Scratch API
Is there a way to get the list of IDs of all Scratch projects via Scratch API?
- Jonathan50
- Scratcher
1000+ posts
Scratch API
No, that would be way to long… Anyway, the project IDs just go sequentially up from 104 to ~198 million, not counting all the deleted projects in between.
Last edited by Jonathan50 (Jan. 19, 2018 04:41:47)
Not yet a Knight of the Mu Calculus.
- _nix
- Scratcher
1000+ posts
Scratch API
Of course, unshared projects are also stored by those IDs, which will just be 404s (if you aren't the creator of that unshared project). No, that would be way to long… Anyway, the project IDs just go sequentially up from 104 to ~198 million, not counting all the deleted projects in between.
By the way, you can get the total number of projects by using /projects/count/all. (This isn't quite live, but updates fairly frequently.)
══ trans autistic lesbian enbydoggirls // 16 17 18 19 20, she/they ════
sparrows one word to the paragraph // <3 // ~(quasar) nebula
- kashifau
- New to Scratch
22 posts
Scratch API
Thanks. That was helpful. I need to perform analysis on large number of projects so maybe I can generate numbers between 104 to 198 million and then check individual projects.
- jokebookservice1
- Scratcher
1000+ posts
Scratch API
Slightly relevant thing of mine. It tries random project IDs until it gets a match.
- kashifau
- New to Scratch
22 posts
Scratch API
Slightly relevant thing of mine. It tries random project IDs until it gets a match.Is the code available online?
- _nix
- Scratcher
1000+ posts
Scratch API
Yes, see here: https://github.com/joker314/joker314.github.io/blob/master/RandomProject.htmlSlightly relevant thing of mine. It tries random project IDs until it gets a match.Is the code available online?
══ trans autistic lesbian enbydoggirls // 16 17 18 19 20, she/they ════
sparrows one word to the paragraph // <3 // ~(quasar) nebula
- jokebookservice1
- Scratcher
1000+ posts
Scratch API
The bit at the start of the URL looks like "https://cors-anywhere.herokuapp.com/" in the code. This basically just fetches the content under the URL that follows; but it bypasses Same Origin policy, something browsers enforce for security, if that helps. Same origin policy stops my code from taking control over your Scratch account.
I'm going to make some modifications to the code since it's a little outdated
(EDIT: done)
To improve, you could try and hook it up to the statistics api so that the maximum random number is the latest one, and not something which turns inaccurate very quickly.
(EDIT: added more words)
I'm going to make some modifications to the code since it's a little outdated
(EDIT: done)
To improve, you could try and hook it up to the statistics api so that the maximum random number is the latest one, and not something which turns inaccurate very quickly.
(EDIT: added more words)
Last edited by jokebookservice1 (Jan. 21, 2018 23:04:19)
- kashifau
- New to Scratch
22 posts
Scratch API
Is there a way to get the project code in Json or any other format ?
- Sheep_maker
- Scratcher
1000+ posts
Scratch API
Is there a way to get the project code in Json or any other format ?
https://projects.scratch.mit.edu/internalapi/project/<project ID>/get/
In it there are md5 hashes of assets such as “8fb3962cfe256cc600587ed3f76f0d59.svg” which you can use to get the assets from
https://cdn.assets.scratch.mit.edu/internalapi/asset/<md5 hash thing>/get/
- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
- kashifau
- New to Scratch
22 posts
Scratch API
Brilliant. Works for 2.0 projects. Any way around for 1.4 projects?Is there a way to get the project code in Json or any other format ?gets the project.json of the given project ID.https://projects.scratch.mit.edu/internalapi/project/<project ID>/get/
In it there are md5 hashes of assets such as “8fb3962cfe256cc600587ed3f76f0d59.svg” which you can use to get the assets fromhttps://cdn.assets.scratch.mit.edu/internalapi/asset/<md5 hash thing>/get/
- _nix
- Scratcher
1000+ posts
Scratch API
1.4 projects are stored as SB files, which are a particular format which isn't particularly easy to work with (it's not a zip or any similar common format). You can get the SB file just by opening the same URL (cdn.assets.scratch.mit.edu/internalapi/asset/MD5/get/); you can use a library like Any way around for 1.4 projects?kurt to extract assets/scripts (but not in the SB2 json format, of course).
══ trans autistic lesbian enbydoggirls // 16 17 18 19 20, she/they ════
sparrows one word to the paragraph // <3 // ~(quasar) nebula
- kashifau
- New to Scratch
22 posts
Scratch API
Thanks for the valuable feedback everyone. Cheers.
Last edited by kashifau (Jan. 22, 2018 00:03:04)
- kashifau
- New to Scratch
22 posts
Scratch API
Is it possible to tell the version of Scratch project (1.4 or 2.0) or can I fetch the extension of the project via API or any other method.
- Jonathan50
- Scratcher
1000+ posts
Scratch API
Fetch the project, if the first byte is “S” it's a Scratch 1.x project, if the first byte is “{” or whitespace then it's a Scratch 2.0 project. Is it possible to tell the version of Scratch project (1.4 or 2.0) or can I fetch the extension of the project via API or any other method.
(Btw, if you're planning to make something that makes lots and lots of requests to the Scratch API to gather lots of statistics, you probably shouldn't go ahead with it, without asking a Scratch Team member first.)
Last edited by Jonathan50 (Jan. 23, 2018 04:19:38)
Not yet a Knight of the Mu Calculus.
- kashifau
- New to Scratch
22 posts
Scratch API
Thanks for the tip.Fetch the project, if the first byte is “S” it's a Scratch 1.x project, if the first byte is “{” or whitespace then it's a Scratch 2.0 project. Is it possible to tell the version of Scratch project (1.4 or 2.0) or can I fetch the extension of the project via API or any other method.
(Btw, if you're planning to make something that makes lots and lots of requests to the Scratch API to gather lots of statistics, you probably shouldn't go ahead with it, without asking a Scratch Team member first.)
I do intend to make a lots of request. At the moment, I am making only few requests just to analyze few projects but soon will be increasing the number of requests. Is that a problem?
- kashifau
- New to Scratch
22 posts
Scratch API
1.4 projects are stored as SB files, which are a particular format which isn't particularly easy to work with (it's not a zip or any similar common format). You can get the SB file just by opening the same URL (cdn.assets.scratch.mit.edu/internalapi/asset/MD5/get/); you can use a library like Any way around for 1.4 projects?kurt to extract assets/scripts (but not in the SB2 json format, of course).
Hi. When I download the project file for 1.4 Scratch projects using https://projects.scratch.mit.edu/internalapi/project/<project ID>/get/ the file I get is in some coded format and there is no md5 in it. I have tried using kurt to read that file but it gives an error. Any idea how to do this?
- Jonathan50
- Scratcher
1000+ posts
Scratch API
https://projects.scratch.mit.edu/internalapi/project/<project ID>/get/ the file I get is in some coded format and there is no md5 in it. I have tried using kurt to read that file but it gives an error. Any idea how to do this?You might need to give it a .sb extension or pass the format “scratch14” to Kurt: Hi. When I download the project file for 1.4 Scratch projects using http://kurt.readthedocs.io/en/latest/api.html#kurt.Project.load
Edit: It seems like Kurt won't read any projects from Scratch 1.2 or older because of the ScratchV01 header Maybe ask @blob8108.
Last edited by Jonathan50 (Feb. 12, 2018 04:57:37)
Not yet a Knight of the Mu Calculus.
- kashifau
- New to Scratch
22 posts
Scratch API
Is there a way to get the age of the user of the project? (via API or any other way?)
- Discussion Forums
- » Advanced Topics
- » Scratch API