Library
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.
With NPX
npx @spotifly/cli@latest library --token token --type light
With CLI
spotifly library --token token --type light
Options
Flag | (required?) Description |
---|---|
--token [string] | ✅ A Spotify user access token. Requires at least the scope "user-library-read" |
--type [string] | ❌ Output type per track. Either full or light . Default: light |
--genres [boolean] | ❌ Include artist genres for each track. Default: false |
--features [boolean] | ❌ Include audio features for each track. Default: false |
--since [string] | ❌ 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 |
--last [number] | ❌ Only include the last n (most recent) tracks. Default: All tracks |
--compact [boolean] | ❌ Output more compact/minified JSON and save disk space. Default: false |
--out-dir [string] | ❌ Custom relative output directory. Default: Current directory |
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.