Discuss Scratch

Digitat321
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

fiosjeofo wrote:

Digitat321 wrote:

Oisthebestletter wrote:

Digitat321 wrote:

W fr, also RIP zero-host.org
Just self host bro
ah yes I really want my laptop to run 24/7, overheat, start thermally throttling, probably crash, and consume unneeded amounts of energy
I have a raspberry pi it doesn't use much power. Maybe you can ask if anyone has a R Pi and for them to host it for you? (it's really sad that website went down :-( )
Yeah i could, but i found a free hosting website called Wispbyte and its recommended in the scratchattach docs soooo
d0ggy1sg00d
Scratcher
46 posts

scratchattach - A Scratch API wrapper (Python)

TimMcCool wrote:

scratchattach is a Scratch API wrapper with support for almost all site features.
The library allows setting cloud variables, following users, updating your profile, and so much more!

Documentation - Website - Community projects

Example code:
import scratchattach as sa
session = sa.login("username", "password")
cloud = session.connect_cloud('project_id')
cloud.set_var('variable', 'value')
session.connect_user("user").studios()[0].post_comment("Hi").reply("hello")
⚙️ Features ⚙️

- Get and set cloud variables anytime
v2.0: Added method for setting multiple cloud variables simultaneously, implemented adaptive ratelimit handling and a cloud recorder

- Interact with users, projects, studios and use other site features (post comments, follow users etc.)
v2.0: Added getting users by id, enforced and added object representation for Projects, Studios, Comments and Activity (messages and activites)

- Cloud events (improved in v2.0)

- Cloud requests (packet loss fixed entirely in v2.0, massively lowered CPU usage, added new features)
Similar to cloud events, but they also send back data to the project (automatically encoded and decoded). This allows seamless communication between Scratch and Python

- Cloud storages (new in v2.0)

- Message events (new in v2.0)

- Project JSON editing capabilities (new in v2.0)

- Self-hosting TurboWarp websocket servers (new in v2.0)

All features: Documentation - All new features: Change log

⚙️Installation & Getting started⚙️

Run the following command in your computer's command prompt / shell:
pip install -U scratchattach
OR
python -m pip install scratchattach
Log in with your Scratch account:
import scratchattach as sa
session = sa.login('username', 'password')
Cloud variables:
cloud = session.connect_cloud('project_id')
cloud.set_var('variable', 'value')
cloud.get_var('variable')
Cloud events:
cloud = session.connect_cloud('project_id')
events = cloud.events()
@events.event
def on_set(activity):
    print("variable", activity.var, "was set to", activity.value)
events.start()
Cloud requests - Cloud storage

Follow users, love their projects and comment:
user = session.connect_user('username')
user.follow()
project = user.projects()[0]
project.love()
project.post_comment('Great project!')
Warning: Ask the Scratch team for permission before making a social bot.

All features: Documentation

⚙️ Reasons to use scratchattach⚙️

➥ Simple to use
➥ Fast and safe
➥ Cloud events & built-in class for encoded cloud requests, also cloud storages
➥ Users, projects, comments, search, explore & more!
➥ Forum posts and topics
➥ Most features don't require a session
➥ Allows editing project JSON and hosting TurboWarp cloud servers
➥ Open-source

High level of abstraction and consistency: (improved in v2.0)

Scratchattach has two entrypoints for working with site data and cloud variables: One that works with a login (saved in a Session object) and another one that works without a login.
Methods creating an object using a login start with “Session.connect_” while methods not using a login start with “scratchattach.get_”. This scheme is used consistently - for users (Session.connect_user vs. scratchattach.get_user) and even for cloud variables (Session.connect_cloud vs. scratchattach.get_cloud).

⚙️ What makes scratchattach special? ⚙️

Site features:
- it is the only library that allows getting a user by ID
- it allows fetching data without logging in (methods getting objects without connecting a login start with “scratchattach.get_” while methods connecting a login start with “Session.connect_”)

Cloud features:
- it is the only library that allows setting multiple cloud variables simultaneously
- it is the only library that automatically enforces intelligent rate limits between cloud variable sets to make sure you can set variables very fast and still don't get ratelimited
- it provides a Cloud Requests framework that allows seamless communication between Scratch projects and Python code through cloud variables
- it provides a Cloud Storage framework that makes it easy to store project data (highscores etc.) on a backend server
- it is the only library with a built-in cloud recorder that allows getting a cloud variable anytime without having to query the clouddata logs

Other features:
- it is the only library that allows editing the contents of a project with pre-built methods and directly uploading it to Scratch
- it is the only library that allows self-hosting TurboWarp cloud variable servers easily
- it is the only library that supports getting and editing forum topics and posts

Structure:
- it's object-oriented, abstract and structured, this makes it possible to write code like
`sa.login(“username, ”pw“).connect_user(”user").studios().post_comment(“Hi”)`
- it is the only library that uses objects to represent modals like messages, activities

Developers:
- it has an active developer community that fixes potential bugs fast
- it is constantly being extended with new features

⚙️ 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 github

This topic is for talking about scratchattach and reporting bugs / glitches, not for advertising projects or other libraries.
updating your prof? it really has access to that?
d0ggy1sg00d
Scratcher
46 posts

scratchattach - A Scratch API wrapper (Python)

what if someone does
print("password")
pw = "password"
session = sa.login("d0ggy1sg00d", pw)
project = session.connect_project(*famous project*)
project.post_comment(*inapropriate comment*).reply("█CENSORED█")
user = session.connect_user('username')
user.follow()
project = user.projects()[0]
project.love()

Last edited by d0ggy1sg00d (Sept. 26, 2026 02:21:12)

TechNerd64
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

d0ggy1sg00d wrote:

what if someone does
print("password")
pw = "password"
session = sa.login("d0ggy1sg00d", pw)
project = session.connect_project(*famous project*)
project.post_comment(*inapropriate comment*).reply("█CENSORED█")
user = session.connect_user('username')
user.follow()
project = user.projects()[0]
project.love()
For one, scratchattach doesn't bypass any scratch features. So an inappropriate comment would still be blocked by Scratch's systems.
CodeWaveSurfer
Scratcher
90 posts

scratchattach - A Scratch API wrapper (Python)

Lol you don't even need the topic it's soooo famous
TechNerd64
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

How do i set the project url when trying to verify users? https://github.com/TimMcCool/scratchattach/wiki/Documentation#verifying-a-users-identity
TheCommCraft
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

You can set the keyword argument `project_id`

Last edited by TheCommCraft (Yesterday 14:20:31)

Powered by DjangoBB