# @flazepe/deezer.js

> A simple package to interact with the Deezer API with track decryption support.

Latest version **2.0.8** (published 2025-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @flazepe/deezer.js
pnpm add @flazepe/deezer.js
yarn add @flazepe/deezer.js
bun add @flazepe/deezer.js
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2025-02-18 |
| First published | 2021-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | flazepe |
| Maintainers | flazepe |

## Links

- npm: https://www.npmjs.com/package/@flazepe/deezer.js
- Repository: https://github.com/flazepe/deezer.js
- Homepage: https://github.com/flazepe/deezer.js#readme
- Issues: https://github.com/flazepe/deezer.js/issues
- npm.io page: https://npm.io/package/@flazepe/deezer.js

## Dependencies (1)

- [blowfish-js](https://npm.io/package/blowfish-js.md) ^1.0.0

## Recent versions

- 2.0.8 (latest) — 2025-02-18
- 2.0.7 — 2025-02-13
- 2.0.6 — 2025-02-12
- 2.0.4 — 2025-02-12
- 2.0.3 — 2025-02-11
- 2.0.2 — 2025-02-11
- 2.0.1 — 2025-02-11
- 2.0.0 — 2025-02-11
- 1.1.0 — 2021-09-23
- 1.0.1 — 2021-09-20
- 1.0.0 — 2021-09-20

## README

# deezer.js

A simple package to interact with the Deezer API with track decryption support.

## Examples

### Searching for tracks, albums, artists, and playlists

```js
const { writeFile } = "fs/promises",
	Deezer = require("@flazepe/deezer.js"),
	deezer = new Deezer();

(async () => {
	// Search for tracks
	const tracks = await deezer.search("A track name", "track"); // Or simply `await deezer.search("A track name")`
	if (tracks[0]) console.log(tracks[0]);

	// Search for albums
	const albums = await deezer.search("An album name", "album");
	if (albums[0]) console.log(albums[0]);

	// Search for artists
	const artists = await deezer.search("An artist name", "artist");
	if (artists[0]) console.log(artists[0]);

	// Search for playlists
	const playlists = await deezer.search("A playlist name", "playlist");
	if (playlists[0]) console.log(playlists[0]);
})();
```

### Getting tracks, albums, artists, and playlists

```js
const { writeFile } = "fs/promises",
	Deezer = require("@flazepe/deezer.js"),
	deezer = new Deezer();

(async () => {
	// Get a track by ID
	let entity = await deezer.get("A track ID", "track"); // Or simply `await deezer.get("A track ID")`
	if (entity) console.log(entity.type, entity.info, entity.tracks); // `entity.tracks` would contain exactly 1 track

	// Get an album by ID
	entity = await deezer.get("An album ID", "album");
	if (entity) console.log(entity.type, entity.info, entity.tracks); // `entity.tracks` would contain the album's tracks

	// Get an artist by ID
	entity = await deezer.get("An artist ID", "artist");
	if (entity) console.log(entity.type, entity.info, entity.tracks); // `entity.tracks` would contain the artist's top tracks

	// Get a playlist by ID
	entity = await deezer.get("A playlist ID", "playlist");
	if (entity) console.log(entity.type, entity.info, entity.tracks); // `entity.tracks` would contain the playlist's tracks

	// No need to provide the entity type if you are providing a URL
	entity = await deezer.get("https://www.deezer.com/en/album/428673387");
	if (entity) console.log(entity.type, entity.info, entity.tracks);
})();
```

### Downloading a track

```js
const { writeFile } = "fs/promises",
	Deezer = require("@flazepe/deezer.js"),
	deezer = new Deezer();

(async () => {
	const tracks = await deezer.search("From Under Cover (Caught Up In A Love Song)"),
		track = tracks[0],
		trackBuffer = await deezer.getAndDecryptTrack(track);

	// Save track to a file
	await writeFile(`${track.ART_NAME} - ${track.SNG_TITLE}.mp3`, trackBuffer);
})();
```

### Downloading a track in FLAC (for Deezer Premium accounts only)

Provide the Deezer `arl` cookie to the constructor to authenticate as a Deezer Premium account.

```js
const { writeFile } = "fs/promises",
	Deezer = require("@flazepe/deezer.js"),
	deezer = new Deezer("xxxxxxxxxxxxxxxxxxxx"); // Insert your arl cookie here

(async () => {
	const tracks = await deezer.search("From Under Cover (Caught Up In A Love Song)"),
		track = tracks[0],
		trackBuffer = await deezer.getAndDecryptTrack(track, true); // Set the FLAC parameter to `true`

	// Save track to a file
	await writeFile(`${track.ART_NAME} - ${track.SNG_TITLE}.flac`, trackBuffer);
})();
```

## Links

-   [Documentation](https://flazepe.github.io/deezer.js/)
-   [npm](https://www.npmjs.com/package/@flazepe/deezer.js)

---
_Source: https://npm.io/package/@flazepe/deezer.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
