Discuss Scratch

cutellama12345
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)


cutellama12345 wrote:

Does scratchattach work with an online IDE?
Depends on which one…
Would this one work? https://www.online-python.com/
MineTurte
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

cutellama12345 wrote:

Would this one work? https://www.online-python.com/
Doesn’t seem to work, no.

Last edited by MineTurte (March 21, 2026 04:18:18)

BobaFatL
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

MineTurte wrote:

Hmm… Try your original code. Does it give the same error? Or try just adding a project to a studio once. I've never actually seen this error code
When I ran the original code I got this error after it looped 10 times:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connection.py", line 204, in _new_conn
    sock = connection.create_connection(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\util\connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\socket.py", line 983, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    response = self._make_request(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 488, in _make_request
    raise new_e
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 464, in _make_request
    self._validate_conn(conn)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 1093, in _validate_conn
    conn.connect()
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connection.py", line 759, in connect
    self.sock = sock = self._new_conn()
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connection.py", line 211, in _new_conn
    raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\adapters.py", line 644, in send
    resp = conn.urlopen(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
    retries = retries.increment(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\util\retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\requests.py", line 30, in get
    r = requests.get(url, data=data, json=json, headers=headers, cookies=cookies, params=params,
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\adapters.py", line 677, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\___\Desktop\Server.py", line 32, in <module>
    studio = session.connect_studio("14640")
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\site\session.py", line 877, in connect_studio
    return self._make_linked_object("id", int(studio_id), studio.Studio, exceptions.StudioNotFound)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\site\session.py", line 792, in _make_linked_object
    return commons._get_object(identificator_name, identificator, __class, NotFoundException, self)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\commons.py", line 159, in _get_object
    raise e
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\commons.py", line 140, in _get_object
    r = _object.update()
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\site\_base.py", line 23, in update
    response = self.update_function(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\requests.py", line 33, in get
    raise exceptions.FetchError(e)
scratchattach.utils.exceptions.FetchError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
GvYoutube
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

BobaFatL wrote:

MineTurte wrote:

Hmm… Try your original code. Does it give the same error? Or try just adding a project to a studio once. I've never actually seen this error code
When I ran the original code I got this error after it looped 10 times:
-snip-
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\requests.py", line 33, in get
    raise exceptions.FetchError(e)
scratchattach.utils.exceptions.FetchError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
Python cant resolve “api.scratch.mit.edu” because it thinks it is an invalid website, because it expects http:// or https:// before the URL.

Last edited by GvYoutube (Feb. 23, 2026 14:36:09)

MineTurte
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

GvYoutube wrote:

BobaFatL wrote:

MineTurte wrote:

Hmm… Try your original code. Does it give the same error? Or try just adding a project to a studio once. I've never actually seen this error code
When I ran the original code I got this error after it looped 10 times:
-snip-
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\requests.py", line 33, in get
    raise exceptions.FetchError(e)
scratchattach.utils.exceptions.FetchError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
Python cant resolve “api.scratch.mit.edu” because it thinks it is an invalid website, because it expects http:// or https:// before the URL.
If this were true then it'd be a problem with scratchattach and not this users script… Considering there hasn't been any problems for anyone else I assume that is not the problem.
cutellama12345
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

Does anyone have an online IDE that you can use Scratchattach on?
TheCommCraft
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

BobaFatL wrote:

(#3143)

MineTurte wrote:

Hmm… Try your original code. Does it give the same error? Or try just adding a project to a studio once. I've never actually seen this error code
When I ran the original code I got this error after it looped 10 times:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connection.py", line 204, in _new_conn
    sock = connection.create_connection(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\util\connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\socket.py", line 983, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    response = self._make_request(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 488, in _make_request
    raise new_e
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 464, in _make_request
    self._validate_conn(conn)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 1093, in _validate_conn
    conn.connect()
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connection.py", line 759, in connect
    self.sock = sock = self._new_conn()
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connection.py", line 211, in _new_conn
    raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\adapters.py", line 644, in send
    resp = conn.urlopen(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
    retries = retries.increment(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\urllib3\util\retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\requests.py", line 30, in get
    r = requests.get(url, data=data, json=json, headers=headers, cookies=cookies, params=params,
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\adapters.py", line 677, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\___\Desktop\Server.py", line 32, in <module>
    studio = session.connect_studio("14640")
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\site\session.py", line 877, in connect_studio
    return self._make_linked_object("id", int(studio_id), studio.Studio, exceptions.StudioNotFound)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\site\session.py", line 792, in _make_linked_object
    return commons._get_object(identificator_name, identificator, __class, NotFoundException, self)
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\commons.py", line 159, in _get_object
    raise e
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\commons.py", line 140, in _get_object
    r = _object.update()
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\site\_base.py", line 23, in update
    response = self.update_function(
  File "C:\Users\___\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\scratchattach\utils\requests.py", line 33, in get
    raise exceptions.FetchError(e)
scratchattach.utils.exceptions.FetchError: HTTPSConnectionPool(host='api.scratch.mit.edu', port=443): Max retries exceeded with url: /studios/14640 (Caused by NameResolutionError("HTTPSConnection(host='api.scratch.mit.edu', port=443): Failed to resolve 'api.scratch.mit.edu' ([Errno 11001] getaddrinfo failed)"))
The device you are hosting this script likely has internet connectivity problems.

The previous saying that you are not allowed to perform an action might be because you are trying to remove a project from a studio which doesn't allow everyone to add projects (if you are not a curator on said studio) or because the project does not belong to the account performing the action in scratchattach.

The first error (json decoder error) was possibly a ratelimit.

Last edited by TheCommCraft (Feb. 25, 2026 19:37:40)

Boss_1s
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

use it on github actions
only downside is a 6hr limit per action run, but that's real easy to bypass
check my scratchattach repo for an example
https://github.com/Boss-1s/scratchattach/blob/main/.github/workflows/action1.yml
ScratchTheCoder12345
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

cutellama12345 wrote:

Does anyone have an online IDE that you can use Scratchattach on?
I'm not sure but if you have some money laying around you can purchase a VPS and just run Scratchattach on it.
MeLovesScratch123
Scratcher
10 posts

scratchattach - A Scratch API wrapper (Python)

help, on my storage.add_database(db1) it keeps saying "name ‘db1’ is not identified
VIGARPAST_777
Scratcher
75 posts

scratchattach - A Scratch API wrapper (Python)

redspacecat wrote:

GamerDAC wrote:

(#3099)
WHAT ERROR IS THIS: Warning: Logged in by id, but couldn't fetch XToken. Make sure the provided session id is valid.
Is the session id you provided valid?
That's not an error. It's only a warning. It doesn't affects to your code. Sry for my English
MineTurte
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

MeLovesScratch123 wrote:

help, on my storage.add_database(db1) it keeps saying "name ‘db1’ is not identified

storage.add_database(“db1”)
wvzack
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

VIGARPAST_777 wrote:

redspacecat wrote:

GamerDAC wrote:

(#3099)
WHAT ERROR IS THIS: Warning: Logged in by id, but couldn't fetch XToken. Make sure the provided session id is valid.
Is the session id you provided valid?
That's not an error. It's only a warning. It doesn't affects to your code. Sry for my English
Are you running on an online ide like replit? Your code will still work for cloud variables however you will not be able to send messages and stuff.
davohunter
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

Is it possible to user scratchattach to make a random project generator in scratch?
GvYoutube
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

davohunter wrote:

Is it possible to user scratchattach to make a random project generator in scratch?
No.
ScratchAttach is a Python plugin that uses cloud variables to make online games or similar online things.
Blaireau2012
Scratcher
28 posts

scratchattach - A Scratch API wrapper (Python)

Hi!
I got this error:

Traceback (most recent call last):
  File "/home/Blaireau2012/Documents/09_ Python/scratchattach$.py", line 57, in <module>
    utillisateur = session.connect_user(utili)
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/site/session.py", line 804, in connect_user
    return self._make_linked_object("username", username, user.User, exceptions.UserNotFound)
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/site/session.py", line 792, in _make_linked_object
    return commons._get_object(identificator_name, identificator, __class, NotFoundException, self)
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/utils/commons.py", line 159, in _get_object
    raise e
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/utils/commons.py", line 153, in _get_object
    raise NotFoundException
scratchattach.utils.exceptions.UserNotFound

Do you know of a way to fix it?
FIXED!

Last edited by Blaireau2012 (March 21, 2026 06:29:45)

ScratchTheCoder12345
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

Blaireau2012 wrote:

Hi!
I got this error:

Traceback (most recent call last):
  File "/home/Blaireau2012/Documents/09_ Python/scratchattach$.py", line 57, in <module>
    utillisateur = session.connect_user(utili)
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/site/session.py", line 804, in connect_user
    return self._make_linked_object("username", username, user.User, exceptions.UserNotFound)
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/site/session.py", line 792, in _make_linked_object
    return commons._get_object(identificator_name, identificator, __class, NotFoundException, self)
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/utils/commons.py", line 159, in _get_object
    raise e
  File "/home/Blaireau2012/venv/lib/python3.12/site-packages/scratchattach/utils/commons.py", line 153, in _get_object
    raise NotFoundException
scratchattach.utils.exceptions.UserNotFound

Do you know of a way to fix it?
Please send your code here.
Blaireau2012
Scratcher
28 posts

scratchattach - A Scratch API wrapper (Python)

Here you are:
import scratchattach as sa
import time
import random
dernier_changement = time.time()
derniere_maj = time.time()
session = sa.login('username', 'password')
cloud = session.connect_cloud('1292979730')
Blaireau = session.connect_user("Blaireau2012")
cloud.set_var('☁ Blaireau2012-fellowers', Blaireau.follower_count())
samoht = session.connect_user("samoht1616")
cloud.set_var('☁ samoht1616-fellowers', samoht.follower_count())
def decoder(variable):
    alphabet = "00000000001234567890 aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'*/:,⭐°⌣�✉(.)★?@#!_-+&➡✔❌"
    compteur = 0
    var = str(variable)
    resultat = ""
    
    # Division entière avec //
    for _ in range(len(var) // 2):
        paire = var[compteur] + var[compteur+1]
        index = int(paire)
        
        # Vérification de l'index
        if index < len(alphabet):
            resultat += alphabet[index]
        else:
            resultat += "?"
            
        compteur += 2
        
    return resultat
#boucle principale
while(True):
    #change la variable test
    if dernier_changement+1 <= time.time():
        cloud.set_var('☁ test', random.randint(1, 10))
        dernier_changement = time.time()
    #met a jour les fellowers
    if derniere_maj+60 >= time.time():
        cloud.set_var('☁ Blaireau2012-fellowers', Blaireau.follower_count())
        cloud.set_var('☁ samoht1616-fellowers', samoht.follower_count())
    
    if cloud.get_var('☁ ask-server') != None:
        print(cloud.get_var('☁ ask-server'))
        if cloud.get_var('☁ ask-server') != 0 :
            utili=decoder(cloud.get_var('☁ ask-server'))
            utillisateur = session.connect_user(utili)
            cloud.set_var('☁ followers', utillisateur.follower_count())
I'm sorry, it's in french.
ERROR FIXED!

Last edited by Blaireau2012 (March 21, 2026 06:30:12)

sly_wolf_901
Scratcher
60 posts

scratchattach - A Scratch API wrapper (Python)

is this what people are using to get round bans? because accounts don't get deleted, only banned.
GvYoutube
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

sly_wolf_901 wrote:

is this what people are using to get round bans? because accounts don't get deleted, only banned.
No, this is a python API wrapper. If you're banned you cannot use the API with your login token

Powered by DjangoBB