Mirror of a WIP clone of the Scratch API and others made in Django
Find a file
2026-01-10 17:12:02 -05:00
_docs
accounts
api
apiclone Add PAGE_STYLE to context processor 2026-01-10 16:46:01 -05:00
assets
files/uploads
galleries
internalapi
lib
news
notifications
projects
projectsAPI
siteapi
static
templates Start work on beta style 2026-01-10 17:12:02 -05:00
uploads
userprofiles
.gitignore
jinxer.py
LICENSE
manage.py
README.md
requirements.sh

APIClone

Work in progress recreation of the main Scratch API, projects API, assets API and uploads API

Requirements

APIClone requires the following to be installed:

  • Python. Only versions 3.12 and 3.13 were tested, but any version from 3.8 to the latest should work in theory.
  • Django. Only versions 4.2 and 5.1 were tested, but any version from 4.0 to the latest one should work in theory.
  • django-cors-headers. For Arch Linux users, there's an AUR package: python-django-cors-headers
  • Pillow. Used for the uploads subdomain.

Optional:

  • PyMemcache. You can disable by deleting the CACHES dictionary from settings.py
  • Memcached (Windows version). Required by PyMemcache, useless without it.
  • Varnish. Varnish isn't actually used by APIClone itself, but it rather wraps around Django and caches everything, effectively avoiding hundreds of possible gateway timeouts while using APIClone on certain lower-end hardware, such as a 2010 laptop, or can be used to just lower the tension on the server.

On Arch Linux, you can run requirements.sh to automatically install every mandatory and optional dependencies. For other distros or operating systems, just use dark magic.

Usage with Scratch-WWW

  1. Clone APIClone and Scratch-WWW:

    git clone https://codeberg.org/heathercat123/apiclone.git
    git clone --depth=1 --single-branch --branch develop https://github.com/scratchfoundation/scratch-www.git
    cd apiclone
    

    You can also use the chipmunk mirror by replacing codeberg.org by code.chipmunk.land if you really want to.

  2. Optional: Start Memcached:

    • On systemd-based Linux distros (which is most of them): sudo systemctl start memcached.
    • On other Linux distros: Read your distribution's manual.
    • On Windows: Execute memcached.exe
  3. Create superuser (admin/ST account): python manage.py createsuperuser Your username has to be lowercase.

  4. Optional: Collect static files: ```python manage.py collectstatic`` This will create the static_prod directory for production environments.

  5. Start APIClone: python manage.py runserver 8080 Tip: If you don't want to use Varnish but you have already built Scratch-WWW configured to the Varnish port, you may want to replace 8080 by 6081.

  6. Switch to another terminal window.

  7. Optional: Start Varnish:

    • On systemd-based Linux distros: sudo systemctl start varnish.
    • On other Linux distros: Read your distrobition's manual (again!).
  8. Install Scratch-WWW's dependencies and translations:

    cd scratch-www
    npm install
    npm run translate
    
  9. Start Scratch-WWW:

    API_HOST=http://localhost:6081/api \
    ASSET_HOST=http://localhost:6081/assets \
    BACKPACK_HOST=http://localhost:6081/backpack \
    PROJECT_HOST=http://localhost:6081/projectshost \
    STATIC_HOST=http://localhost:6081/uploads \
    FALLBACK=http://localhost:6081 \
    npm start
    

    Replace 6081 by 8080 if not using Varnish.

  10. Open http://localhost:8333/admin.

  11. Log in using the superuser created before.

  12. Select Users, then click on your username.

  13. Scroll down and set Full username to the same username as before, but with whatever casing your heart desires (so it doesn't have to be lowercase).

You can now open http://localhost:8333 in a web browser (without /admin!) and enjoy Scratch-WWW with APIClone. Note that many elements of the website are hard-coded whereas they should be modifiable by the user, such as the home page's "What's Happening" box. Quite a few pages and API endpoints are also missing. Both of these are either currently being worked on or this project may randomly have gotten abandoned. I love life.

Standalone usage

TODO: Write this section.
It's basically like with WWW but without the WWW part and you have to set SCRATCHR2_ONLY in /apiclone/local_settings.py.