Audius.js
offers a dead simple Javascript client for interacting with the Audius protocol.
This package is early and experimental. You may experience bugs and frequent changes.
Audius.js
currently only works in Node
environments. It will not work in a browser.
Under the hood, audius.js
leverages Audius Libs, a much lower level client, to interact with the network.
Audius.js
currently supports streaming tracks and retrieving track metadata.
Audius.js
is fully documented.
To stream a track, Audius.js
provides an HLS manifest encoded in a data-URL. This URL should be consumable by clients that can stream HLS.
npm install @audius/audius.js
const Audius = require('@audius/audius.js')
// Create a new instance of the Audius client
const audius = new Audius({
/* Give this client a descriptive ID describing this application. */
analyticsId: 'audius_discord_bot'
})
// Return metadata for some track
const trackId = '12345'
try {
const metadata = await audius.getTrackMetadata(trackId)
console.log(metadata.title)
} catch (err) {
...
}
// Return a streamable URL for some track,
// do something fun with it.
try {
const url = await audius.getAudioStreamURL(trackId)
// Pass it off to a Discord client - fun!
discordVoiceConnection.play(url)
} catch (err) {
...
}
Many of the methods accept trackIds
.
TrackIds
may be found by stripping off the trailing digits from an Audius track URL: e.g. "https://audius.co/lido/life-of-peder-part-one-11786" => 11786
Audius.js
uses ESLint to lint as pre-commit hook. ESLint is configured with both StandardJS and Prettier settings.
It's highly recommended to turn on auto-fixes on save in your editor of choice. In VSCode, you can install the ESLint Extension, and then add the following code to your settings.json:
"editor.codeActionsOnSave": {
"source.fixAll": true
},
// Compile the lib in watch mode
npm run start
// Compile the lib once.
npm run build
// Compile docs for the lib.
npm run docs
A descriptive ID representing this particular use of Audius.js.
Metadata for a track on the Audius network.
The description of the track. May be an empty string.
Total favorites count of a track.
The genre of the track.
The mood of the track.
The ID of the uploading user.
The path of the track on the Audius network, e.g. "lido/life-of-peder-part-one"
The date the track was originally released on the Audius network.
Total reposts count of a track.
Tags describing the track.
The title of the track.
The ID of the uploaded track.
The handle of the uploading user.
The name of the uploading user.
Configuration options for
Audius
class constructor.