Top Related Projects
Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk
Python library that makes it easy for data scientists to create charts.
Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.
A client-side JS wrapper for the Spotify Web API
A Node.js wrapper for Spotify's Web API.
Quick Overview
Your Spotify is an open-source project that allows users to create a personal website displaying their Spotify listening statistics. It provides a self-hosted alternative to services like Spotify Wrapped, offering continuous access to listening data and customizable visualizations.
Pros
- Self-hosted solution, giving users full control over their data
- Continuous access to listening statistics, not limited to yearly summaries
- Customizable interface and visualizations
- Integrates with Spotify API for real-time data updates
Cons
- Requires technical knowledge to set up and maintain
- Limited to Spotify data only, not compatible with other music streaming services
- May require regular updates to maintain compatibility with Spotify API changes
- Potential for increased server costs if hosting a large number of users
Getting Started
-
Clone the repository:
git clone https://github.com/Yooooomi/your_spotify.git
-
Install dependencies:
cd your_spotify npm install
-
Set up environment variables:
cp .env.example .env
Edit the
.env
file with your Spotify API credentials and database information. -
Start the application:
npm run dev
-
Access the application at
http://localhost:3000
and follow the on-screen instructions to connect your Spotify account.
Competitor Comparisons
Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk
Pros of annoy
- Highly optimized C++ implementation for fast approximate nearest neighbor search
- Supports multiple distance metrics (Euclidean, Manhattan, etc.)
- Can be used for various applications beyond music recommendations
Cons of annoy
- Requires more technical expertise to implement and integrate
- Limited to nearest neighbor search functionality
- Not specifically tailored for Spotify data analysis
Code comparison
annoy:
AnnoyIndex<int, float, Euclidean, Kiss32Random> index(f);
index.add_item(0, v0);
index.add_item(1, v1);
index.build(10); // 10 trees
your_spotify:
const stats = await spotify.getStats(user);
const topArtists = await spotify.getTopArtists(user);
const topTracks = await spotify.getTopTracks(user);
Summary
annoy is a powerful library for approximate nearest neighbor search, offering high performance and flexibility. However, it requires more technical knowledge to implement and is not specifically designed for Spotify data analysis.
your_spotify, on the other hand, is a dedicated tool for analyzing personal Spotify data, providing easy-to-use functions for retrieving user statistics, top artists, and tracks. It's more accessible for users looking to analyze their Spotify listening habits but lacks the broader applicability of annoy.
The choice between these repositories depends on the specific use case and the user's technical expertise.
Python library that makes it easy for data scientists to create charts.
Pros of chartify
- Developed and maintained by Spotify, ensuring high-quality and up-to-date integration with Spotify's API
- Focuses on data visualization and chart creation, providing powerful tools for analyzing music data
- Offers a wide range of chart types and customization options for in-depth data analysis
Cons of chartify
- Requires more technical knowledge and programming skills to use effectively
- Limited to data visualization and analysis, lacking features for personal music tracking or recommendations
- May have a steeper learning curve for users not familiar with data science libraries
Code comparison
chartify:
import chartify
# Create a chart
ch = chartify.Chart(blank_labels=True, x_axis_type='datetime')
ch.plot.scatter(
data_frame=df,
x_column='date',
y_column='streams'
)
ch.show()
your_spotify:
import React from 'react';
import { TopTracks } from '../components/TopTracks';
const TopTracksPage = () => {
return <TopTracks />;
};
export default TopTracksPage;
The code snippets highlight the different focus areas of the two projects. chartify emphasizes data visualization and chart creation, while your_spotify is more centered on creating a user interface for displaying Spotify data.
Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.
Pros of luigi
- More comprehensive and feature-rich data pipeline tool
- Supports a wide range of data processing tasks beyond just Spotify data
- Larger community and more extensive documentation
Cons of luigi
- Steeper learning curve due to its complexity
- Requires more setup and configuration
- Not specifically tailored for Spotify data analysis
Code comparison
luigi:
import luigi
class SpotifyTask(luigi.Task):
def requires(self):
return SomeOtherTask()
def run(self):
# Process Spotify data
pass
your_spotify:
import { getListeningHistory } from './spotify';
async function processData() {
const history = await getListeningHistory();
// Analyze Spotify data
}
Key differences
- luigi is a Python-based data pipeline tool, while your_spotify is a JavaScript project
- luigi offers a more structured approach to data processing with task dependencies
- your_spotify is specifically designed for personal Spotify data analysis
- luigi requires more boilerplate code but provides greater flexibility
- your_spotify offers a simpler setup for quick Spotify data insights
Use cases
luigi is better suited for:
- Complex data workflows involving multiple data sources
- Large-scale data processing tasks
- Integration with other data analysis tools
your_spotify is ideal for:
- Personal Spotify listening history analysis
- Quick setup and visualization of Spotify data
- Users who prefer working with JavaScript and web technologies
A client-side JS wrapper for the Spotify Web API
Pros of spotify-web-api-js
- Comprehensive API coverage: Provides a wrapper for most Spotify Web API endpoints
- Well-documented: Extensive documentation and examples for easy integration
- Lightweight: Focused solely on API interactions, keeping the library small and efficient
Cons of spotify-web-api-js
- Limited functionality: Focuses only on API interactions, lacking data visualization or analysis features
- No built-in authentication: Requires separate implementation of Spotify authentication flow
- Less user-friendly for non-developers: Requires more technical knowledge to set up and use effectively
Code Comparison
spotify-web-api-js:
var spotifyApi = new SpotifyWebApi();
spotifyApi.setAccessToken('<access_token>');
spotifyApi.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE').then(
function(data) {
console.log('Artist albums', data);
},
function(err) {
console.error(err);
}
);
your_spotify:
// No direct API wrapper available
// Focuses on data visualization and analysis
// Example code not applicable for direct comparison
your_spotify is more focused on providing a complete solution for visualizing and analyzing Spotify listening data, while spotify-web-api-js is a lightweight wrapper for interacting with the Spotify Web API. The choice between the two depends on the specific needs of the project and the developer's expertise.
A Node.js wrapper for Spotify's Web API.
Pros of spotify-web-api-node
- More comprehensive API coverage, providing access to a wider range of Spotify features
- Better documentation and examples, making it easier for developers to get started
- Actively maintained with regular updates and bug fixes
Cons of spotify-web-api-node
- Requires more setup and configuration compared to your_spotify
- May be overkill for simple projects that only need basic Spotify functionality
- Steeper learning curve due to its extensive feature set
Code Comparison
spotify-web-api-node:
const SpotifyWebApi = require('spotify-web-api-node');
const spotifyApi = new SpotifyWebApi({
clientId: 'your-client-id',
clientSecret: 'your-client-secret'
});
spotifyApi.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE').then(
function(data) {
console.log('Artist albums', data.body);
},
function(err) {
console.error(err);
}
);
your_spotify:
import { Spotify } from 'your_spotify';
const spotify = new Spotify({
clientId: 'your-client-id',
clientSecret: 'your-client-secret'
});
spotify.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE')
.then(albums => console.log('Artist albums', albums))
.catch(err => console.error(err));
Both libraries provide similar functionality, but spotify-web-api-node offers a more extensive API with additional methods and options. your_spotify has a simpler interface, which may be preferable for smaller projects or developers new to working with the Spotify API.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Your Spotify
YourSpotify is a self-hosted application that tracks what you listen and offers you a dashboard to explore statistics about it! It's composed of a web server which polls the Spotify API every now and then and a web application on which you can explore your statistics.
Table of contents
- Prerequisites
- Installation
- Creating the Spotify application
- Importing past history
- FAQ
- External guides
- Contributing
- Sponsoring
Prerequisites
- You have to own a Spotify application ID that you can create through their dashboard.
- You need to provide the Server environment the public AND secret key of the application (cf. Installation).
- You need to provide an authorized redirect URI to the
docker-compose
file.
A tutorial is available at the end of this readme.
Installation
Using docker-compose
Follow the docker-compose-example.yml to host your application through docker.
services:
server:
image: yooooomi/your_spotify_server
restart: always
ports:
- "8080:8080"
links:
- mongo
depends_on:
- mongo
environment:
API_ENDPOINT: http://localhost:8080 # This MUST be included as a valid URL in the spotify dashboard (see below)
CLIENT_ENDPOINT: http://localhost:3000
SPOTIFY_PUBLIC: __your_spotify_client_id__
SPOTIFY_SECRET: __your_spotify_secret__
mongo:
container_name: mongo
image: mongo:6
volumes:
- ./your_spotify_db:/data/db
web:
image: yooooomi/your_spotify_client
restart: always
ports:
- "3000:3000"
environment:
API_ENDPOINT: http://localhost:8080
Some ARM-based devices might have trouble with Mongo >= 5. I suggest you use the image mongo:4.4.
Installing locally (not recommended)
You can follow the instructions here. Note that you will still have to do the steps below.
Environment
Key | Default value (if any) | Description |
---|---|---|
CLIENT_ENDPOINT | REQUIRED | The endpoint of your web application |
API_ENDPOINT | REQUIRED | The endpoint of your server |
SPOTIFY_PUBLIC | REQUIRED | The public key of your Spotify application (cf Creating the Spotify Application) |
SPOTIFY_SECRET | REQUIRED | The secret key of your Spotify application (cf Creating the Spotify Application) |
TIMEZONE | Europe/Paris | The timezone of your stats, only affects read requests since data is saved with UTC time |
MONGO_ENDPOINT | mongodb://mongo:27017/your_spotify | The endpoint of the Mongo database, where mongo is the name of your service in the compose file |
LOG_LEVEL | info | The log level, debug is useful if you encouter any bugs |
CORS | not defined | List of comma-separated origin allowed (defaults to CLIENT_ENDPOINT) |
COOKIE_VALIDITY_MS | 1h | Validity time of the authentication cookie, following this pattern |
MAX_IMPORT_CACHE_SIZE | Infinite | The maximum element in the cache when importing data from an outside source, more cache means less requests to Spotify, resulting in faster imports |
MONGO_NO_ADMIN_RIGHTS | false | Do not ask for admin right on the Mongo database |
PORT | 8080 | The port of the server, do not modify if you're using docker |
FRAME_ANCESTORS | not defined | Sites allowed to frame the website, comma separated list of URLs (i-want-a-security-vulnerability-and-want-to-allow-all-frame-ancestors to allow every website) |
CORS
- Not defining it will default to authorize only the
CLIENT_ENDPOINT
origin. origin1,origin2
will alloworigin1
andorigin2
.
If you really want to allow every origin no matter what, you can set the
CORS
value toi-want-a-security-vulnerability-and-want-to-allow-all-origins
.
Creating the Spotify Application
For YourSpotify to work you need to provide a Spotify application public AND secret to the server environment. To do so, you need to create a Spotify application here.
- Click on Create app.
- Fill out all the information.
- Set the redirect URI, corresponding to your server location on the internet (or your local network) adding the suffix /oauth/spotify/callback (/api/oauth/spotify/callback if using the linuxserver image).
- i.e:
http://localhost:8080/oauth/spotify/callback
orhttp://home.mydomain.com/your_spotify_backend/oauth/spotify/callback
- Check Web API
- Check I understand and agree
- Hit Settings at the top right corner
- Copy the public and the secret key into your
docker-compose
file under the name ofSPOTIFY_PUBLIC
andSPOTIFY_SECRET
respectively. - Once you have created your application, Spotify wants you to register the users that will be able to access the application. (You don't need to do that for the account that created the application)
- Click the User Management button
- Enter the required information, a name and the email the user's Spotify account has been created with.
- (Optional) You can Request extension if you do not want to register the users by hand.
Importing past history
By default, YourSpotify will only retrieve data for the past 24 hours once registered. This is a technical limitation. However, you can import previous data by two ways.
The import process uses cache to limit requests to the Spotify API. By default, the cache size is unlimited, but you can limit is with the MAX_IMPORT_CACHE_SIZE
env variable in the server.
Supported import methods
Privacy data
Takes a maximum of 5 days. Only gets you the last year of history.
- Request your privacy data at Spotify to have access to your history for the past year here.
- Head to the Settings page and choose the Account data method.
- Input your files starting with
StreamingHistoryX.json
. - Start your import.
Full privacy data (recommended)
Takes a maximum of 30 days. Gets you the whole history since the creation of your account.
- Request your Full privacy data to have access to your history data since the creation of the account here.
- Head to the Settings page and choose the Extended streaming history method.
- Input your files starting with
endsongX.json
. - Start your import.
Troubleshoot
An import can fail:
- If the server reboots.
- If a request fails 10 times in a row.
A failed import can be retried in the Settings page. Be sure to clean your failed imports if you do not want to retry it as it will remove the files used for it.
It is safer to import data at account creation. Though YourSpotify detects duplicates, some may still be inserted.
FAQ
How can I block new registrations?
From an admin account, go to the Settings page and hit the Disable new registrations button.
Songs don't seem to synchronize anymore.
This can happen if you revoked access on your Spotify account. To re-sync the songs, go to settings and hit the Relog to Spotify button.
The web application is telling me it cannot retrieve global preferences.
This means that your web application can't connect to the backend. Check that your API_ENDPOINT env variable is reachable from the device you're using the platform from.
A specific user does not use the application in the same timezone as the server, how can I set a specific timezone for him?
Any user can set his proper timezone in the settings, it will be used for any computed statistics. The timezone of the device will be used for everything else, such as song history.
External guides
- BreadNet installation tutorial
Contributing
If you have any issue or any idea that could make the project better, feel free to open an issue. I'd love to hear about new ideas or bugs you are encountering.
Sponsoring
I work on this project on my spare time and try to fix issues as soon as I can. If you feel generous and think this project and my investment are worth a few cents, you can consider sponsoring it with the button on the right, many thanks.
Top Related Projects
Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk
Python library that makes it easy for data scientists to create charts.
Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.
A client-side JS wrapper for the Spotify Web API
A Node.js wrapper for Spotify's Web API.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot