Discuss Scratch

vcokltfre
Scratcher
100+ posts

Scratch 3 API with Python

I'm making a python program with basic functionality to interact with cloud variables, but, I can't find anywhere the documentation regarding using the Scratch 3 API. It would be great if someone could direct me to resources explaining how I could achieve this, or if someone has an example I could view.

The main thing the program needs to be able to do is read the value of a cloud variable.

–Thanks, vcokltfre
apple502j
Scratcher
1000+ posts

Scratch 3 API with Python

I want it too but the ST does not like that kind of libraries. When I asked @thisandagain, he said logging into Scratch would not be allowed, so are bots.
ScratchToolBox
Scratcher
61 posts

Scratch 3 API with Python

For reading cloud variables, you could pull the latest value from the Cloud Logs JSON

Example JSON URL: https://clouddata.scratch.mit.edu/logs?projectid=214939356&limit=500&offset=0


Example Python: (Requires requests module, ‘pip install requests’)
https://repl.it/@William3/test3453234232

Example Output:
Value: 100
Variable Name: ☁ myvariable
User: ScratchToolBox
vcokltfre
Scratcher
100+ posts

Scratch 3 API with Python

ScratchToolBox wrote:

For reading cloud variables, you could pull the latest value from the Cloud Logs JSON

Example JSON URL: https://clouddata.scratch.mit.edu/logs?projectid=214939356&limit=500&offset=0


Example Python: (Requires requests module, ‘pip install requests’)
https://repl.it/@William3/test3453234232

Example Output:
Value: 100
Variable Name: ☁ myvariable
User: ScratchToolBox
I figured this out after a while but thanks for the help anyway and now there's an easy permanent reference to this
TheGeniusCoder
Scratcher
100+ posts

Scratch 3 API with Python

Not sure if anyone of you guys are still active but is there anyway that you can explain how to reference and execute the cloud logs. I've seen the discussion on a couple different posts but the explanations don't follow a tutorial structure or a way of saying how to do it, just saying what to do (ex: reference the cloud logs).
A-E-
Scratcher
100+ posts

Scratch 3 API with Python

Just send an HTTP GET with your library of choice to https://clouddata.scratch.mit.edu/logs?projectid=PROJECT-ID&limit=40&offset=0
A-E-
Scratcher
100+ posts

Scratch 3 API with Python

You can write to variables with https://github.com/trumank/scratch-api but that needs a bot account, and the ST dislikes those. Also, if you create bot accounts, the ST will ban any alts you create, and that's how my alt @DenverCoder9 got banned 2 days after I made it, with no activity, because they thought it was a bot. It wasn't. (Please give it back, or at least give a non-generic reply to my email. I responded to your last email weeks ago and you haven't replied yet)

Powered by DjangoBB