#Geckoboard-Spotify
A Geckoboard integration using the Spotify API that allows users to monitor data of a Spotify artist. It pulls data from Spotify API and pushes that data to Geckoboard Datasets API at a regular interval.
- Ruby 2.3.1
From the command line:
$ git clone https://github.com/yyl29/geckoboard-spotify.git
$ cd geckoboard-spotify
$ bundle
Create a file .env
in the root directory, then add your Geckoboard API key:
GECKOBOARD_API_KEY='your_api_key'
Configure custom settings in app.rb
. The defaults are set as follows:
ARTIST_ID = "43ZHCT0cAZBISjO8DG9PnE" # Spotify artist id for Elvis Presley
COUNTRY = "GB" # Country code for top tracks
UPDATE_INTERVAL = '10m' # Geckoboard update interval
The artist id can be found in the url address of the artist's Spotify page. E.g. 43ZHCT0cAZBISjO8DG9PnE
for Elvis Presley(https://open.spotify.com/artist/43ZHCT0cAZBISjO8DG9PnE).
The country code is an ISO 3166-1 alpha-2 country code.
The update interval can have units in seconds, minutes, hours, days or weeks(s, m, h, d or w).
To run the app locally, run from the command line:
$ ruby app.rb
This will create a artist dataset (with the number of followers and popularity) and a top_tracks dataset (with top tracks of the artist and popularity of the tracks), you can then go to your dashboard to build some widgets from the datasets!
From the command line:
$ rspec
This app is written in Ruby and uses the Geckoboard Datasets API to integrate with the Spotify API.
Ruby Net::HTTP is used to make HTTP request from Spotify API.
The following Ruby gems are also used:
- dotenv - to store Geckoboard API key
- rufus-scheduler - to schedule Geckoboard datasets update
The app is tested in Rspec. In order to stub external API services, I used the Ruby gem webmock and example json data (downloaded from real HTTP response) to control the responses.
- Include a timestamp field so that data trend can be displayed over time
- Use Spotify OAuth to access more data
- Ability to include more artists