Skip to content

audio

The primary audio track of the page as a direct asset:
const { url } = await microlink.audio('https://open.spotify.com/track/3BovdzfaX4jb5KFQwoPfAw')
It resolves to an asset object with url, type, duration, duration_pretty, size, and size_pretty, or null when no audio is detected:
const audio = await microlink.audio('https://open.spotify.com/track/1W2919zs8SBCLTrOB1ftQT')

console.log(audio.type) // 'mp3'
console.log(audio.duration_pretty) // '30s'
It has no method-specific options; the shared options apply. See the audio parameter for the detection details.

Examples

Build a podcast entry with the track and the episode metadata in one request:
const { title, publisher, audio } = await microlink.metadata(episodeUrl, { audio: true })

player.src = audio.url
caption.textContent = `${title}${publisher} (${audio.duration_pretty})`
For every audio element on a page rather than the primary track, use audios.