Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchattach - A Scratch API wrapper (Python)
- TimMcCool
-
100+ posts
scratchattach - A Scratch API wrapper (Python)
Scratch API wrapper with support for almost all site features. The library can set cloud variables, follow Scratchers, post comments and do so much more!
It has special features that make it easy to transmit data through cloud variables.
Available on PyPi and on GitHub: https://github.com/TimMcCool/scratchattach
Quick Documentation
(Full documentation) (GitHub) (Official studio for scratchattach projects)
Installation:
Run this command in your command prompt / shell:
Features:
- Get and set cloud variables on any Scratch project
- Cloud events
- Cloud requests that allow Scratch projects and Python to interact
- Get and interact with users, projects and studios
- Get and interact with Forum Posts / Topics
… and much more!
Examples
Setting a cloud var with scratchattach:
Cloud Requests:
Link to examples
Cloud event handler:
(Full documentation) (GitHub) (Official studio for scratchattach projects)
Support
If you need help with your code, leave a comment in the official forum topic on TimMcCool's Scratch profile or open an issue on the github repo
Reasons to use scratchattach
➥ Simple to use
➥ Fast and safe
➥ Cloud events & built-in class for encoded cloud requests
➥ Users, projects, comments, search, explore & more!
➥ Forum posts and topics
➥ Most features don't require a session
➥ Open-source

Note
This topic is for talking about scratchattach and reporting bugs / glitches, not for advertising projects or other libraries.
It has special features that make it easy to transmit data through cloud variables.
Available on PyPi and on GitHub: https://github.com/TimMcCool/scratchattach
Quick Documentation
(Full documentation) (GitHub) (Official studio for scratchattach projects)
Installation:
Run this command in your command prompt / shell:
pip install -U scratchattach
Features:
- Get and set cloud variables on any Scratch project
- Cloud events
- Cloud requests that allow Scratch projects and Python to interact
- Get and interact with users, projects and studios
- Get and interact with Forum Posts / Topics
… and much more!
Examples
Setting a cloud var with scratchattach:
import scratchattach as scratch3
session = scratch3.login("username", "password")
conn = session.connect_cloud("project_id")
conn.set_var("variable", value)
Link to examples
Cloud event handler:
import scratchattach as scratch3
events = scratch3.CloudEvents("project_id")
@events.event
def on_set(event): #Called when a cloud var is set
print(f"{event.user} set the variable {event.var} to the valuee {event.value} at {event.timestamp}")
events.start()
(Full documentation) (GitHub) (Official studio for scratchattach projects)
Support
If you need help with your code, leave a comment in the official forum topic on TimMcCool's Scratch profile or open an issue on the github repo
Reasons to use scratchattach
➥ Simple to use
➥ Fast and safe
➥ Cloud events & built-in class for encoded cloud requests
➥ Users, projects, comments, search, explore & more!
➥ Forum posts and topics
➥ Most features don't require a session
➥ Open-source

Note
This topic is for talking about scratchattach and reporting bugs / glitches, not for advertising projects or other libraries.
Last edited by TimMcCool (Sept. 29, 2023 21:37:23)
My profile / Mein Profil: @TimMcCool
- NFlex23
-
1000+ posts
scratchattach - A Scratch API wrapper (Python)
There are a bunch of other Scratch Python libraries out there already, such as Scratchcloud and Scratchclient, so you may want to use one of those instead of creating an entirely new library. That being said, this still looks really cool and has a lot of potential. 


Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.


- scratchfan321
-
94 posts
scratchattach - A Scratch API wrapper (Python)
Yes! I have an extremely outdated virtual machine with linux which could probably run this safely! (I don't know how to use linux so I keep guessing. Danger comes from myself + terminal)
- scott170
-
84 posts
scratchattach - A Scratch API wrapper (Python)
Can you add encoding and decoding built into this? It would make life so much easier.
- Esben_Flavogle
-
76 posts
scratchattach - A Scratch API wrapper (Python)
when green flag clicked
change [Timmccools follows v] by (100000)
TY SO MUCH FOR MAKING THIS
Last edited by Esben_Flavogle (May 10, 2022 19:47:53)
if <This> then
Eat Ice Cream
else
Also eat ice cream
end
- MrMcCoder
-
100+ posts
scratchattach - A Scratch API wrapper (Python)
Funny, I have actually already learned Python beforehand by working on a Lego robotics team!
Many people have asked me how my “Cloud Scratch Stats” project works. Therefore I decided to make a pip package that makes it easy to build such projects
The package is available on PyPi (Link: https://pypi.org/project/scratch3.py/ ) and on GitHub (Link: https://github.com/TimMcCool/scratch3.py ).
You can install it usingpip install scratch3.py
Features:
- Getting and setting cloud variables
- Built-in class for cloud requests that makes it easy to interact with your Scratch project
- Cloud events
- Users and projects
- Getting and posting comments
- Getting search / explore page
… and much more!
What makes this library special is that it has a built-in class for sending encoded data to Scratch projects. More information: https://github.com/TimMcCool/scratch3.py#cloud-requests–scratch3cloudrequests
How to use:
Setting a cloud var:import scratch3
session = scratch3.login("username", "password")
conn = session.connect_cloud(project_id="project_id")
conn.set_var("variable", value)
Cloud requests:
Find out how to use cloud requests: https://github.com/TimMcCool/scratch3.py#cloud-requests–scratch3cloudrequests
Cloud event handler:import scratch3
events = scratch3.CloudEvents("project_id")
@events.event
def on_set(event): #Called when a cloud var is set
print(f"{event.user} set the variable {event.var} to the valuee {event.value} at {event.timestamp}")
events.start()
More instructions on usage: https://pypi.org/project/scratch3.py/
Please report bugs / glitches on my profile
“Anything can fly if you over engineer it enough.”
-Me
- MagicCrayon9342
-
1000+ posts
scratchattach - A Scratch API wrapper (Python)
I would highly recommend refraining from using a file extension in a package name. The package name does not have to be the same as the file name. Plus, it just isn't as catchy. Also, not sure how good ‘Scratch3.py’ really sounds. I'd recommend a better name, no offense. Also to differentiate between it and Scratch 3.
- Thebro57
-
9 posts
scratchattach - A Scratch API wrapper (Python)
*Me being happy to have a way to code by not using blocks on scratch*
- Winterstar_Official
-
20 posts
scratchattach - A Scratch API wrapper (Python)
this is cool *yeyey*
- nampinanathali
-
1000+ posts
scratchattach - A Scratch API wrapper (Python)
Amazing! - your block assets simply revolutionize the cloud, I am gonna do now simply a scratch bank 

mom when look at my browser history

- Oneninth
-
3 posts
scratchattach - A Scratch API wrapper (Python)
I was think the same Amazing! - your block assets simply revolutionize the cloud, I am gonna do now simply a scratch bank

- Dacggug
-
4 posts
scratchattach - A Scratch API wrapper (Python)
Thank you so much! I know there is a way to use external code to make it so you can have more cloud variables, or something equivalent to that. Could you make a guid for how to code that? I'm planning to make a real time strategy game with multiple players.
- brandontwinzone
-
5 posts
scratchattach - A Scratch API wrapper (Python)
Thanks for the package! I'll use it for my future python projects 
Also, is it available on PyCharm? I don't have pip.

Also, is it available on PyCharm? I don't have pip.
when green flag clicked
set [isClone? v] to [0]
remove (clone limit v) :: #00a30a
remove (fencing v) :: #00a30a
clone (myself v) [100] times :: #ceb810
when I start as a clone
set [isClone? v] to [1]
point in direction (pick random [0] to [360]
forever
move [10] steps
if touching (clones of myself v), bounce :: #255089
if <touching clones of (myself v) :: #376d84> then
say [ow!] for [2] secs:: #26a890
end
if <touching (mouse-pointer v)?> then
animate (image.png v) :: #ff7272
repeat (30)
move cursor to (myself v) :: #db3b3b
- Discussion Forums
- » Advanced Topics
-
» scratchattach - A Scratch API wrapper (Python)