Discuss Scratch

Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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.

Last edited by Paddle2See (Aug. 10, 2022 17:07:04)

scratchieguy12345678
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

That looks really cool! I'm going to have to try that out!
9gr
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

make bbcode reading possible and ill be happy
Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

9gr wrote:

make bbcode reading possible and ill be happy
What do you mean?
Chiroyce
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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

Last edited by Chiroyce (April 22, 2021 09:15:25)

Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Raihan142857 wrote:

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

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

@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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

bump
Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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

scratchclient - A scratch API wrapper for python

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
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

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

Last edited by Yeetoburro1 (May 19, 2021 03:56:24)

Powered by DjangoBB