Node.js Client to query odesli.co (song.link/album.link) API
Initial release
npm install odesli.js --save
const Odesli = require('odesli.js');
const odesli = new Odesli();
An API Key is not needed, however, you will be limited to 10 Requests per minute.
Email [email protected]
to get an API Key.
const odesli = new Odesli({
apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
version: 'vX-beta.X'
});
If no version is supplied, it'll default to 'v1-alpha.1'
Use fetch()
to fetch a song by a streaming service url:
// fetch(url: string, country?: 2-character code)
let song = await odesli.fetch('https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR');
console.log(`${song.title} by ${song.artist[0]}`);
// output: Bad and Boujee by Migos
// fetch(url: string, country?: 2-character code)
odesli.fetch('https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR').then(song => {
console.log(`${song.title} by ${song.artist[0]}`);
// output: Bad and Boujee by Migos
});
Use getByParams()
to fetch a song by a streaming service type, song/album type, and it's unique ID:
// getByParams(platform: string, type: enum<song|album>, id: string, country?: 2-character code)
let song = await odesli.getByParams('spotify', 'song', '4Km5HrUvYTaSUfiSGPJeQR');
console.log(song.artist[0]);
// output: Migos
// getByParams(platform: string, type: enum<song|album>, id: string, country?: 2-character code)
odesli.getByParams('spotify', 'song', '4Km5HrUvYTaSUfiSGPJeQR').then(song => {
console.log(song.artist[0]);
// output: Migos
});
Use getById()
to fetch a song by it's unique ID:
// getById(id: string, country?: 2-character code)
let song = await odesli.getById('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR');
console.log(song.title);
// output: Bad and Boujee
// getById(id: string, country?: 2-character code)
odesli.getById('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR').then(song => {
console.log(song.title);
// output: Bad and Boujee
});
Check the Odesli's Public API Documentation for more info.