Raihan142857

A few days ago I noticed there was no easy way to mess with scratch's API in Python so I created a python module to do this. https://pypi.org/project/scratchclient/

You can install it using
pip install scratchclient

Thanks to this npm package for the reference code and ilcheese2 for their modified version of my cloud code.

You can report issues on the (email removed by moderator - please don't share contact information) this topic, or my scratch profile.

Usage:
Basic usage:
from scratchclient import ScratchSession
session = ScratchSession("ceebee", "--uwu--")
# post comments
session.get_user("Paddle2See").post_comment("OwO")
# lots of other stuff
print(session.get_project(450216269).get_comments()[0].content)
print(session.get_studio(29251822).description)
Cloud connection:
from scratchclient import ScratchSession
session = ScratchSession("griffpatch", "SecurePassword7")
connection = session.create_cloud_connection(450216269)
connection.set_cloud_variable("variable name", 5000)
@connection.on("set")
def on_set(variable):
    print(variable.name, variable.value)
print(connection.get_cloud_variable("other variable"))

I havent made documentation yet because I'm lazy so feel free to ask questions in this topic.

scratchieguy12345678

That looks really cool! I'm going to have to try that out!

9gr

make bbcode reading possible and ill be happy

Raihan142857

9gr wrote:

make bbcode reading possible and ill be happy
What do you mean?

Chiroyce

Raihan142857 wrote:

What do you mean?
basically it takes raw BBCODE data from the api like this

 [color=red] nono word [/color]
and will show it like this
nono word

Raihan142857

Chiroyce wrote:

Raihan142857 wrote:

What do you mean?
basically it takes raw BBCODE data from the api like this

 [color=red] nono word [/color]
and will show it like this
nono word
There's no API for the forums… I guess I can implement ScratchDB but that sort of defeats the purpose…

Chiroyce

Raihan142857 wrote:

There's no API for the forums…
what I meant was getting posts using a get request

Raihan142857

Chiroyce wrote:

Raihan142857 wrote:

There's no API for the forums…
what I meant was getting posts using a get request
You mean webscraping?

9gr

Raihan142857 wrote:

Chiroyce wrote:

Raihan142857 wrote:

There's no API for the forums…
what I meant was getting posts using a get request
You mean webscraping?
no
GET scratch.mit.edu/discuss/post/postid/source

Raihan142857

9gr wrote:

Raihan142857 wrote:

Chiroyce wrote:

Raihan142857 wrote:

There's no API for the forums…
what I meant was getting posts using a get request
You mean webscraping?
no
GET scratch.mit.edu/discuss/post/postid/source
Oop, apparently I was wrong. I'll add it the next time I update it.

PikachuB2005

@Raihan142857 Can you include a list of ALL of the functions?

BTW I have my own github repo for interacting with scratch's api, but I would like to try yours. I made this thing with mine.

Raihan142857

PikachuB2005 wrote:

@Raihan142857 Can you include a list of ALL of the functions?

BTW I have my own github repo for interacting with scratch's api, but I would like to try yours. I made this thing with mine.
I'm going to add documentation later.

9gr

Raihan142857 wrote:

PikachuB2005 wrote:

@Raihan142857 Can you include a list of ALL of the functions?

BTW I have my own github repo for interacting with scratch's api, but I would like to try yours. I made this thing with mine.
I'm going to add documentation later.
Imma use your code for the new api docs I'm making

Raihan142857

bump

Raihan142857

is anyone willing to help me write docs? there's a lot of stuff I need to document and help would be appreciated

silvxrcat

Raihan142857 wrote:

is anyone willing to help me write docs? there's a lot of stuff I need to document and help would be appreciated
sure i'll help, i know basic md

scratchieguy12345678

Raihan142857 wrote:

is anyone willing to help me write docs? there's a lot of stuff I need to document and help would be appreciated

I'll help, I've already looked at the code and I understand it well.

9gr

Raihan142857 wrote:

is anyone willing to help me write docs? there's a lot of stuff I need to document and help would be appreciated
mkdocs please

Raihan142857

9gr wrote:

Raihan142857 wrote:

is anyone willing to help me write docs? there's a lot of stuff I need to document and help would be appreciated
mkdocs please
I'm just gonna put it on the wiki for the gh repo

Yeetoburro1

Hi, for some reason connecting to a project is taking infinitely long for me, wondering if this is a common issue or..
edit: king of the page hahaaha