Discuss Scratch

kajtolmation
Scratcher
100+ posts

ScratchGonnect: A Scratch API wrapper for Go

Send Scratch API requests with ease.

ScratchGonnect is a Scratch API wrapper written in Go and allows you to easily and quickly interface with the Scratch API. It allows you to post comments, change project data and much more.

Documentation - Source Code

> What can it do?

  • Easily log into new sessions and access user specific data

  • Simplified access to the Scratch API (ability to easily add projects to a studio, post comments and more)

  • Interface with Turbowarp cloud variables (lets you set variables and listen to variable changes)

> How to install?


Get ScratchGonnect by running this command in your terminal:
go get github.com/kejjtoli/ScratchGonnect@latest

You may need to initialize go.mod first if you haven't done that:
go mod init packagename

> Example use


Creating a new session (lets you use features that require logging in)
// Log into a scratch session
session := scratchgonnect.NewSession("username", "pass")

Posting a comment under a project
// Get a project by id
project := scratchgonnect.GetProject("535962801")
// Post comment with given content, parent_id, commentee_id
project.PostComment(*session, "Comment Content", "", "")

Following a user and getting a list of followers
// Get a user by username
user := scratchgonnect.GetUser("kajtolmation")
// Follow user
user.Follow(*session)
// Get array of user objects
followers := user.GetFollowers()

Connect to Turowarp cloud (lets you interface with Turbowarp cloud variables)
// Connect to turbowarp websocket
cloud := scratchgonnect.ConnectTurbowarpCloud("username", "1121839236")

Set a variable and listen to any value changes
// Sets the value of a cloud variable
cloud.SetVariable("t1", 314)
// Listens to all set variable messages
cloud.Listen(cloud_listener)
// Prints out name and new value of changed variable
func cloud_listener(connection *scratchgonnect.CloudSocket, variable_name string, value int) {
	fmt.Println(variable_name, value)
}
More examples

> Future ideas & support


I'm open to answering any questions about ScratchGonnect under this thread. Any feature requests are more than welcome as well!

Sadly due to recent cloud variable instability I was unable to properly add cloud support to this package but it's certainly high on my priority list for future things to add.

Last edited by kajtolmation (Jan. 19, 2025 13:58:16)

Redstone1080
Scratcher
1000+ posts

ScratchGonnect: A Scratch API wrapper for Go

FINALLY something other than Python. Props to you!
kRxZy_kRxZy
Scratcher
1000+ posts

ScratchGonnect: A Scratch API wrapper for Go

Nice!
BartoloPL
Scratcher
39 posts

ScratchGonnect: A Scratch API wrapper for Go

This is AMAZING. :D @kajtolmation is a master.
susak-pospolity
New Scratcher
2 posts

ScratchGonnect: A Scratch API wrapper for Go

You are a genius @kajtolmation !!!

Powered by DjangoBB