Skip to content

ScratchSession

CubeyTheCube edited this page Jul 8, 2021 · 2 revisions

Properties

username

The username of the logged in user.

Example:

session = ScratchSession("ceebee", "--uwu--")

print(session.username)
# ceebee

session_id

The Scratch session ID of the logged in user's session.

token

The X-Token of the logged in user.

csrf_token

The CSRF token of the logged in user's session.

user

The User object of the logged in user.

Example:

session = ScratchSession("ceebee", "--uwu--")

print(session.user.id)
# 2755634

Methods

get_user(username)

Gets the User object of the specified username.

Example:

print(session.get_user("griffpatch").scratchteam)
# False

get_project(id)

Gets the Project object for the specified ID.

Example:

print(session.get_project(60917032).title)
# Appel v1.4

get_studio(id)

Gets the Studio object for the specified ID.

Example:

print(session.get_studio(26135902).owner)
# Za-Chary

get_news()

Gets Scratch's news as an array of News objects.

Example:

print(session.get_news()[0].title)
# Wiki Wednesday!

get_messages(all=False, limit=20, offset=0, filter="all")

Gets the messages of the logged in user as an array of Message objects. If the all parameter is specified as True, all the messages are fetched. Otherwise, they are fetched with a limit of limit messages and and offset of offset. If a filter is provided, the messages are filtered with it.

Example:

print(session.get_messages(all=True)[0].actor)
# griffpatch

print(session.get_messages(limit=40, offset=10, filter="comments")[0].comment_fragment)
# thank you my friend

create_cloud_connection(id)

Creates a cloud connection for the specified project ID. Returns a CloudConnection object.

Example:

connection = session.create_cloud_connection(104)

print(connection.get_cloud_variable('foo'))

explore_projects(mode="trending", query)

Explores Scratch projects with the specified mode and query. Returns an array of Project objects.

Example:

print(session.explore_projects()[0].title)
# Epic 7D platformer 2021

explore_studios(mode="trending", query)

Explores Scratch studios with the specified mode and query. Returns an array of Studio objects.

search_projects(mode="popular", query)

Searches Scratch projects with the specified mode and query. Returns an array of Project objects.

search_studios(mode="popular", query)

Searches Scratch studios with the specified mode and query. Returns an array of Studio objects.