musicxmatch-api
is an npm package that provides easy access to MusixMatch API endpoints. It supports searching tracks, getting track details, lyrics, artists, albums, and more. This package handles the necessary signing and authentication required by MusixMatch.
Time I spent on this project so far
Took me 1 hr 28 mins 56 secs to build this package.
- Fetch lyrics, tracks, albums, and artists
- Automatically fetches app signature from Musixmatch
- Proxy support built-in (currently not used internally)
- Fully typed (TypeScript support)
npm install musixmatch-api
pnpm install musixmatch-api
yarn add musixmatch-api
bun install musixmatch-api
Requires Node.js 16+
Here's how you can use the MusixMatchAPI
class to interact with the MusixMatch API:
import { MusixMatchAPI } from "musicxmatch-api";
const musixMatchAPI = new MusixMatchAPI();
searchTracks(options: { query?: string; track?: string; artist?: string; page: number; }): Promise<SearchTracksResponse>
Search for tracks based on the provided options.
const tracks = await musixMatchAPI.searchTracks({
query: "love",
track: "Shape of You",
artist: "Ed Sheeran",
page: 1,
});
Get track details by track ID or ISRC.
const track = await musixMatchAPI.getTrack("123456");
Get lyrics of a track by track ID or ISRC.
const lyrics = await musixMatchAPI.getTrackLyrics("123456");
Search for artists by name.
const artist = await musixMatchAPI.searchArtist("Queen");
Get artist details by artist ID.
const artist = await musixMatchAPI.getArtist("118");
Get albums of an artist by artist ID.
const albums = await musixMatchAPI.getArtistAlbums("118");
Get album details by album ID.
const album = await musixMatchAPI.getAlbum("32541950");
Get tracks of an album by album ID.
const tracks = await musixMatchAPI.getAlbumTracks("32541950");
getTrackLyricsTranslation(trackId: string, language: string): Promise<GetTrackLyricsTranslationResponse>
Get lyrics translation of a track by track ID and language.
const translation = await musixMatchAPI.getTrackLyricsTranslation("123456", "es");
Make a raw request to any MusixMatch API endpoint.
const response = await musixMatchAPI.rawRequest("track.get?app_id=community-app-v1.0&format=json&track_id=123456");
import { MusixMatchAPI } from "musicxmatch-api";
const musixMatchAPI = new MusixMatchAPI();
async function fetchTrackDetails() {
try {
const track = await musixMatchAPI.getTrack("123456");
console.log(track);
} catch (error) {
console.error("Error fetching track details:", error);
}
}
fetchTrackDetails();
This package is licensed under the MIT License. Feel free to use, modify, and distribute it as per the terms of the license.