https://github.com/rocktimsaikia/spotify-mini
Spotify client for nodejs exposing few useful methods
https://github.com/rocktimsaikia/spotify-mini
spotify spotify-api spotify-library spotify-node
Last synced: 2 months ago
JSON representation
Spotify client for nodejs exposing few useful methods
- Host: GitHub
- URL: https://github.com/rocktimsaikia/spotify-mini
- Owner: rocktimsaikia
- License: mit
- Created: 2022-02-27T16:26:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T09:16:46.000Z (3 months ago)
- Last Synced: 2025-04-05T11:53:22.644Z (2 months ago)
- Topics: spotify, spotify-api, spotify-library, spotify-node
- Language: TypeScript
- Homepage: https://npmjs.com/spotify-mini
- Size: 136 KB
- Stars: 51
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spotify-mini

Simple Spotify client for nodejs exposing useful methods
> I was using a basic version of this library on my [website](https://www.rocktimsaikia.dev/) for a long time, which led me to transform it into a fully-fledged module.
## Prerequisite
Make sure to create a `refresh_token` with atleast the following permissions enabled:
1. `user-read-currently-playing`
2. `user-read-recently-played`
3. `user-top-read`> :bulb: You can use [spotify-rtoken-cli](https://github.com/rocktimsaikia/spotify-rtoken-cli) to easily create a `refresh_token` right from your terminal.
## Installation
```sh
# Install with npm
npm install spotify-mini# Install with yarn
yarn add spotify-mini# Install with pnpm
pnpm add spotify-mini
```## Usage
```javascript
import { SpotifyClient } from 'spotify-mini'const spotify = new SpotifyClient({
clientId: '',
clientSecret: '',
refreshToken: ''
})// Get the currently playing track.
const currentlyPlayingTrack = await spotify.getCurrentTrack()console.log(currentlyPlayingTrack)
```Example output:
```javascript
{
isPlaying: true,
title: '',
artist: '',
album: '',
}
```## API
#### getCurrentTrack
Get the currently playing track.
| Options | Type | Description |
| ---------------------- | ------- | --------------------------------------------------------------------------------- |
| `fallbackToLastPlayed` | boolean | Returns the last played track, if there is no ongoing track atm. (default:`true`) |#### getRecentTracks
Get the recently played tracks.
| Options | Type | Description |
| ------- | --------------------- | -------------------------------------------------------------------- |
| `limit` | number (1 <= n <= 50) | Limit the number of recently played tracks to return. (default: `1`) |#### getTopTracks
Get the top tracks of the user.
| Options | Type | Description |
| ----------- | ------------------- | ---------------------------------------------------------------------------- |
| `limit` | number | Limit the number of recently played tracks to return. (Default: `10`) |
| `timeRange` | short, medium, long | Over what time range the top tracks should be calculated. (Default: `short`) |## Related
- [spotify-rtoken-cli](https://github.com/rocktimsaikia/spotify-rtoken-cli) - Generate Spotify `refresh_token` right from terminal
## License
[MIT](./LICENSE) License © [ Rocktim Saikia ](https://github.com/rocktimsaikia) 2025