Package: scratch2py
Scratch2pyScratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API
Based ofscratchclientbyRaihan142857InstallationRun this in your terminalpipinstallscratch2pypipinstall--force-reinstallwebsocket-client# may be requiredUsageImport scratch2py in like this:fromscratch2pyimportScratch2Pys2py=Scratch2Py('username','password')# Imports s2py and initializes a new s2py object. Enter your Scratch MIT credentials to create a connection with the API.user classuser=s2py.user('username')user.exists()# Checks if a user exists. Returns true or falseuser.getMessagesCount()# Gets the number of messages someone has.user.getMessages()# Gets your messages and returns the JSON.user.getStatus()# Gets the 'about me' section of a users.user.getBio()# Gets the 'What I'm Working On' section of a users profile.user.getProjects()# Gets the projects that a user has.userSession classuser=s2py.userSession('username')# Creates a userSession class.user.followUser()# Follows the user mentioned in the userSession constructor.user.unfollowUser('thatotheruser')# Unfollows the user mentioned in the userSession constructor.user.toggleCommenting()# Toggles commenting on your profile (On/Off)user.postComment('text','parent_id (OPTIONAL','commentee_id (OPTIONAL)'))# Posts a comment on the users profilestudioSession classstudio=s2py.studioSession('sid')studio.inviteCurator('person')# Invites a curator to a studiostudio.addStudioProject('pid')# Adds a project to a studiostudio.postComment('Text','parentid','commentee_id')studio.getComments()# Gets the comments from a studiostudio.follow()# Follows a studiostudio.unfollow()# Unfollows a studioproject classproject=s2py.project('id')project.getStats()# Gets the stats of a project. Returns statistics as JSONproject.getComments()# Gets the comments of a projectproject.getInfo()# Gets the info of a projectproject.fetchAssets(type='img/snd')# Fetches assets of a project. Type is img by default, can be img or snd. snd will fetch sound files from the project.projectSession classproject=s2py.projectSession('id')# Starts a project session to the specific projectproject.share()# Shares a projectproject.unshare()# Unshares a projectproject.favorite()# Favorites a projectproject.unfavorite()# Unfavorites a projectproject.love()# Loves a projectproject.unlove()# Unloves a projectproject.remix()# Remixes a projectscratchConnect ClassUsing the module for cloud on scratch.cloudproject=s2py.scratchConnect('Project_Id')# Creates a new connection to a Scratch project.cloudproject.setCloudVar('CloudVar','Value')# Sets a value to a cloud variable. Don't add the cloud symbol.cloudproject.readCloudVar('variable name','Limit(optional)')# Gets the value of a cloud variable. Limit is when the program should stop looking for the value. Limit is 1000 by default.turbowarpConnect classturbowarp=s2py.turbowarpConnect('project_id')#  Creates a new connection to a Turbowarp project.turbowarp.setCloudVar('CloudVar','Value')# Sets a value to a cloud variable. Don't add the cloud symbol.turbowarp.readTurbowarpVar('variable name')# Gets the value of a cloud variable.cloudDatabase classdb=s2py.cloudDatabase('Project id')# Creates a new database that will detect messages on a certain project iddb.startLoop()# Starts a new loop for the database.Referherefor more infoEncode/decode functionss2py.encode('value')# Encodes a value. Scratch version available on my Scratch profiles2py.decode('value')# Decodes a value. To be used to communicate to and from a Scratch project.The EndThat's it!
Contact my on myScratch profile