Skip to content

andreafspeziale/mxm-api

Repository files navigation

Logo

HTTP client SDK showcase using Undici,
Zod and Pino logger.

Package License Test Status

Important

Artwork inspired by ElysiaJS.

Installation

npm

npm install @andreafspeziale/mxm-api

yarn

yarn add @andreafspeziale/mxm-api

pnpm

pnpm add @andreafspeziale/mxm-api

How to use?

Note

To effectively interact with the Musixmatch API you need a valid API key.

The SDK implements most of the Musixmatch API endpoints, providing a strongly typed and easy-to-use interface for developers. It handles authentication, request construction and response parsing allowing you to focus on building your application.

Zero-config

import { MxmAPI } from '@andreafspeziale/mxm-api';

const mxmAPI = new MxmAPI();

const track = await mxmAPI.trackGet({
  track_isrc: 'USUM72005901',
  apiKey: 'your-api-key',
});

With API key configuration

import { MxmAPI } from '@andreafspeziale/mxm-api';

const mxmAPI = new MxmAPI({
  config: {
    apiKey: 'your-api-key',
  },
});

const track = await mxmAPI.trackGet({
  track_isrc: 'USUM72005901',
});

With API key & Logging configuration

A Pino basic logger instance is created internally when enableLog is set to true.

import { MxmAPI } from '@andreafspeziale/mxm-api';

const mxmAPI = new MxmAPI({
  config: {
    apiKey: 'your-api-key',
    enableLog: true,
    defaultLoggerConfig: {
      formatters: {
        level: (label) => {
          return { level: label };
        },
      },
    },
  },
});

const track = await mxmAPI.trackGet({
  track_isrc: 'USUM72005901',
});

With API key & Pino instance plus Logging configuration

A Pino logger instance is provided and logging can be enabled/disabled via configuration.

import { pino } from 'pino';
import { MxmAPI } from '@andreafspeziale/mxm-api';

const logger = pino({
  formatters: {
    level: (label) => {
      return { level: label };
    },
  },
});

const mxmAPI = new MxmAPI({
  logger,
  config: {
    apiKey: 'your-api-key',
    enableLog: true,
  },
});

const track = await mxmAPI.trackGet({
  track_isrc: 'USUM72005901',
});

Available methods

Test

Note

To keep consistency over time and to be sure each endpoint returns the expected result, e2e tests are run against the actual Musixmatch APIs when a valid API key is provided (environment variable MUSIXMATCH_API_KEY). Instead e2e will be skipped.

  • pnpm test

Stay in touch

License

mxm-api MIT licensed.

About

HTTP client SDK showcase using Undici, Zod and Pino logger

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •