Options
All
  • Public
  • Public/Protected
  • All
Menu

Class API

The main API.

To utilize the API, you must create providers. A provider is a class that returns Song objects by fetching a website.

example
import { API, GeniusProvider, AZLyricsProvider } from 'modulyrics';

const api = new API()
    .useProviders([
        // The Genius key is used for searching songs, but it's not required
        new GeniusProvider(process.env.GENIUS_KEY),
        new AZLyricsProvider()
    ]);

// In an async environment
const songs = await api.getSongs('all of me john legend');

Hierarchy

  • API

Index

Constructors

constructor

  • new API(): API

Properties

providers

providers: BaseProvider[] = ...

Methods

getSongs

  • getSongs(query: string): Promise<Song[]>
  • Returns a list of Songs, with lyrics, that match the query. The songs are fetched using the first available provider that returns valid songs.

    memberof

    API

    Parameters

    • query: string

    Returns Promise<Song[]>

usePrivilegedProvider

  • Adds a provider to the start of the list of available providers.

    memberof

    API

    Parameters

    Returns API

usePrivilegedProviders

  • Adds multiple providers to the start of the list of available providers.

    memberof

    API

    Parameters

    Returns API

useProvider

  • Adds a provider to the list of available providers.

    memberof

    API

    Parameters

    Returns API

useProviders

  • Adds multiple providers to the list of available providers.

    memberof

    API

    Parameters

    Returns API

Generated using TypeDoc