Python to Scratch API connector
Project description
Scratch2py
Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857
Installation
Run this command in your terminal as ONE command.
pip install scratch2py && pip uninstall websocket-client & pip install websocket-client
Usage
Import scratch2py in like this:
from scratch2py import Scratch2Py
s2py = Scratch2Py('username', 'password')
# Imports s2py and initializes a new s2py object. Enter your Scratch MIT credentials to create a connection with the API.
user class
user = s2py.user('username')
user.exists()
# Checks if a user exists. Returns true or false
user.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 class
user = s2py.userSession('username')
user.followUser('otheruser')
# Follows a user
user.unfollowUser('thatotheruser')
# Unfollows a user
user.toggleCommenting()
# Toggles commenting on your profile (On/Off)
studioSession class
studio = s2py.studioSession('sid')
studio.inviteCurator('person')
# Invites a curator to a studio
studio.addStudioProject('pid')
# Adds a project to a studio
studio.postComment('Text', 'parentid', 'commentee_id')
studio.getComments()
# Gets the comments from a studio
studio.follow()
# Follows a studio
studio.unfollow()
# Unfollows a studio
project class
project = s2py.project('id')
project.getStats('loves/faves/remixes/views')
# Gets the stats of a project
project.getComments()
# Gets the comments of a project
project.getInfo()
# Gets the info of a project
projectSession class
project = s2py.projectSession('id')
# Starts a project session to the specific project
project.share()
# Shares a project
project.unshare()
# Unshares a project
project.favorite()
# Favorites a project
project.unfavorite()
# Unfavorites a project
project.love()
# Loves a project
project.unlove()
# Unloves a project
scratchConnect Class
Using 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 class
turbowarp = 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 class
db = s2py.cloudDatabase('Project id')
# Creates a new database that will detect messages on a certain project id
db.startLoop()
# Starts a new loop for the database.
Refer [here](https://scratch.mit.edu/projects/574609423/) for more info
Encode/decode functions
s2py.encode('value')
# Encodes a value. Scratch version available on my Scratch profile
s2py.decode('value')
# Decodes a value. To be used to communicate to and from a Scratch project.
The End
That's it! Contact my on my Scratch profile
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
scratch2py-0.5.0.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file scratch2py-0.5.0.tar.gz
.
File metadata
- Download URL: scratch2py-0.5.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5f2d17eeed6613102c45dc259a2370844c05af6df4d5dd76d8513a260ab8496 |
|
MD5 | c7d29b1653a41658bd0613ccd3abac39 |
|
BLAKE2b-256 | 9e2ca386544d9db4f1ff1451a616fe9a96a632262270eb8aed3b3f99a4c999c9 |
File details
Details for the file scratch2py-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: scratch2py-0.5.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b82a0591385f831cde71c9d4165b9ca716bdb8d6ff6edeb524f490658a964716 |
|
MD5 | 41f6f39049f4c497bc6f42517fe46150 |
|
BLAKE2b-256 | 326d22f884b2197022d6513323a8d2a2710ed51f413c071c6047864e52ada7ce |