spotify-activity-listener
v1.1.2
Published
Poll Last.fm for your most recent Spotify listens.
Downloads
6
Maintainers
Readme
Spotify Activity Listener
Poll Last.fm for your recent Spotify listening data.
Demo
Prerequisite Configuration
- Create a Last.fm account
- Enable API access for your account
- Make note of your API key
- In Spotify, go to
Settings > Last.fm
and selectConnect to Last.fm
Installation
npm i spotify-activity-listener --save
Usage
Full Usage Example (React.js)
- Import the listener:
import SpotifyListener from 'spotify-activity-listener';
// Or
var SpotifyListener = require('spotify-activity-listener');
- Instantiate the listener:
var Listener = new SpotifyListener({
username: 'YOUR_LAST.FM_USERNAME',
key: 'YOUR_LAST.FM_API_KEY',
pollInterval: 5000, // (Milliseconds)
trackCount: 1, // Capped at 50 by Last.fm
callback: (res) => {
// Handle response data here
}
});
- Start listening
Listener.startListening();
- Stop listening (if need be)
Listener.stopListening();
Response Format
[
{
album: "Atrocity Exhibition",
art: "https://lastfm-img2.akamaized.net/i/u/300x300/514bed1643432ccf69854d30e35d24ba.png",
artist: "Danny Brown",
name: "Downward Spiral"
},
{ /* (...) */ },
{ /* (...) */ }
]
Contribute
- Fork it
- Create your branch
- Make some changes
- Commit the changes
- Submit a pull request