{"id":24102156,"url":"https://github.com/rubynixx/spotify_analysis_using_spotipy","last_synced_at":"2025-02-27T20:19:57.628Z","repository":{"id":256466012,"uuid":"854847780","full_name":"RubyNixx/spotify_analysis_using_spotipy","owner":"RubyNixx","description":"Utilising the Spotipy API to visualise personal listening patterns.","archived":false,"fork":false,"pushed_at":"2024-09-10T20:33:30.000Z","size":1492,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T17:43:53.601Z","etag":null,"topics":["data-visualization","spotify","spotipy","spotipy-api","spotipy-library"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubyNixx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T21:55:25.000Z","updated_at":"2024-09-10T20:33:34.000Z","dependencies_parsed_at":"2024-09-10T22:39:07.915Z","dependency_job_id":"73df2ad4-ed95-4097-92a6-7d3fd5fdbb65","html_url":"https://github.com/RubyNixx/spotify_analysis_using_spotipy","commit_stats":null,"previous_names":["rubynixx/spotipy_user_analysis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyNixx%2Fspotify_analysis_using_spotipy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyNixx%2Fspotify_analysis_using_spotipy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyNixx%2Fspotify_analysis_using_spotipy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyNixx%2Fspotify_analysis_using_spotipy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyNixx","download_url":"https://codeload.github.com/RubyNixx/spotify_analysis_using_spotipy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241055819,"owners_count":19901661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","spotify","spotipy","spotipy-api","spotipy-library"],"created_at":"2025-01-10T17:36:17.955Z","updated_at":"2025-02-27T20:19:57.608Z","avatar_url":"https://github.com/RubyNixx.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cb\u003eSpotify Listening Stats\u003c/b\u003e\n\nThis project uses the Spotipy library in Google Colab to analyse personal Spotify listening data and provide headline statistics on listening activity.\n\n\u003cb\u003e\u003ci\u003eFeatures\u003c/i\u003e\u003c/b\u003e\n\n*   Retrieves your top tracks and artists over different time ranges\n*   Calculates average audio features (danceability, energy, etc.) of your most-played tracks\n*   Generates a breakdown of your listening habits by genre\n*   Visualizes listening trends over time\n\n\u003cb\u003e\u003ci\u003ePrerequisites\u003c/i\u003e\u003c/b\u003e\n\n*   Python 3.7+ (I used Google Colab)\n*   A Spotify account\n*   Spotify Developer credentials (Client ID and Client Secret)\n\n\u003cb\u003e\u003ci\u003eSetup\u003c/i\u003e\u003c/b\u003e\n\n1. Clone this repository:\n\n[![Clone](https://img.shields.io/badge/Clone-Repository-blue?style=for-the-badge\u0026logo=github)](https://github.com/RubyNixx/spotify_analysis_using_spotipy.git)\n\n2. Set up your Spotify Developer account:\n\n*    Go to the Spotify Developer Dashboard\n*   Create a new app\n*   Note your Client ID and Client Secret\n*   Add http://localhost:8888/callback as a Redirect URI in your app settings\n\n3. Set environment variables with your Spotify credentials:\n\u003cb\u003eDo not share your API client ID or client secret on Github\u003c/b\u003e\n\nTo handle this, i've used files with enviroment variables (.env) and utilised a .gitignore file to ensure sensitive information isnt included. I've then set and called them as variables within the python code.\n\nCreate a .env file and store in a secure place. See these instructions how to create a .env file:\nhttps://github.com/RubyNixx/spotify_analysis_using_spotipy/blob/main/Steps_to_create_env_file.md\n\n4. Run the main python script in google colab\n\n   [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/RubyNixx/spotify_analysis_using_spotipy/blob/main/spotipy.ipynb)\n\n\n6. On first run, you'll be prompted to authorise the app to access your Spotify data. Follow the link provided to complete the authorisation process.\n\n7. Sample Outputs:\n\n![spotipy2](https://github.com/user-attachments/assets/8346eab9-e412-4d0e-b6ce-4965b254605a)\n\n![spotipy_energy_dist](https://github.com/user-attachments/assets/33499f9f-a689-46ee-bd57-16c4ecf3b629)\n\n![spotipy_top_tracks](https://github.com/user-attachments/assets/a9640325-4d20-43e8-88c3-2862055d246c)\n\n![spotipy_top_50](https://github.com/user-attachments/assets/858d3781-8bef-4655-b4a3-71cf51450308)\n\n![spotipy5](https://github.com/user-attachments/assets/504ff13e-4b02-4827-9078-faa1331af390)\n\n![ShortTermVsLongTerm](https://github.com/user-attachments/assets/d62abd60-93f1-4aea-b6cf-7176c194130e)\n\n![spotipy6](https://github.com/user-attachments/assets/9513dd0c-a987-4cfa-a9e2-747ab8d021db)\n\n![spotipy7](https://github.com/user-attachments/assets/6c5ee392-a052-4cf9-8a52-970098058696)\n\n![spotipy8](https://github.com/user-attachments/assets/623cd09a-9315-47f1-953a-e3d56d06ac32)\n\nThe Spotipy library offers several key features for interacting with the Spotify Web API:\n\n*    Full API access: Spotipy provides access to all endpoints of the Spotify Web API, allowing you to retrieve a wide range of music data\n\n*    User authorisation support: The library supports both the Authorization Code flow and the Client Credentials flow for user authentication\n\n*    Lightweight and easy to use: Spotipy is designed to be a lightweight Python wrapper for the Spotify Web API, making it simple to integrate into your projects\n\n*    Comprehensive data retrieval: You can fetch information about artists, albums, tracks, playlists, user profiles, and more\n\n*    Search functionality: Spotipy allows you to search for items in the Spotify catalog\n\n*    Playlist management: You can create, modify, and delete playlists, as well as add or remove tracks\n\n*    User library interactions: The library enables you to access and modify a user's saved tracks and albums\n\n*    Audio features and analysis: You can retrieve audio features and detailed audio analysis for tracks\n\n*    Personalisation: Spotipy provides access to personalized data such as a user's top artists and tracks\n\n*    Follow/unfollow functionality: You can manage following/unfollowing artists, users, and playlists\n\n*    Browse and recommendations: The library allows you to access Spotify's browse and recommendation features\n\n*    Error handling: Spotipy includes built-in error handling for API requests\n\nMore information can be found here: \n\u003cb\u003eSpotipy API documentation:\u003c/b\u003e\nhttps://spotipy.readthedocs.io/en/2.24.0/\n  Note: This will help with understanding the API \u0026 how to connect to it. I've included a clause in the python code to help work with the API in a google colab notebook.\n\n\u003cb\u003eSpotipy githib repo:\u003c/b\u003e\nhttps://github.com/spotipy-dev/spotipy\n\n\u003cb\u003eSpotipy scopes:\u003c/b\u003e\nhttps://developer.spotify.com/documentation/web-api/concepts/scopes#user-top-read\n\n\u003cb\u003eStack overflow thread that helped with audio features:\u003c/b\u003e\nhttps://stackoverflow.com/questions/38823403/scrape-deep-audio-features-using-spotipy-python-library\n\n\u003cb\u003eExploring features of Spotify playlists - data collection code:\u003c/b\u003e\nhttps://orda.shef.ac.uk/articles/code/Exploring_features_of_Spotify_playlists_data_collection_code/19107998\n\n\u003cb\u003eOther github repo inspiration utilising the API:\u003c/b\u003e\nUsing approaches likes PCA to reduce dimensions of data:\nhttps://stmorse.github.io/journal/spotify-api.html\n\nSome examples of how others have used it:\nhttps://github.com/spotipy-dev/spotipy-examples/blob/main/showcases.ipynb\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubynixx%2Fspotify_analysis_using_spotipy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubynixx%2Fspotify_analysis_using_spotipy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubynixx%2Fspotify_analysis_using_spotipy/lists"}