Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchclient - A scratch API wrapper for python
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
The code you have given here perfectly works!Like I just proved…
- TimMcCool
-
Scratcher
100+ posts
scratchclient - A scratch API wrapper for python
what could be the problem then?i do not think so.im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratchhang on, does does the cloud variable need to start with the ☁ symbol?
it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.
any help please
thanks in advance
I made a new script as a test and it gets stuck connecting to the project
this is the scriptprint("init") from scratchclient import ScratchSession print("logging on...") session = ScratchSession("adamkrps425", "<placeholderpassword>") print("connecting to project...") connection = session.create_cloud_connection(726701801) print("setting var...") connection.set_cloud_variable("cloudVar", 1234) print("done!")
and this is the console output
init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)
and as you see the cloud var on the project is still 0
Are you running the code on replit? Then it won't work. Scratch blocked replit from sending login request.
To set cloud variables with replit, you have to use cookie connect. I'm not sure if scratchclient has that feature, I couldn't find it in the documentation
- TimMcCool
-
Scratcher
100+ posts
scratchclient - A scratch API wrapper for python
Ok, I just mainly want to see user followers and project stats and whatnot. How do I use the API?(#563)Depending on what you want to do, if you just want to see user/project stats then you just use scratch's api. But there isn't really a way to comment and interact with the website without using your password.
Is it possible to add a session without my username and password? I want to use this to make a program but I don't want my password and stuff out there for anyone to see.
i've never used scratchclient before now lol
To get your user / project stats, use @DatOneLefty's ScratchDB API:
https://scratchdb.lefty.one/v3/docs/#api-User-GetUserInfo
Example: (this will fetch your user stats)
import requests stats = requests.get("https://scratchdb.lefty.one/v3/user/info/SomeoneOnThelnternet").json()
You can also get your user stats with scratchattach (doesn't require logging in) or scratchconnect:
import scratchattach as scratch3 user = scratch3.get_user("SomeoneOnTheInternet") stats = user.stats()
Last edited by TimMcCool (Aug. 31, 2022 10:45:49)
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
I just made a script that follows and unfollows the account you choose to follow or unfollow.
So, if you wanted to follow gdpr0000001 using this script, you can!
from scratchclient import ScratchSession username2 = input("Username? ") password2 = input("Password? ") session = ScratchSession(username2, password2) follow_or_unfollow = input("Do you want to follow a user or unfollow a user? (\"y\" to follow, CASE SENSITIVE)") if follow_or_unfollow == "y": print("Follow option selected!") else: print("Unfollow option selected") print("Enter in a user name") user1 = input() if follow_or_unfollow == "y": print(f"Following user {user1}...") session.get_user(user1).follow() print(f"User {user1} followed! Check your followers page! https://scratch.mit.edu/users/{username2}/following/") print("To follow or unfollow another user, run this script again!") else: print(f"Unfollowing user {user1}") session.get_user(user1).unfollow() print(f"User {user1} followed! Check your followers page! https://scratch.mit.edu/users/{username2}/following/") print("To unfollow or follow another user, run this script again!")
So, if you wanted to follow gdpr0000001 using this script, you can!
- Peterlll
-
Scratcher
11 posts
scratchclient - A scratch API wrapper for python
Are you guys really sure this can be used without risking a ban?
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Are you guys really sure this can be used without risking a ban?About as safe as using any other scratch python library!
- ZZC12345
-
Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Are you guys really sure this can be used without risking a ban?Yes. There are so many cloud projects using this and similar libraries out there, and they're all still up.
- god286
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
(#587)If you use social actions, like following, loving/favouriting, commenting, etc. then that is not allowed and you may be warned/banned.
Are you guys really sure this can be used without risking a ban?
Other than that, for just getting data and cloud variables, it should be safe.
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
…oh boy, time to edit my post to remove the script!(#587)If you use social actions, like following, loving/favouriting, commenting, etc. then that is not allowed and you may be warned/banned.
Are you guys really sure this can be used without risking a ban?
- AdamKRPS425
-
Scratcher
44 posts
scratchclient - A scratch API wrapper for python
I get this when posting the commentreally I would appreciate any helpDo you get a “scratchclient.ScratchExceptions.UnauthorizedException” error (meaning a 403, and I looked through the code), or a “scratchclient.ScratchExceptions.InvalidCredentialsException” error (meaning, well, your credentials are incorrect)?

and when changing a cloud variable the project just hangs, the console stays responsive but nothing happens. through testing I figured it got stuck on
connection = session.create_cloud_connection(726701801)
- AdamKRPS425
-
Scratcher
44 posts
scratchclient - A scratch API wrapper for python
nope, running it locallywhat could be the problem then?i do not think so.im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratchhang on, does does the cloud variable need to start with the ☁ symbol?
it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.
any help please
thanks in advance
I made a new script as a test and it gets stuck connecting to the project
this is the scriptprint("init") from scratchclient import ScratchSession print("logging on...") session = ScratchSession("adamkrps425", "<placeholderpassword>") print("connecting to project...") connection = session.create_cloud_connection(726701801) print("setting var...") connection.set_cloud_variable("cloudVar", 1234) print("done!")
and this is the console output
init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)
and as you see the cloud var on the project is still 0
Are you running the code on replit? Then it won't work. Scratch blocked replit from sending login request.
To set cloud variables with replit, you have to use cookie connect. I'm not sure if scratchclient has that feature, I couldn't find it in the documentation
- AdamKRPS425
-
Scratcher
44 posts
scratchclient - A scratch API wrapper for python
does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?what could be the problem then?i do not think so.im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratchhang on, does does the cloud variable need to start with the ☁ symbol?
it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.
any help please
thanks in advance
I made a new script as a test and it gets stuck connecting to the project
this is the scriptprint("init") from scratchclient import ScratchSession print("logging on...") session = ScratchSession("adamkrps425", "<placeholderpassword>") print("connecting to project...") connection = session.create_cloud_connection(726701801) print("setting var...") connection.set_cloud_variable("cloudVar", 1234) print("done!")
and this is the console output
init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)
and as you see the cloud var on the project is still 0
The code you have given here perfectly works!
- ZZC12345
-
Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
What's the error?~snip~does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?
The code you have given here perfectly works!
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
What's the error?~snip~does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?
The code you have given here perfectly works!
I get this when posting the comment
- ZZC12345
-
Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Sorry!What's the error?~snip~does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?
The code you have given here perfectly works!I get this when posting the comment
Scratch returned a 403 error when you tried to post that comment. I'm not sure why.
https://github.com/CubeyTheCube/scratchclient/blob/cbabc79bbdeec1064e8de1c88480efdaebd5e1e7/scratchclient/User.py#L102-L103
- NashwanYT
-
Scratcher
100+ posts
scratchclient - A scratch API wrapper for python
can u use pycharm it has inbuilt terminal and pip
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
can u use pycharm it has inbuilt terminal and pipMost of us would rather not pay 89 dollars USA for a product that can easily be replicated for 0 dollars USA with VSCode and a VSCode extension. Your choice, though.
- Chiroyce
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Bruh PyCharm is free https://www.jetbrains.com/pycharm/download/ — secondly if they already have the paid version then what is wrong with using PyCharm for this? PyCharm is designed for Pythoncan u use pycharm it has inbuilt terminal and pipMost of us would rather not pay 89 dollars USA for a product that can easily be replicated for 0 dollars USA with VSCode and a VSCode extension. Your choice, though.
I've seen this as a trend with your posts, just take this as advise and maybe look through sources a bit more when you post

Last edited by Chiroyce (Sept. 17, 2022 05:09:55)
- ZZC12345
-
Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Most of the JetBrains IDEs are expensive if you pay for the commercial versions, but the community versions are free. The community ones are even open source! Next time, do some research before you post.can u use pycharm it has inbuilt terminal and pipMost of us would rather not pay 89 dollars USA for a product that can easily be replicated for 0 dollars USA with VSCode and a VSCode extension. Your choice, though.
Download PyCharmThe regular version is free.
Professional
For both Scientific and Web Python development. With HTML, JS, and SQL support.
( Download )
Free 30-day trial available
Community
For pure Python development
( Download )
Free, built on open-source
- DifferentDance8
-
Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Most of the JetBrains IDEs are expensive if you pay for the commercial versions, but the community versions are free. The community ones are even open source! Next time, do some research before you post.I know that. It's just that if you want to get support from JetBrains themselves, then you gotta pay up.
- Discussion Forums
- » Advanced Topics
-
» scratchclient - A scratch API wrapper for python