Socket
Socket
Sign inDemoInstall

spotify-mini

Package Overview
Dependencies
6
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    spotify-mini

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/rocktimsaikia/spotify-mini/main.yml) ![npm](https://img.shields.io/npm/v/spotify-mini?style=flat-square&color=success&logo=npm)


Version published
Weekly downloads
4
Maintainers
1
Created
Weekly downloads
 

Readme

Source

spotify-mini

GitHub Actions Workflow Status npm

Simple Spotify client for nodejs exposing useful methods

I was using a basic version of this library on my website 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 to easily create a refresh_token right from your terminal.

Installation

# Install with npm
npm install spotify-mini

# Install with yarn
yarn add spotify-mini

# Install with pnpm
pnpm add spotify-mini

Usage

import { SpotifyClient } from 'spotify-mini'

const spotify = new SpotifyClient({
  clientId: '<YOUR-SPOTIFY-CLIENT-ID>',
  clientSecret: '<YOUR-SPOTIFY-CLIENT_SECRET>',
  refreshToken: '<YOUR-SPOTIFY-REFRESH-TOKEN>'
})

// Get the currently playing track.
const currentlyPlayingTrack = await spotify.getCurrentTrack()

console.log(currentlyPlayingTrack)

Example output:

 {
    isPlaying: true,
    title: '<track title>',
    artist: '<artist name>',
    album: '<album name>',
 }

API

getCurrentTrack

Get the currently playing track.

OptionsTypeDescription
fallbackToLastPlayedbooleanReturns the last played track, if there is no ongoing track atm. (default:true)
getRecentTracks

Get the recently played tracks.

OptionsTypeDescription
limitnumber (1 <= n <= 50)Limit the number of recently played tracks to return. (default: 1)
getTopTracks

Get the top tracks of the user.

OptionsTypeDescription
limitnumberLimit the number of recently played tracks to return. (Default: 10)
timeRangeshort, medium, longOver what time range the top tracks should be calculated. (Default: short)

License

MIT License © Rocktim Saikia 2024

Keywords

FAQs

Last updated on 10 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc