GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - explodingcamera/subsonic-api: typescript/javascript library for interacting with subsonic-compatible apis

BranchesTags
Open more actions menu

Latest commit

 

History

97 Commits
97 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
biome.json
biome.json
 
 
bun.lock
bun.lock
 
 
package.json
package.json
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Subsonic-API

A lightweight Subsonic and OpenSubsonic client for TypeScript. Supports Node.js, Deno, Bun, and modern browsers.

Features

  • Supports all Subsonic API methods up to version 1.16.1 / Subsonic 6.1.4.
  • Supports OpenSubsonic extensions.
  • Supports both GET and POST requests.
  • Has zero runtime dependencies.

Installation

npm install subsonic-api
# or
bun add subsonic-api
<script type="module">
  import { SubsonicAPI } from "https://esm.sh/subsonic-api";
</script>

Example Usage

import { SubsonicAPI } from "subsonic-api";

const api = new SubsonicAPI({
  url: "https://demo.navidrome.org",
  auth: {
    username: "demo",
    password: "demo",
  },
});

const { randomSongs } = await api.getRandomSongs();
console.log(randomSongs);

API

subsonic-api supports all Subsonic API methods through API version 1.16.1 / Subsonic 6.1.4, along with the currently published OpenSubsonic extensions. All methods return a promise that resolves to the JSON response from the server.

See the JSDoc documentation for a complete list of supported methods and their parameters.

new SubsonicAPI

new SubsonicAPI(config: SubsonicConfig)

Creates a new SubsonicAPI instance.

interface SubsonicConfig {
  // The base URL of the Subsonic server, e.g., https://demo.navidrome.org.
  url: string;

  // The authentication details to use when connecting to the server.
  auth:
    | {
        username: string;
        password: string;
      }
    | {
        // See https://opensubsonic.netlify.app/docs/extensions/apikeyauth/
        apiKey: string;
      };

  // A salt to use when hashing the password. Not used if `auth.apiKey` is provided.
  salt?: string;

  // Whether to reuse generated salts. If not provided,
  // a random salt will be generated for each request.
  // Ignored if `salt` is provided or `auth.apiKey` is used.
  reuseSalt?: boolean;

  // Whether to use POST requests instead of GET requests.
  // Only supported by OpenSubsonic compatible servers with the `formPost` extension.
  post?: boolean;

  // The fetch implementation to use. If not provided, the global fetch will be used.
  fetch?: typeof fetch;

  // The crypto implementation to use. If not provided, the global WebCrypto object
  // or the Node.js crypto module will be used.
  crypto?: Crypto;
}

baseURL

baseURL(): string

Returns the base URL of the server. This is useful when interacting with other APIs exposed by the server.

Media URLs

const coverArtURL = await api.getCoverArtURL({ id: "cover-art-id", size: 512 });
const streamURL = await api.streamURL({ id: "song-id", maxBitRate: 320 });

Returns authenticated GET URLs without making a request. These methods are useful when passing a URL to native image or media components, and they work even when the client is configured with post: true.

The returned URLs contain authentication credentials and should be treated as sensitive.

custom

custom(method: string, params: Params): Promise<Response>

Allows you to make a custom request to the server.

customJSON

customJSON<T>(method: string, params: Params): Promise<T>

Allows you to make a custom request to the server and parse the response as JSON.

About

typescript/javascript library for interacting with subsonic-compatible apis

www.npmjs.com/package/subsonic-api

Topics

airsonicnavidromesubsonic

Resources

Readme
MIT license

Code of conduct

Code of conduct

Security policy

Security policy
Activity

Stars

30 stars

Watchers

1 watching

Forks

7 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.