1.0.4 • Published 3 years ago

odesli.js v1.0.4

Weekly downloads
15
License
ISC
Repository
github
Last release
3 years ago

odesli.js

Node.js Client to query odesli.co (song.link/album.link) API

v1.0.4

Initial release

Installation

npm install odesli.js --save

Initilise

const Odesli = require('odesli.js');
const odesli = new Odesli();

API Key

An API Key is not needed, however, you will be limited to 10 Requests per minute. Email developers@song.link 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'

Fetch

Use fetch() to fetch a song by a streaming service url:

async/await

// 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

or you can use promises.

// 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
});

Get By Parameters

Use getByParams() to fetch a song by a streaming service type, song/album type, and it's unique ID:

async/await

// 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

or you can use promises.

// 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
});

Get By ID

Use getById() to fetch a song by it's unique ID:

async/await

// // getById(id: string, country?: 2-character code)
let song = await odesli.getByParams('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR');
console.log(song.title);

// output: Bad and Boujee

or you can use promises.

// getByParams(platform: string, type: enum<song|album>, id: string)
odesli.getByParams('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR').then(song => {
console.log(song.title);

// output: Bad and Boujee
});

Odesli API Docs

Check the Odesli's Public API Documentation for more info.