User¶
Properties¶
username : str
¶
The username of the user.
Example:
print(session.get_user("you").username)
# you
id : int
¶
The ID of the user.
joined_timestamp : str
¶
An ISO 8601 timestamp representing the date the user joined Scratch.
scratchteam : bool
¶
A bool
representing whether the user is a member of the Scratch Team.
profile : UserProfile
¶
A UserProfile object representing data related to the user's profile.
Example:
print(session.get_user("mres").profile.bio)
# I'm a professor at MIT Media Lab. But more important: I'm one of the people who created Scratch!
Methods¶
get_projects(all=False, limit=20, offset=0)
¶
Gets a list of the user's shared projects. Returns an array of Project objects.
PARAMETERS
- all (
Optional[bool]
) - Whether to retrieve every single project or justlimit
projects. - limit (
Optional[int]
) - How many projects to retrieve ifall
isFalse
. - offset (
Optional[int]
) - The offset of the projects from the newest ones - i.e. an offset of 20 would give you the next 20 projects after the first 20.
RETURNS - list[Project]
Example:
print(session.get_user("griffpatch").get_projects(all=True)[-1].title)
# Pacman HD with full Ghost AI (Scratch 2)
get_curating(all=False, limit=20, offset=0)
¶
Gets a list of studios the user is curating. Returns an array of Studio objects.
PARAMETERS
- all (
Optional[bool]
) - Whether to retrieve every single studio or justlimit
studios. - limit (
Optional[int]
) - How many studios to retrieve ifall
isFalse
. - offset (
Optional[int]
) - The offset of the studios from the newest ones - i.e. an offset of 20 would give you the next 20 studios after the first 20.
RETURNS - list[Studio]
Example:
print(session.get_user("griffpatch").get_studios()[0].title)
# The Scratchnapped Series (The epic adventures of Scratch?)
get_favorites(all=False, limit=20, offset=0)
¶
Gets a list of projects the user has favorited. Returns an array of Project objects.
PARAMETERS
- all (
Optional[bool]
) - Whether to retrieve every single project or justlimit
projects. - limit (
Optional[int]
) - How many projects to retrieve ifall
isFalse
. - offset (
Optional[int]
) - The offset of the projects from the newest ones - i.e. an offset of 20 would give you the next 20 projects after the first 20.
RETURNS - list[Project]
get_followers(all=False, limit=20, offset=0)
¶
Gets a list of users that are following the user. Returns an array of User objects.
PARAMETERS
- all (
Optional[bool]
) - Whether to retrieve every single follower or justlimit
followers. - limit (
Optional[int]
) - How many followers to retrieve ifall
isFalse
. - offset (
Optional[int]
) - The offset of the followers from the newest ones - i.e. an offset of 20 would give you the next 20 followers after the first 20.
RETURNS - list[User]
Example:
print(session.get_user("griffpatch").get_followers()[0].username)
# kaj
get_following(all=False, limit=20, offset=0)
¶
Gets a list of users that the user is following. Returns an array of User objects.
PARAMETERS
- all (
Optional[bool]
) - Whether to retrieve every single user or justlimit
users. - limit (
Optional[int]
) - How many users to retrieve ifall
isFalse
. - offset (
Optional[int]
) - The offset of the users from the newest ones - i.e. an offset of 20 would give you the next 20 users after the first 20.
RETURNS - list[User]
Example:
print(session.get_user("World_Languages").get_following()[0].username)
# RykerJohnson
get_message_count()
¶
Gets the message count of the user. Returns an int
with the user's message count.
Info
Scratch has historically tried to block requests that are trying to retrieve message counts. To prevent weird errors or further restrictions, try to use this sparingly.
RETURNS - int
Example:
print(session.get_user("isthistaken123").get_message_count())
# 90722
post_comment(content, parent_id="", commentee_id="")
¶
Posts a comment on the user's profile. You must be logged in for this to not throw an error.
PARAMETERS
- content (
str
) - The content of the comment to be posted. - parent_id (
Optional[Literal[""] | int]
) - If the comment to be posted is a reply, this is the comment ID of the parent comment. Otherwise, this is an empty string""
. - commentee_id (
Optiona[Literal[""] | int]
) - If the comment to be posted is a reply, this is the user ID of the author of the parent comment. Otherwise, this an empty string""
.
Example:
session.get_user("isthistaken123").post_comment("hello my friend", parent_id=140441449, commentee_id=143585)
session.get_user("griffpatch").post_comment("f4f?!?!?!")
delete_comment(comment_id)
¶
Deletes a comment on the user's profile with the specified comment_id
. You must be logged in, and be the owner of the profile, for this to not throw an error.
PARAMETERS
- comment_id (
int
) - The ID of the comment to be deleted.
report_comment(comment_id)
¶
Reports a comment on the user's profile with the specified comment_id
. You must be logged in for this to not throw an error.
PARAMETERS
- comment_id (
int
) - The ID of the comment to be reported.
report(field)
¶
Reports the user for the reason specified in the field
parameter. You must be logged in for this to not throw an error.
PARAMETERS
- field (
Literal["username"] | Literal["icon"] | Literal["description"] | Literal["working_on"]
) - The section of the user's profile that you are reporting them for. A value of"username"
represents the user's username, a value of"icon"
represents the user's avatar, a value of"description"
represents the "About Me" section of the user's profile, and a value of"working_on"
represents the "What I'm Working On" section of the user's profile.
Example
session.get_user("griffpatch_alt").report("username")
toggle_commenting()
¶
Toggles whether people can post comments on the user's profile. You must be logged in, and the owner of the profile, for this to not throw an error.
Example:
session.user.post_comment("Aight im leaving scratch, unless I can get 4000 followers by tonight im out")
session.user.toggle_commenting()
follow()
¶
Follows the user. You must be logged in for this to not throw an error. Returns a dict
with general data about the user's profile.
RETURNS - dict
Example
session.get_user('griffpatch').follow()
unfollow()
¶
Unfollows the user. You must be logged in for this to not throw an error. Returns a dict
with general data about the user's profile.
RETURNS - dict
Example
griffpatch = session.get_user('griffpatch')
griffpatch.unfollow()
griffpatch.post_comment("I thought we promised we'd do f4f :(")