Skip to content

Repository files navigation

javascript-ampache

A JS client for the Ampache API.

Installation

npm install javascript-ampache

Usage

Import javascript-ampache module in your project and initialize it with the URL to your server e.g. http://music.com.au

importAmpacheAPIfrom"javascript-ampache";constAPI=newAmpacheAPI({url: "http://pathToYourAmpacheServer",sessionKey: yourSessionAuthKey,});// debug: true - will log the final GET to console// either set the session key at time of instantiation or set/update with:API.setSessionKey(yourSessionAuthKey);letallUsers=API.users();letthisAlbum=API.album({filter: 123});letresults=API.advancedSearch({type: "album",operator: "and",random: 1,limit: 20,rules: [["title",0,"monkey"],// Title contains 'monkey'["myrating",2,4],// Rating is 4 stars],});

Bearer token

You can send the session key in the Authorization: Bearer header instead of the auth query parameter by passing useBearerToken: true when creating the client:

constAPI=newAmpacheAPI({url: "http://pathToYourAmpacheServer",sessionKey: yourSessionAuthKey,useBearerToken: true,});

When using this from a browser, the Ampache server must allow the Authorization header (e.g. via Access-Control-Allow-Headers).

Build

npm run build

About

Javascript JSON API library for Ampache

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages