All Projects → Arinerron → Scratchapi

Arinerron / Scratchapi

Licence: other
A library written in Java for accessing scratch.mit.edu via your Java application...

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Scratchapi

Porcupine
Threading, Resiliency and Monitoring for Java EE 7/8
Stars: ✭ 99 (+1880%)
Mutual labels:  cloud, statistics
Analytics
Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
Stars: ✭ 9,469 (+189280%)
Mutual labels:  cloud, statistics
Terraform
Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
Stars: ✭ 30,477 (+609440%)
Mutual labels:  cloud
Boto3
AWS SDK for Python
Stars: ✭ 6,894 (+137780%)
Mutual labels:  cloud
Openfaas Cloud
The Multi-user OpenFaaS Platform
Stars: ✭ 744 (+14780%)
Mutual labels:  cloud
Orchest
A new kind of IDE for Data Science.
Stars: ✭ 694 (+13780%)
Mutual labels:  cloud
Cpprestsdk
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Stars: ✭ 6,631 (+132520%)
Mutual labels:  cloud
Learn Julia The Hard Way
Learn Julia the hard way!
Stars: ✭ 679 (+13480%)
Mutual labels:  statistics
Chatistics
💬 Python scripts to parse Messenger, Hangouts, WhatsApp and Telegram chat logs into DataFrames.
Stars: ✭ 814 (+16180%)
Mutual labels:  cloud
Aws Shell
An integrated shell for working with the AWS CLI.
Stars: ✭ 6,359 (+127080%)
Mutual labels:  cloud
Spring Cloud Document
Spring Cloud中国社区线下沙龙文档
Stars: ✭ 775 (+15400%)
Mutual labels:  cloud
Vm
💻☁📦 The (official) Nextcloud VM (virtual machine appliance), Home/SME Server and scripts for RPi (4).
Stars: ✭ 716 (+14220%)
Mutual labels:  cloud
Fecon235
Notebooks for financial economics. Keywords: Jupyter notebook pandas Federal Reserve FRED Ferbus GDP CPI PCE inflation unemployment wage income debt Case-Shiller housing asset portfolio equities SPX bonds TIPS rates currency FX euro EUR USD JPY yen XAU gold Brent WTI oil Holt-Winters time-series forecasting statistics econometrics
Stars: ✭ 708 (+14060%)
Mutual labels:  statistics
Statsmodels
Statsmodels: statistical modeling and econometrics in Python
Stars: ✭ 6,935 (+138600%)
Mutual labels:  statistics
Minio
High Performance, Kubernetes Native Object Storage
Stars: ✭ 30,698 (+613860%)
Mutual labels:  cloud
Awesome Serverless
☁️ A curated list of awesome services, solutions and resources for serverless / nobackend applications.
Stars: ✭ 6,654 (+132980%)
Mutual labels:  cloud
Dnsfs
Store your data in others DNS revolvers cache
Stars: ✭ 696 (+13820%)
Mutual labels:  cloud
Statistical Rethinking With Python And Pymc3
Python/PyMC3 port of the examples in " Statistical Rethinking A Bayesian Course with Examples in R and Stan" by Richard McElreath
Stars: ✭ 713 (+14160%)
Mutual labels:  statistics
Rules docker
Rules for building and handling Docker images with Bazel
Stars: ✭ 744 (+14780%)
Mutual labels:  cloud
Awesome Python Data Science
Probably the best curated list of data science software in Python.
Stars: ✭ 812 (+16140%)
Mutual labels:  statistics

Introduction

ScratchAPI is a simple Java interface to the Scratch 2.0 website. It is not nearly done yet, and will later include several features, but it takes time. :P

Build Status Gitter

If you want to see a list of features to be added, click here > https://github.com/Arinerron/ScratchAPI/issues/1 Also, if you're wondering why everything is indented with 8-width tabs, it's because GitHub is being irritating. They are supposed to be 4 spaces.

Documentation

Jump to Section


Session Management

Create a user session and log in:

ScratchSession session = Scratch.createSession("username", "password");

Register a new user (might now work, but it might! Try it out!):

ScratchSession session = Scratch.register("username", "password", "gender", birthMonth, "birthYear", "location", "[email protected]"); // All fields case sensitive-- to be documented better later...

Get information about the session:

String username = session.getUsername();
String csrftoken = session.getCSRFToken();
String expiration = session.getExpiration();
String sessionid = session.getSessionID();
ScratchCloudSession cloudSession = session.getCloudSession(projectid); // Cloud sessions are documented a while down
ScratchUser user = session.you();

Log session out:

session.logout();

Users

Create a user instance:

ScratchUser user = new ScratchUser("username");

Get information about user:

user.update(); // Run this first! It updates the info about the user.
String username = user.getUsername();
String status = user.getStatus();
String bio = user.getBio();
String country = user.getCountry();
Date joinDate = user.getJoinDate();
int messageCount = user.getMessageCount();
List<ScratchProject> favoriteProjects = user.getFavoriteProjects(limit, offset); // limit max 20

Follow and unfollow the user:

user.setFollowing(session, true); // Follow user
user.setFollowing(session, false); // Unfollow user

Comment on user profile:

user.comment(session, "Example comment"); // You can't comment too fast, remember the delay

Projects

Create a project instance:

ScratchProject project = new ScratchProject(projectid); // 'projectid' is an int

Get information about project:

project.update(); // Run this before everything else
String title = project.getTitle();
String description = project.getDescription();
ScratchUser creator = project.getCreator();
int viewCount = project.getViewCount();
int loveCount = project.getLoveCount();
int favoriteCount = project.getFavoriteCount();
int projectid = project.getProjectID();
ScratchProjectManager manager = project.getProjectManager(); // Useless as of now
String resourceurl = project.getResourceURL();
String shareDate = project.getShareDate();
String thumbnailurl = project.getThumbnailURL();

Love and unlove the project:

project.setLoved(session, true); // Love project
project.setLoved(session, false); // Unlove project

Favorite and unfavorite the project:

project.setFavorited(session, true); // Favorite project
project.setFavorited(session, false); // Unfavorite project

Comment on project:

project.comment(session, "Example comment"); // You also can't comment too fast, remember the delay

Cloud Data Management

Create a cloud session:

ScratchCloudSession cloudSession = session.getCloudSession(projectid);

Add and remove a cloud event listener:

ScratchCloudListener listener = new ScratchCloudListener() {
    public void onSet(int projectID, String name, String value) {
        // insert code here...	
    }
    
    // Later TODO add onEnd
}

cloudSession.addCloudListener(listener); // add
cloudSession.removeCloudListener(listener); // remove

Get the cloud symbol (☁):

char cloudSymbol = Scratch.CLOUD;

Get information about cloud session:

int projectid = cloudSession.getProjectID();
ScratchSession session = cloudSession.getScratchSession();
String cloudToken = cloudSession.getCloudToken();

Get a list of cloud variables:

List<String> variables = cloudSession.getVariables();

Get a cloud variable's contents:

String contents = cloudSession.get(Scratch.CLOUD + " variable"); // The space is needed!

Set a cloud variable's contents:

cloudSession.set(Scratch.CLOUD + " variable", "new value"); // Strings should work...

Rename a cloud variable (untested):

cloudSession.rename(Scratch.CLOUD + " variable", Scratch.CLOUD + " new name");

Create a cloud variable (untested):

cloudSession.create(Scratch.CLOUD + " newVariable", "value");

Delete a cloud variable (untested):

cloudSession.delete(Scratch.CLOUD + " variable");

Close the cloud session:

cloudSession.close();

Statistics

Get total project count:

 // Updates every 24hrs (thanks @thisandagain)
 
int totalProjectCount = ScratchStatistics.getProjectCount();
int totalStudioCount = ScratchStatistics.getStudioCount();
int totalUserCount = ScratchStatistics.getUserCount();
int totalCommentCount = ScratchStatistics.getCommentCount();
Date timestamp = ScratchStatistics.getTimestamp(); 

Miscellaneous

Set the default User-Agent:

Scratch.setUserAgent("insert User-Agent here");

Get a list of Scratch users:

List<ScratchUser> users = Scratch.getUsers(limit, offset); // Max limit is 20

Exceptions

List of exceptions:

edu.mit.scratch.exceptions.ScratchException
edu.mit.scratch.exceptions.ScratchLoginException
edu.mit.scratch.exceptions.ScratchUserException
edu.mit.scratch.exceptions.ScratchProjectException
edu.mit.scratch.exceptions.ScratchStatisticalException

Examples

Follow yourself and kaj

new ScratchUser(session.getUsername()).setFollowing(session, true); // Yourself
new ScratchUser("kaj").setFollowing(session, true); // Kaj

Open alert dialog when you get a message

final String user = "griffpatch"; // Change this to your username!
		
Timer timer = new Timer();
timer.schedule(new TimerTask() {
	public ScratchUser target = new ScratchUser(user);
	public int previous = -1;
	
	@Override
	public void run() {
		try {
			int count = target.getMessageCount();
			if(previous == -1) {
				previous = count; // This means the program just started.
			} else 
				if(count > previous) {
					previous = count;
					javax.swing.JOptionPane.showMessageDialog(null, "The account " + user + " on Scratch now has " + count + " messages.");
				}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}, 0, 5 * 1000); // Updates every 5 seconds

Warning: if you are famous, the number of dialogs from your messages will seriously get annoying.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].