Scratch public API proxy server (MIT). Provides extended user information and additional filters on basic functions, such as searching for projects and studios, plus exclusive indexing queries and a custom feed from your qualified followers.
Created by KrisbelGV as part of the educational and learning project "Scarlet's Basement" available on the Scarlet's Basement Website.
- π Extended search - Search projects and studios with additional filters (mode, profiles, discard terms)
- π€ User statistics - Get detailed summaries for any Scratch user
- π Studio finder - Locate studios by project ID and tags
- π Indexing status - Check speculative indexing status of a project
- π₯ Custom feed - Curated following feed from qualified followers
- β‘ Rate limiting & circuit breaker - Protects Scratch API from overuse
| Category | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express |
| Cache | Upstash Redis |
| Deploy | Vercel |
| API Source | Scratch Public API |
-
Clone this repository
git clone https://github.com/KrisbelGV/scarlets_basement-proxy.git cd scarlets_basement-proxy -
Ensure you have Node.js 18 or higher
node --version # Should be v18.x or higher -
Install the project dependencies
npm install
-
Create a
.envfile in the project rootNODE_ENV=development PORT=300
-
Run the development server
npm run dev
scarlets-basement-proxy/
β
βββ api/
β βββ index.js
β
βββ src/
β βββ controllers/
β β βββ aNewView.js
β β βββ findAStudio.js
β β βββ isItIndex.js
β β βββ search.js
β β βββ userData.js
β β
β βββ middleware/
β β βββ doorman.js
β β βββ errorHandler.js
β β βββ validator.js
β β
β βββ routes/
β β βββ proxy.js
β β
β βββ services/
β β βββ filterService.js
β β βββ proxyService.js
β β
β βββ utils/
β βββ catchAsync.js
β βββ createAbortController.js
β βββ upstash.js
β
βββ package.json
βββ package-lock.json
βββ vercel.json
| Layer | Archive | Function |
|---|---|---|
| Entry point | api/index.js | Configure Express, CORS, set up routes |
| Routes | src/routes/proxy.js | Define endpoints and middleware chain |
| Middleware | src/middleware/doorman.js | Rate limiting, processing blocking, and circuit breaker |
| Middleware | src/middleware/validator.js | Input validation and sanitization |
| Middleware | src/middleware/errorHandler.js | Translates errors to HTTP responses |
| Controllers | src/controllers/*.js | They orchestrate the business logic |
| Services | src/services/filterService.js | Search, filter, statistics count |
| Services | src/services/proxyService.js | HTTPS client to Scratch |
| Utilities | src/utils/upstash.js | Lua scripts for Redis |
| Utilities | src/utils/catchAsync.js | Try/catch for async/await |
| Utilities | src/utils/createAbortController.js | Timeout for long operations |
Key technical decisionsβand why certain approaches were rejected.
Using a third-party proxy to bypass CORS and filter on the browser was rejected due to privacy concerns. A browser-based solution would expose user requests and filtering patterns to external servers, whereas a server-side proxy keeps all processing under the project's control.
A queuing mechanism was prototyped to handle concurrent requests, but it produced an unacceptable error rate due to network latency and inter-service communication issues. It degraded user experience and consumed unnecessary resources, so it was removed.
The idea of adding mirrored endpoints to resume pagination after timeout limits was considered but rejected to preserve resources for diverse, non-exhaustive queries. The current five endpoints are sufficient, though this could be reconsidered based on user feedback.
The proxy focuses on lightweight, stateless filtering with rate limiting and a circuit breaker to protect the Scratch API. All decisions prioritize reliability, privacy, and fair access for all users.
π‘ Open to collaboration β We remain open to working with external providers to reduce Scratch API load and develop new features, provided privacy standards are met.
All endpoints return a boolean abort field:
falseβ Complete result from Scratch APItrueβ Incomplete result (processing timeout or partial data)
Access policy: This API implements CORS restrictions and is only accessible from domains associated with KrisbelGV's GitHub repositories and the official Scarlet's Basement Website. You may test the API for educational or development purposes (console, browser, curl, Postman, etc.), but use in external projects is not open for discussion. Resources are limited and must be reserved to guarantee the proper functioning of this service.
Returns a summary of statistics for a given user.
| Parameter | Type | Required | Description |
|---|---|---|---|
:username |
path | β | Scratch username |
General search or profile-filtered search.
| Parameter | Type | Required | Description |
|---|---|---|---|
q |
query | β | Search terms |
mode |
query | β | Results order. Only trending accepted; popular is default |
username |
query | β | Specifies a user for the query |
profile |
query | β | Uses projects of specified profile(s) instead of general search |
discard |
query | β | Terms to exclude from results |
Returns studios associated with the given project ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
:projectid |
path | β | Scratch project ID |
tag |
query | β | Filter by tag (without # symbol) |
Returns project statistics and speculative indexing status.
| Parameter | Type | Required | Description |
|---|---|---|---|
:projectid |
path | β | Scratch project ID |
Returns a custom following feed for the given user.
| Parameter | Type | Required | Description |
|---|---|---|---|
:username |
path | β | Scratch username |
This project is licensed under the MIT License. See the LICENSE file in this repository for the full terms.
Contributions to the codebase are welcome! As an open-source educational project, we appreciate improvements, bug fixes, and documentation enhancements.
- Fork the repository
- Create a feature branch (
git checkout -b feat/feature) - Commit your changes (
git commit -m 'Add feature') - Push to the branch (
git push origin feat/feature) - Open a Pull Request
- After your PR is reviewed and merged by the maintainer, it will be automatically deployed
Note for contributors: Deployments are handled via GitHub Actions. All changes must go through a Pull Request. Direct pushes to
mainare protected and will be rejected.
For detailed tracking of bug fixes or updates, follow our news thread in the Scratch discussion forum.
