Skip to content

Final project for Data Harvesting, part of the UC3M's Computational Social Science Master

Notifications You must be signed in to change notification settings

alvarosc99/Spotify-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 

Repository files navigation

Spotify scraper for R

Interacting with the Spotify API

Obtaining the credentials.

The first necessary conditions for obtaining the credentials for using the Spotify Web API is having a valid account for the application.

As a next step, we need to register an app in Spotify for Developers. As you already should have a valid user and password for Spotify, you should log in with that Spotify Account and then click in the create an app button. For a valid app, only a name and a description is necessary (as well as accepting Spotify's developer terms). The purpose of creating this app is obtaining two central things: the client ID and the client secret.

These client ID and the client secret are the credentials needed to obtain the OAth 2.0 token, in order to interact with the API. Again, in the dashboard tab, we find the client ID at the left of the screen; below the name and the description. In order to see the secret, we have to click in show client secret. Finally, the token is obtained via a POST request to the API itself (detailed in the FinalRMD).

The final step is to create two .txt documents outside the folder of the repository, named:

  • client_id.txt (Containing only the Client ID).
  • client_secret.txt (Contaning only the Client secret). They should only include the respective information for each one, and nothing else.

Note: for an easier and quicker access to the API, place these into an easy directory, as you will later need to link them to the .Rmd.

Once this is done, just paste the directories in the chunks in lines 51 and 55, and the 'Spotify scraper.Rmd' will be ready to run, so that you can easily scrape Spotify's information.

Summary

Thus, the process can be summarised in:

  1. Creating a Spotify account.
  2. Loging in in Registering an app in Spotify for Developers.
  3. Obtaining the Client ID and Client secret and storing them in two separate .txt files, in the specified format.
  4. Link these two .txt to the .Rmd document, sepcifying where they're located.
  5. Run the code.

About

Final project for Data Harvesting, part of the UC3M's Computational Social Science Master

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published