Credit: This project is based on devoxin/anonify with refactoring and adaptation for LavaSrc and general Spotify access token needs.
A simple REST API to generate and cache anonymous Spotify access tokens using Playwright. This project is primarily designed for use as a custom anonymous token endpoint for LavaSrc on Lavalink, but can be used in any application or service that needs a fresh Spotify access token.
Alternative: For a compiled/binary version, you can use accessify-rs — a Rust port of this project.
- Generate anonymous Spotify access tokens (browser automation, Playwright)
- Designed for seamless integration with LavaSrc/Lavalink (
customTokenEndpoint) - Can be used by any service needing a Spotify access token
- Token caching with force refresh support
- Concurrency-safe (Semaphore)
- Fast REST API (Hono framework)
- TypeScript, modular and maintainable structure
- Node.js 18+
- Chromium browser (see below for installation instructions)
npm installInstall Playwright's bundled Chromium automatically:
npx playwright install chromium- Download Chromium
- Download a compatible Chromium build from https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html (choose your OS/arch, e.g. Linux x64).
- Extract the archive and upload the
chrome/chromiumbinary (and its folder) to your Pterodactyl server, e.g./home/container/chrome-linux/chrome. - Set the path in
.env:CHROME_PATH=/home/container/chrome-linux/chrome - Restart your server/container.
If CHROME_PATH is not set, Playwright will use its default browser (if installed).
npm start- GET /spotifytoken
- Returns a cached Spotify access token (auto-refresh if expired)
Example:
curl http://localhost:3000/spotifytokenThis API can be used as a custom anonymous token endpoint for LavaSrc and Lavalink (see LavaSrc PR #286).
Example LavaSrc on Lavalink config:
spotify:
preferAnonymousToken: true
customTokenEndpoint: "http://localhost:3000/spotifytoken"- For deployment on server/CI, make sure Chromium is available:
- Use
npx playwright install chromiumfor most environments. - For Pterodactyl, upload Chromium manually and set
CHROME_PATHin.env.
- Use
- Request logs include IP and user-agent.