Skip to content

Class ScratchUserSession | Subcommands

Dylan Beswick edited this page Apr 10, 2016 · 8 revisions

Subcommands of ScratchUserSession

ScratchUserSession.backpack

Provides a read/write JSON interface with the user's "backpack", a feature of the scratch website.

ScratchUserSession.backpack.get - Get the JSON content the user's backpack.

Arguments: None
Fails: When the server returns a malformed JSON object.

ScratchUserSession.backpack.set - Write to the user's backpack

Arguments:

  • payload [required] - a JSON object to be uploaded.

Fails: When the server returns a malformed JSON object.


ScratchUserSession.cloud

Provides an interface for scratch's "cloud variables" via HTTP polling (see CloudSession for TCP socket interface).

ScratchUserSession.cloud.set_var - Set the value of a cloud variable.

Arguments:

  • var [required] - The name of the variable to be set.
  • value [required] - The value which the var should be set to.
  • projId [required] - The project ID of the project with the var.

Fails: When the session can't acquire a token needed for server validation.

ScratchUserSession.cloud.create_var - Creates a cloud variable.

Arguments:

  • var [required] - The name of the variable to be created.
  • value [required] - The value which the var should be set to.
  • projId [required] - The project ID of the project with the var.

Fails: When the session can't acquire a token needed for server validation.

ScratchUserSession.cloud.get_var - Gets the value of a cloud variable.

Arguments:

  • var [required] - The name of the variable.
  • projId [required] - The project ID of the project with the var.

Fails: When the variable name can't be found

ScratchUserSession.cloud.get_vars - Gets all the cloud variables and their values from a project.

Arguments:

  • projId [required] - The project ID of the project to read the variables from.

Fails: When the server returns a malformed JSON object.


ScratchUserSession.messages

Allows reading of messages and message counts.

ScratchUserSession.messages.get_message_count - Gets the message count of a user.

Arguments:

  • user [optional, defaults to current user] - The user.

Fails: When the server returns a malformed JSON object.

ScratchUserSession.messages.get_message_html - Gets the HTML of the user's messages page.

Arguments: None
Fails: Should not fail.


ScratchUserSession.projects

Functionality for project related API requests.

ScratchUserSession.projects.comment - Comment on a project.

Arguments:

  • projid [required] - The project ID which to comment on.
  • comment [required] - The content of the comment.

Fails: Should not fail.

ScratchUserSession.projects.get - Returns JSON content of a project.

Arguments:

  • projectId [required] - The project ID which to get.

Fails: Fails if project does not exist.

ScratchUserSession.projects.get_meta - Returns information about a project.

Arguments:

  • projid [required] - The project ID which to get.

Fails: Fails if project does not exist.

ScratchUserSession.projects.set - Sets project data.

Arguments:

  • projectId [required] - The project ID which to set.
  • payload [required] - The JSON content of the new project.

Fails: Should not fail.


ScratchUserSession.studios

Functionality for studio related API requests.

ScratchUserSession.studios.comment - Comment on a studio.

Arguments:

  • studioid [required] - The studio ID which to comment on.
  • comment [required] - The content of the comment.

Fails: Should not fail.

ScratchUserSession.studios.get_meta - Returns information about a studio.

Arguments:

  • studioid [required] - The studio ID which to get.

Fails: Fails if studio does not exist.


ScratchUserSession.userpage

APIs for userpage customization, for the logged in user. Functionality for studio related API requests.

ScratchUserSession.userpage.set_bio - Set's the user's biography.

Arguments:

  • payload [required] - Your new bio.

Fails: Should Not Fail

ScratchUserSession.userpage.set_status - Set's the user's status.

Arguments:

  • payload [required] - Your new status.

Fails: Should Not Fail

ScratchUserSession.userpage.toggle_comments - Toggles comments on or off.

Note: Toggling only is available because of the absence of an API to detect if comments are turned on or not.
Arguments: None
Fails: Should Not Fail


Clone this wiki locally