Skip to content
Top Dog edited this page Apr 5, 2019 · 42 revisions

Usage

new Client(auth, debug)
  • Auth Object containing authentication information. (Object)
    • username Username of the user to login to. (String)
    • password Password of the user to login to. (String)
  • Debug Function to log debugging information to. (Function)

Properties

auth

An object containing authentication information (Object)

  • username The username that was used to login. (String)
  • password The password that was used to login (String)

debug

Function to log debug information. (Function)

session

The login session of the user in the client. (Session)

Methods

login

Create session and access token to make authorized requests. Returns Promise<>

Client.login().then(() => {

});

getProject(project)

Get project from a project id. Returns Promise<Project>

Client.getProject(10128407).then(project => {
  console.log("The project " + project.title + " was made by " + project.author.username);
});

/*
The project Paper Minecraft v11.3 (Minecraft 2D) was made by griffpatch
*/

getProjectCount()

Get the amount of projects on scratch. Returns Promise<Number>

Client.getProjectCount().then(count => {
  console.log("There are currently " + count + " projects on scratch");
});

/*
There are currently 40128703 projects on scratch
*/

getUser(user)

Get user information from a username. Returns Promise<User>

Client.getUser("WO997").then(user => {
  console.log("The user " + user.username + " is working on \n" + user.profile.status);
});

/*
The user WO997 is working on
Babylon.js, Android Studio
and Hill Climb Racing 3 - last scratch project

with @r2dav2 &@snow-cannon

If you're interested in starting working with 3D
https://scratch.mit.edu/projects/41231380/
*/

getNews()

Get current scratch news. Returns Promise<Array<News>>

Client.getNews().then(news => {
  console.log("The latest scratch news: " + news[0].title + "\n" + news[0].description);
});

/*
The latest scratch news: New Scratch Design Studio!
Create a project about a day in the life of something! This can be an animal, an object, a sup
erhero- anything you can imagine…
*/
Clone this wiki locally