npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scratchlib

v0.4.0

Published

A powerful NPM module/library to interact with the Scratch API

Downloads

86

Readme

Table of contents

About

ScratchLib is a powerful Node.JS module to work with the Scratch API. It provides many methods and properties you never heard of, and does requests for you.

Installation

NPM

Open a terminal, and enter the following command: npm install scratchlib

How to use

Start by requiring the module.

const Scratchlib = require("scratchlib");

:tada: Congrats - you can now access to the many properties this module offers!

Documentation

In order to use a method, you must choose between creating an async function or by adding a callback with .then().

async function():

async function test() {
    try {
	    let info = await ScratchLib.getStatus();
	    console.log(info);
    } catch (err) {
        console.error(err);
    }
}

test();

.then() callback:

ScratchLib.getStatus().then(info => {
	console.log(info);
}).catch(err => {
	console.error(err);
});

Both equals to:

{
  version: '1d96065a1ea1d017949e2bd8e179762744d231f0',
  uptime: 1013664,
  load: [ 0.1611328125, 0.134765625, 0.09619140625 ],
  sql: { ssl: true, min: 0, max: 40 },
  cache: { connected: true, ready: true }
}

:warning: Don't forget to catch the promise.

ScratchLib.getUserFollowers().then(info => {
	console.log(info);
}).catch(err => {
	console.error(err);
});
Output: Parameter of type string is missing!

Methods

getFeatured() - Returns information regarding the projects currently visible on the front page of the website. getNews() - Returns information regarding the "Scratch News" section of the homepage. getProfile(username: string) - Returns information about the specified user. getProject(id: string) - Returns information relevant to the given project. getProjectsCount() - Returns the total number of shared projects on the Scratch website. getRoot() - The root of the api interface provides basic information regarding the API and the Scratch website. getStatus() - Used to return the status of the Scratch website. (really? :P) getUserFavorites(username: string) - Returns an array of details regarding the projects that a given user has favourited on the website. getUserFollowers(username: string) - Returns a list of a user's most recent followers. getUserFollowing(username: string) - Returns a list of the users that the specified user has most recently followed. getUserMessages(username: string) - This returns the number of unread messages a user currently has. getUserProjects(username: string) - Returns an array with information regarding the projects that a given user has shared on the Scratch website.

:warning: The following methods are returning JSON data.

TypeScript

:bulb: This module can be used with TypeScript! It even provides quality types that can be auto-completed from Visual Studio Code, or any editor that supports IntelliSense/autocompletion.

Web

:globe_with_meridians: This library can also be used on the Web! You'll need help from browserify though.

CORS

If you use this module in the browser, you'll probably encounter a problem: CORS, which means 'Cross-origin resource sharing'. Thanks to @locness3 (#3), this library now supports proxies. You just have to specify a parameter, which must be equal to your proxy URL as follows: http://host:port.

ScratchLib.getFeatured("http://localhost:8080").then(info => {
	console.log(info);
}).catch(err => {
	console.error(err);
});

Contributing

You can contribute to this project by doing a PR :heart:

Help

Do you need help? Create an issue!