listenbrainz-api
v0.3.0
Published
A fully typed, zero-dependency ListenBrainz REST API client for JavaScript/TypeScript.
Maintainers
Readme
listenbrainz-api
A typed, zero-dependency ListenBrainz REST client for Node 18+, Bun, Deno and
other runtimes with fetch. Includes a rate-limited MusicBrainz client.
npm install listenbrainz-apiimport { ListenBrainzClient, createListen } from "listenbrainz-api";
const lb = new ListenBrainzClient({
token: process.env.LISTENBRAINZ_TOKEN,
userAgent: "MyApp/1.0 (https://example.com)",
});
const listens = await lb.getListens("username", { count: 10 });
await lb.submitListen(
process.env.LISTENBRAINZ_TOKEN!,
createListen({
artistName: "Daft Punk",
trackName: "One More Time",
listenedAt: Math.floor(Date.now() / 1000),
}),
);ListenBrainzClient wraps commonly used listens, stats, submission, feedback,
metadata, explore and recommendation endpoints. Every other documented route
is available through client.request<T>({ method, path, query, body, token }).
See the endpoint index and official
ListenBrainz API documentation.
Requests include Authorization: Token ... when a token is configured, send a
descriptive User-Agent, retry rate-limited/server errors, and throw typed
ListenBrainzError exceptions. Tokens are never added to URLs.
Read the practical guides for account setup, listens, stats, writes, discovery, and MusicBrainz. The API guide covers authentication, errors, and raw requests.
bun install
bun run typecheck
bun test
bun run buildLicense: GPL-3.0-only.
