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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@krishna2206/deezer-api

v1.0.0

Published

TypeScript Deezer API client

Downloads

6

Readme

Deezer API TypeScript Package

A comprehensive TypeScript client for the Deezer API, extracted from the ReFreezer project. This package provides full access to Deezer's music streaming and metadata APIs.

Installation

npm install @krishna2206/deezer-api

Usage

Basic Setup

import DeezerAPI from '@krishna2206/deezer-api';

const deezer = new DeezerAPI({
  language: 'en',
  country: 'US'
});

// Initialize with ARL token
await deezer.initialize('your_arl_token_here');

Search

// Search for music
const results = await deezer.search('Daft Punk');
console.log(results.tracks, results.albums, results.artists, results.playlists);

// Get search suggestions
const suggestions = await deezer.searchSuggestions('Daft');

Tracks

// Get track details
const track = await deezer.track('track_id');

// Add to favorites
await deezer.addFavoriteTrack('track_id');

// Get streaming URL
const { url, encrypted } = await deezer.getTrackUrl(trackData, quality);

Albums

// Get album details
const album = await deezer.album('album_id');

// Get user's favorite albums
const albums = await deezer.getAlbums();

// Add album to favorites
await deezer.addFavoriteAlbum('album_id');

Artists

// Get artist details
const artist = await deezer.artist('artist_id');

// Get artist discography
const discography = await deezer.discographyPage('artist_id');

// Get user's favorite artists
const artists = await deezer.getArtists();

Playlists

// Get playlist
const playlist = await deezer.playlist('playlist_id');

// Create new playlist
const playlistId = await deezer.createPlaylist('My Playlist', 'Description');

// Add track to playlist
await deezer.addToPlaylist('track_id', 'playlist_id');

// Get user's playlists
const playlists = await deezer.getPlaylists();

Discovery

// Get home page
const homePage = await deezer.homePage();

// Get Flow (personalized radio)
const flowTracks = await deezer.flow();

// Get smart radio for artist
const radioTracks = await deezer.smartRadio('artist_id');

// Get mix based on track
const mixTracks = await deezer.playMix('track_id');

URL Parsing

// Parse Deezer URLs
const linkInfo = await deezer.parseLink('https://www.deezer.com/track/123456');
if (linkInfo?.type === 'TRACK') {
  const track = await deezer.track(linkInfo.id!);
}

Downloads

import { TrackQuality } from '@krishna2206/deezer-api';
import fs from 'fs';
import path from 'path';

// Download a single track with progress tracking
const onProgress = (progress) => {
  console.log(`${progress.phase}: ${progress.percentage.toFixed(1)}%`);
  console.log(`Speed: ${progress.downloadSpeed} bytes/s`);
  console.log(`ETA: ${progress.timeRemaining} seconds`);
};

const result = await deezer.downloadTrack(
  'track_id',
  TrackQuality.MP3_320, // or TrackQuality.FLAC, TrackQuality.MP3_128
  onProgress
);

if (result.success) {
  const { audioData, trackData, coverData, filename } = result;
  
  // Handle the raw audio data as needed
  // For example, save to file:
  const filePath = path.join('./downloads', filename);
  fs.writeFileSync(filePath, Buffer.from(audioData));
  
  console.log('Downloaded:', filename);
  console.log('Track data:', trackData.SNG_TITLE);
  console.log('Has cover:', !!coverData);
} else {
  console.error('Download failed:', result.error);
}

// Download album cover
const coverData = await deezer.downloadAlbumCover('md5_hash', 1000);

Download Progress Phases

The download progress callback provides detailed information about each phase:

  • fetching: Getting track metadata from Deezer API
  • downloading: Downloading the encrypted audio file with real-time progress
  • decrypting: Decrypting the audio file (if encrypted)
  • complete: Download finished successfully

Note: The API returns raw audio data, track metadata, and cover data. File saving and metadata addition should be handled by the consuming application for maximum flexibility.

Authentication

You need a valid ARL (Authentication Record Locator) token to use this API. This token can be obtained by logging into Deezer through a web browser and extracting it from the cookies.

Note: This is for educational purposes only. Please respect Deezer's Terms of Service.

License

MIT License - See LICENSE file for details.