npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tidalpromise

v0.2.11

Published

Unofficial Node.js TIDAL Promise API

Downloads

19

Readme

TidalPromise

Build Status npm version npm downloads NPM David

About

node.js TIDAL API, with Promises and playlist manipulation support.

Mantainer Lucas Deters

This is a fork of node.js Tidal API by Lucas Vasconcelos

NOTE: Currently not supporting facebook login.

How to use

Run the following:

npm install tidalpromise

Obtain the Tidal token needed to use this API

As well as a TIDAL username and password, the Tidal API needs an API token which is unique to your apps. You can get this token by network-sniffing some application that uses TIDAL Playback feature, like Tidal for Windows, Tidal for Android, or CapTune from Sennheiser.

Obtaining a token from TIDAL for Windows

  • Install Fiddler and start it.
  • In Fiddler, click Tools > Options > Decrypt HTTPS Traffic
  • Install TIDAL for Windows and start it
  • In Fiddler, look for requests to api.tidal.com. Click a request, then on the right, click Inspectors > Headers. Underneath Miscellaneous you'll see X-Tidal-Token. This is a TIDAL Token you can use.

Usage

Simple usage searching and querying a track list

var TidalAPI = require('tidalpromise');

var api = new TidalAPI({
  username: 'your-username-here',
  password: 'your-password-here',
  token: 'your-token-here',
  // Could also be 'LOSSLESS' but this only supported on premium subscriptions
  quality: 'HIGH'
});

Search

api.search({type: 'artists', query: 'Dream Theater', limit: 1}).then( function(data){
  console.log(data.artists);
}).catch(console.log)

api.search({type: 'albums', query: 'Dream Theater', limit: 1}).then( function(data){
  console.log(data.albums);
}).catch(console.log)

api.search({type: 'tracks', query: 'Dream Theater', limit: 1}).then( function(data){
  console.log(data.tracks);
}).catch(console.log)

api.search({type: 'tracks,albums,artists', query: 'Dream Theater', limit: 1}).then( function(data){
  console.log(data.tracks);
  console.log(data.albums);
  console.log(data.artists);
}).catch(console.log)

Track info

api.getTrackInfo({id: 22560696 }).then( function(data){
  console.log(data)
}).catch(console.log)

Streams

api.getStreamURL({id: 22560696}).then( function(data){
  console.log(data)
}).catch(console.log)

api.getVideoStreamURL({id: 25470315}).then( function(data){
  console.log(data)
}).catch(console.log)

Album Art

console.log(api.getArtURL('24f52ab0-e7d6-414d-a650-20a4c686aa57', 1280)) //coverid

Videos

api.getArtistVideos({id: 14670, limit: 2}).then( function(data){
  console.log(data)
}).catch(console.log)

FLAC tags

api.genMetaflacTags({id: 22560696, coverPath: './albumart.jpg', songPath: './song.flac'}).then( function(data){
  console.log(data)
  /* --remove-all-tags --set-tag="ARTIST=Dream Theater" --set-tag="TITLE=Along For The Ride" --set-tag="ALBUM=Dream Theater" --set-tag="TRACKNUMBER=8" --set-tag="COPYRIGHT=2013 Roadrunner Records, Inc." -set-tag="DATE=2013" --import-picture-from="./albumart.jpg" "./song.flac" --add-replay-gain */
}).catch(console.log)

Playlist manipulation (example using async/await for clarity)

// get the id of the current user
let user_id = await api.getMyID();
console.log(user_id);

// query more information about current user
let user = await api.getUser({id: user_id});
console.log(user);

// get all playlists of current user
let result = await api.getPlaylists({id: user_id});
let current_playlists = result.items;
let playlists_resume = current_playlists.map(playlist => playlist.title).filter((value, index) => index < 5);
console.log('listing first 5 playlists of current user: \n',playlists_resume)

// search some musics
let track_results = await api.search({type: 'tracks', query: 'The Beatles', limit: 10});
let beatles_tracks = track_results.tracks.items;
let beatles_tracks_resume = beatles_tracks.map(playlist => playlist.title);
console.log('list of beatles tracks:',beatles_tracks_resume);

// lookup for a specific playlist
let TEST_PLAYLIST = 'Test playlist'
let filtered_playlists = current_playlists.filter( playlist => playlist.title == TEST_PLAYLIST );
let test_playlist = filtered_playlists[0]

// create a new playlist if necessary
if (test_playlist == undefined){
  test_playlist = await api.createPlaylist({title: TEST_PLAYLIST, description: 'Automatically created playlist.'});
  console.log('created a new playlist.')
}
console.log('test playlist uuid is:' + test_playlist.uuid)

// add musics to the beginning of the playlist
result = await api.addPlaylistTracks({playlist: test_playlist, tracks: beatles_tracks, toIndex: 0});
console.log(beatles_tracks.length + ' tracks added to playlist ', result);

// get tracks in the playlist
result = await api.getPlaylistTracks({playlist: test_playlist})
let musics_on_test_playlist = result.items;
let number_of_musics_on_test_playlist = result.totalNumberOfItems;
console.log('Musics on the playlist now : \n',number_of_musics_on_test_playlist);

// we added new music to the beginning. so we can delete old musics from the end.
let number_of_musics_to_keep = beatles_tracks.length;
let number_of_musics_to_delete = number_of_musics_on_test_playlist - number_of_musics_to_keep;
let positions_to_delete = [...Array(number_of_musics_to_delete).keys()].map(v => v+number_of_musics_to_keep);
result = await api.deletePlaylistTracks({playlist: test_playlist, trackPositions: positions_to_delete});
console.log(number_of_musics_to_delete + ' tracks deleted from the playlist');

// get tracks in the playlist again
result = await api.getPlaylistTracks({playlist: test_playlist})
musics_on_test_playlist = result.items;
number_of_musics_on_test_playlist = result.totalNumberOfItems;
console.log('Musics on the playlist now : \n',number_of_musics_on_test_playlist);

result = await api.deletePlaylist(test_playlist);
console.log('Playlist deleted. \n')

Troubleshooting

500 error with 'Ooops, an unexpected error occurred'

Your TIDAL token is likely incorrect.