Discuss Scratch

TimMcCool
Scratcher
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:
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)
Cloud Requests:
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)


Developer of scratchattach, the most popular Python Scratch API wrapper
NFlex23
Scratcher
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.
Before you post: Is what you're posting likely to start an argument or derail the thread (e.g., browsers, operating systems)? If so, please re-think your post!





scratchfan321
Scratcher
95 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)
supersonic734
Scratcher
29 posts

scratchattach - A Scratch API wrapper (Python)

scratchfan321 wrote:

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)
Oh hello there!!!

Don't forget to check out my projects



rubycube2010
Scratcher
27 posts

scratchattach - A Scratch API wrapper (Python)

this is helpful!
gamemaker_02
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

supersonic734
Scratcher
29 posts

scratchattach - A Scratch API wrapper (Python)

Scratch3.py isn't working for me.

Don't forget to check out my projects



scott170
Scratcher
84 posts

scratchattach - A Scratch API wrapper (Python)

hi
scott170
Scratcher
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
Scratcher
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
goldtime9
Scratcher
1 post

scratchattach - A Scratch API wrapper (Python)

how do you guys make that
MrMcCoder
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

Funny, I have actually already learned Python beforehand by working on a Lego robotics team!

TimMcCool wrote:

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 using
pip 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
Scratcher
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
Scratcher
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
Scratcher
20 posts

scratchattach - A Scratch API wrapper (Python)

this is cool *yeyey*
nampinanathali
Scratcher
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
-wolfs
Scratcher
6 posts

scratchattach - A Scratch API wrapper (Python)

Help ful
__

Wolf god
Oneninth
Scratcher
3 posts

scratchattach - A Scratch API wrapper (Python)

nampinanathali wrote:

Amazing! - your block assets simply revolutionize the cloud, I am gonna do now simply a scratch bank
I was think the same but Im working on something rn so gl
Dacggug
Scratcher
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
Scratcher
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.

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

Powered by DjangoBB