Private
reqIt searches for a song, artist, album, or playlist
const spotify = new Spotify({
clientID: "clientID",
clientSecret: "clientSecret",
});
const search = await spotify.search({ query: "Never Gonna Give You Up", type: "track", limit: 10 });
console.log(search);
The search function returns the body of the response.
tracks.href A link to the Web API endpoint returning the full result of the request.
tracks.items The requested data.
tracks.limit The maximum number of items in the response (as set in the query or by default).
tracks.next URL to the next page of items. (null if none)
tracks.offset The offset of the items returned (as set in the query or by default).
tracks.previous URL to the previous set of items (null if none)
tracks.total Total
If the type is not track, artist, album or playlist.
If the limit is not between 1 and 50.
It gets the top tracks/artists from the user's account
const spotify = new Spotify({
clientID: "clientID",
clientSecret: "clientSecret",
});
const topTracks = await spotify.top({ type: "tracks", limit: 10, time: "short_term" });
console.log(topTracks);
An array of objects.
album.album_type The type of the album: one of "album", "single", or "compilation".
album.artists The artists of the album. Each artist object includes a link in href to more detailed information about the artist.
album.available_markets The markets in which the album is available: ISO 3166-1 alpha-2 country codes. Note that an album is considered available in a market when at least 1 of its tracks is available in that market.
album.external_urls Known external URLs for this album.
album.href A link to the Web API endpoint providing full details of the album.
album.id The Spotify ID for the album.
album.images The cover art for the album in various sizes, widest first.
album.name The name of the album. In case of an album takedown, the value may be an empty string.
album.release_date The date the album was first released, for example "1981-12-15". Depending on the precision, it might be shown as "1981" or "1981-12".
album.release_date_precision The precision with which release_date value is known: "year", "month", or "day".
album.total_tracks The total number of tracks in the album.
album.type The object type: "album"
album.uri The Spotify URI for the album.
artists The artists who performed the track. Each artist object includes a link in href to more detailed information about the artist.
available_markets The markets in which the track is available: ISO 3166-1 alpha-2 country codes. Note that an album is considered available in a market when at least 1 of its tracks is available in that market.
disc_number The disc number (usually 1 unless the album consists of more than one disc).
duration_ms The track length in milliseconds.
explicit Whether or not the track has explicit lyrics ( true = yes it does; false = no it does not OR unknown).
external_ids Known external IDs for the track.
external_urls Known external URLs for this track.
href A link to the Web API endpoint providing full details of the track.
id The Spotify ID for the track.
is_local Whether or not the track is from a local file.
name The name of the track.
popularity The popularity of the track. The value will be between 0 and 100, with 100 being the most popular. The popularity is calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how recent those plays are.
preview_url A link to a 30 second preview (MP3 format) of the track. Can be null.
track_number The number of the track. If an album has several discs, the track number is the number on the specified disc.
type The object type: "track".
uri The Spotify URI for the track.
If the type is not tracks or artists.
If the time is not short_term, medium_term or long_term.
If the limit is not between 1 and 50.
If the user is not logged in.
If the user has no top tracks/artists.
Generated using TypeDoc
Classdec
Spotify Class, which handles all relevant statistical endpoints from the Spotify API
Param
Spotify client ID
Param
Spotify client secret