LrcLib
LRCLIB API client with serialized requests and bounded retries.
class LrcLibLRCLIB API client with serialized requests and bounded retries.
Constructors
constructor
constructor(player: {
version: string;
debug(message: string): void;
})Create an LRCLIB client owned by one Player.
Parameters
| Name | Type | Description |
|---|---|---|
| player | { | Player used to identify requests and publish debug messages. |
Properties
api
api: stringBase API URL.
timeout
timeout: numberRequest timeout in milliseconds.
retryLimit
retryLimit: numberMaximum retry count for rate limits and server errors.
playerreadonly
readonly player: {
version: string;
debug(message: string): void;
}Player used to identify requests and publish debug messages.
Methods
setRequestTimeout
setRequestTimeout(timeout: number): voidSet the request timeout.
Parameters
| Name | Type | Description |
|---|---|---|
| timeout | number | Positive request timeout in milliseconds. |
Returns
void
setRetryLimit
setRetryLimit(limit: number): voidSet the maximum retry count.
Parameters
| Name | Type | Description |
|---|---|---|
| limit | number | Non-negative retry count for rate limits and server errors. |
Returns
void
get
get(params: LrcGetParams): Promise<LrcGetResult>Get lyrics by exact track metadata.
Parameters
| Name | Type | Description |
|---|---|---|
| params | LrcGetParams | Track title, artist, album, and optional duration. |
Returns
Promise<LrcGetResult>
getById
getById(id: number | `${number}`): Promise<LrcGetResult>Get lyrics by LRCLIB record ID.
Parameters
| Name | Type | Description |
|---|---|---|
| id | number | `${number}` | Numeric LRCLIB record ID. |
Returns
Promise<LrcGetResult>
getCached
getCached(params: LrcGetParams): Promise<LrcGetResult>Get cached lyrics by exact track metadata.
Parameters
| Name | Type | Description |
|---|---|---|
| params | LrcGetParams | Track title, artist, album, and optional duration. |
Returns
Promise<LrcGetResult>
search
search(params: LrcSearchParams): Promise<LrcSearchResult[]>Search LRCLIB for matching lyric records.
Parameters
| Name | Type | Description |
|---|---|---|
| params | LrcSearchParams | Free-form query or track and artist metadata. |
Returns
Promise<LrcSearchResult[]>
request
request<Result>(path: string, options: RequestInit = {}): Promise<Result>Send one serialized request to LRCLIB.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | API path, with or without a leading slash. |
| options | RequestInitDefault: {} | Additional fetch options merged with the default GET request. |
Returns
Promise<Result>
Parsed JSON response.