Skip to main content

Library

npm Codecov

Motivation

This package allows you to easily export your Spotify library to JSON. Each track can be enriched with the genres of its artists and its audio features (Spotify does not assign a genre to each track but rather to most artists, which thereforce act as a proxy).

In order to access your library, you will need an access token from Spotify. You can get one from right here.

CLI Usage

Create your custom command using the query builder below and paste it into your terminal.

Using this command requires authentication. If you have Spotifly configuration file, you can specify a profile to use instead of an access token. If you specify a profile, an access token will be used automatically for you. See the docs about access configuration.


With NPX

npx @spotifly/cli@latest library --type light

With CLI

spotifly library --type light

Flags and Commands

Usage: spotifly library [command?] <...flags>

Commands
help Print this help message

Optional flags
--compact [boolean] Output more compact/minified JSON and save disk space. Default: false
--features [boolean] Include audio features for each track. Default: false
--genres [boolean] Include artist genres for each track. Default: false
--last [number] Only include the last n (most recent) tracks. Default: All tracks
--out-dir [string] Custom relative output directory. Default: Current directory
--profile [string] The Spotifly profile to use for the Spotify API. Default profile: "default"
--since [date] Only include tracks added after this date. The date string must be formatted according to the ECMAScript Date Time String Format, e.g.: "YYYY-MM-DD". Default: All tracks
--token [string] A Spotify user access token. Requires at least the scope "user-library-read"
--type <full|light> Output type per track. Either 'full' or 'light'. Default: 'light'
-h, --help Print this help message

Note that if both --last and --since are set, whatever condition is met first will exhaust the procedure.

Output

A light track has a reduced set of properties:

type TrackLight = {
id: string;
name: string;
album: {
name: string;
id: string;
};
artists: {
id: string;
name: string;
}[];
};

Type full has all track properties as they come from the Spotify API. The next page features an example of both outputs.