Spotify Activity
Spotify Activity API tracks and displays real-time Spotify music activities, including track details, album covers, and playback status.
Installation
Run the following command to add the package to your project
1. Basic Usage
Add the package to your project and start fetching your Spotify activity.
2. Reference
SpotifyActivity
The main class used to fetch Spotify activities.
Required Information
clientId
: Client ID obtained from the Spotify Developer Dashboard.clientSecret
: Client Secret obtained from the Spotify Developer Dashboard.refreshToken
: Refresh Token obtained through the Spotify OAuth process.
fetchAccessToken()
Fetches a new access token for the Spotify API.
fetchCurrentActivity()
Returns the currently playing Spotify activity. Example output:
3. Using the Data
Data | Description |
---|---|
activity.item.name | Currently playing song title |
activity.item.artists | List of artists performing the song (array) |
activity.item.artists[0].name | First artist's name |
activity.item.album.name | Album name of the song |
activity.item.album.images | List of album cover images (array) |
activity.item.album.images[0].url | URL of the album cover image |
activity.item.external_urls.spotify | Spotify link of the song |
Displaying Song Information
You can display the song name, artist name and album art using the fetched data:
Album Image
FAQ
How to Get a Refresh Token?
To obtain a refresh token, you need to complete the Spotify OAuth process. For details, check the Spotify OAuth Guide.
Is There an API Limit?
Yes, the Spotify API has certain rate limits. For details, check the Spotify API Documentation.