Example of how to create your own automated Twitter account that tweets tracks from a Spotify playlist.
Example of how to create an automated Twitter account that tweets tracks from a Spotify playlist.
First clone this repo and run npm install
.
You'll need to sign up for both Twitter and Spotify developer accounts and then paste your credentials into a local .env
file following .env.example.
# app credentials
PROVIDER_SPOTIFY_CLIENT_ID=
PROVIDER_SPOTIFY_CLIENT_SECRET=
PROVIDER_SPOTIFY_REDIRECT_URI=
PROVIDER_TWITTER_CLIENT_ID=
PROVIDER_TWITTER_CLIENT_SECRET=
# user credentials
SPOTIFY_USER_ACCESS_TOKEN=
SPOTIFY_USER_REFRESH_TOKEN=
TWITTER_USER_ACCESS_TOKEN=
TWITTER_USER_ACCESS_TOKEN_SECRET=
# automation settings
# URL or ID of spotify playlist to pull tracks from
# example: https://open.spotify.com/playlist/2MgkBl2rQnPdF3WZ6ciajc?si=gF7XkYJLRBWo8lxoMKmySA
SPOTIFY_PLAYLIST=
Then, just run node index.js
.
This will pick a random track from the given Spotify playlist and tweet it from your account, adding a bit of text and a few random hashtags as well.
If you want to automate your account to tweet on a regular schedule, check out cron or a hosted cron solution like Simple Cron.
Here's an (example ambient playlist) if you'd like to get started.
Purely for fun: LofiGrind. 🤓
I was inspired by lofi DJs like ChilledCow who have created large followings by curating fresh music on a regular basis across YouTube, Twitter, Spotify, etc.
MIT © Travis Fischer
Support my OSS work by following me on twitter