### Install Jamendo API Client Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Installs the node-jamendo package using npm. This is the first step to using the Jamendo API in your Node.js project. ```bash $ npm install jamendo ``` -------------------------------- ### Configure Jamendo API Client Constructor (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Provides an example of how to configure the Jamendo API client during instantiation. It lists important settings like client_id, protocol, version, debug mode, and SSL certificate handling. ```javascript var jamendo = new Jamendo({ client_id : 'no default', // Specify your client_id // see http://developer.jamendo.com/v3.0#obtain_client_id protocol : 'http', // HTTP protocol to use, http or https version : 'v3.0', // Use the specified API version debug : false // Print the whole response object and body in the console rejectUnauthorized: false // Ignore SSL certificates issues // see TLS options http://nodejs.org/docs/v0.7.8/api/https.html }); ``` -------------------------------- ### Configure Grunt Build and Documentation Tasks Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/Gruntfile.js.html This snippet demonstrates the Grunt configuration for running JSHint on source files and executing a shell command to generate documentation using Doxx. It defines the task registration for default and install workflows. ```javascript module.exports = function(grunt) { grunt.initConfig({ shell: { makeDocs: 'doxx --source . --ignore "public,static,views,templates,node_modules,grunt,config,sandbox,.client" --target public/docs' }, jshint: { options: { curly: true, eqeqeq: true, immed: true, latedef: true, newcap: true, noarg: true, sub: true, undef: true, boss: true, eqnull: true, node: true, es5: true, strict: false }, globals: { jQuery: true }, uses_defaults: [ '_.js', 'lib/*.js' ] } }); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-shell'); grunt.registerTask('default', ['jshint', 'shell:makeDocs']); grunt.registerTask('install', ['jshint', 'shell:makeDocs']); }; ``` -------------------------------- ### GET /tracks/file Source: https://context7.com/vincent/node-jamendo/llms.txt Download the audio file for a specific track, supporting both callback-based binary data and streamable output. ```APIDOC ## GET /tracks/file ### Description Downloads the MP3 audio file for a given track ID. Can be piped directly to a file stream. ### Method GET ### Endpoint /tracks/file ### Parameters #### Query Parameters - **id** (int) - Required - The ID of the track to download. ### Request Example { "id": 245 } ### Response #### Success Response (200) - **binary** (buffer) - Raw MP3 audio data. #### Response Example [Binary MP3 Data] ``` -------------------------------- ### GET /playlists Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Retrieves information about playlists. ```APIDOC ## GET /playlists ### Description Fetches public playlists from the Jamendo platform. ### Method GET ### Endpoint /playlists ### Parameters #### Query Parameters - **parameters** (Object) - Required - A query string object for filtering playlists. ### Request Example { "limit": 10 } ### Response #### Success Response (200) - **results** (Array) - List of playlist objects. #### Response Example { "results": [{"id": "p1", "title": "My Playlist"}] } ``` -------------------------------- ### GET /oauth/authorize Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Initiates the OAuth2 authorization flow to request user permission for application access. ```APIDOC ## GET /oauth/authorize ### Description Redirects the user to the Jamendo authorization page to grant rights to the application. ### Method GET ### Endpoint /oauth/authorize ### Parameters #### Query Parameters - **parameters** (Object) - Required - A query string object containing client_id and other OAuth parameters. ### Request Example { "client_id": "your_client_id", "response_type": "code" } ### Response #### Success Response (200) - **url** (string) - The URL to which the user should be redirected for login. #### Response Example { "url": "https://api.jamendo.com/oauth/authorize?client_id=..." } ``` -------------------------------- ### GET /artists Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Retrieves information about artists. ```APIDOC ## GET /artists ### Description Fetches a list of artists based on provided query parameters. ### Method GET ### Endpoint /artists ### Parameters #### Query Parameters - **parameters** (Object) - Required - A query string object for filtering artists. ### Request Example { "name": "Artist Name" } ### Response #### Success Response (200) - **results** (Array) - List of artist objects. #### Response Example { "results": [{"id": "1", "name": "Artist Name"}] } ``` -------------------------------- ### Autocomplete Search Source: https://context7.com/vincent/node-jamendo/llms.txt Get search suggestions for artists, albums, and tracks based on a provided prefix. ```javascript jamendo.autocomplete({ prefix: 'bot', limit: 5 }, function(error, data) { console.log('Suggestions:', data.results); }); ``` -------------------------------- ### GET /albums Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Retrieves album information from the Jamendo API. ```APIDOC ## GET /albums ### Description Retrieves a list of albums based on provided filters. ### Method GET ### Endpoint /albums ### Parameters #### Query Parameters - **id** (array/string) - Optional - The ID or list of IDs of the albums to retrieve. - **offset** (integer) - Optional - The offset for pagination. - **limit** (integer) - Optional - The number of results to return. ### Request Example jamendo.albums({ id: 33 }, function(error, data) { ... }); ### Response #### Success Response (200) - **results** (array) - List of album objects. #### Response Example { "id": "33", "name": "Simple Exercice", "artist_name": "Both" } ``` -------------------------------- ### GET /albums/musicinfo Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Retrieves music information for specific albums. ```APIDOC ## GET /albums/musicinfo ### Description Retrieves detailed music information for albums. ### Method GET ### Endpoint /albums/musicinfo ### Parameters #### Query Parameters - **parameters** (Object) - Required - A query string object containing filter criteria. ### Request Example { "id": "12345" } ### Response #### Success Response (200) - **data** (Object) - The album music information object. #### Response Example { "id": "12345", "name": "Album Name" } ``` -------------------------------- ### GET /albums Source: https://context7.com/vincent/node-jamendo/llms.txt Retrieve album metadata, including track listings and download links for full albums. ```APIDOC ## GET /albums ### Description Fetch album details such as release date, artist information, and the URL for the ZIP archive. ### Method GET ### Endpoint /albums ### Parameters #### Query Parameters - **id** (array/int) - Optional - One or more album IDs. ### Request Example { "id": 33 } ### Response #### Success Response (200) - **results** (array) - List of album objects. #### Response Example { "results": [ { "id": "33", "name": "Simple Exercice", "zip": "http://storage-new.newjamendo.com/download/a33/mp32/" } ] } ``` -------------------------------- ### Execute API Requests Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Provides methods to perform GET and POST requests to the Jamendo API. These methods handle parameter cleaning, network retries, and callback execution. ```javascript Jamendo.prototype.request = function(path, parameters, callback) { parameters = this.clean_params(path, parameters || {}); var self = this; var r = request({ url: this.base_url + path, method: 'GET', rejectUnauthorized: this.rejectUnauthorized, qs: parameters, json: true }, function(error, response, body){ if (error && !response && self.retry) { return self.request(path, parameters, callback); } if (typeof callback === 'function') { callback(error, body); } }); return r; }; ``` ```javascript Jamendo.prototype.write_request = function(path, parameters, callback) { parameters = parameters || {}; var self = this; var r = request({ url: this.base_url + path, method: 'POST', rejectUnauthorized: this.rejectUnauthorized, form: parameters, json: true }, function(error, response, body){ if (error && !response && self.retry) { return self.write_request(path, parameters, callback); } if (typeof callback === 'function') { if (error || !response) { callback(error, 'network error', null); } else { callback(response.headers.code, response.headers.error_message, response.headers.warnings); } } }); return r; }; ``` -------------------------------- ### GET /tracks Source: https://context7.com/vincent/node-jamendo/llms.txt Retrieve information about one or more tracks from the Jamendo catalog, with support for filtering by ID and date ranges. ```APIDOC ## GET /tracks ### Description Fetch track metadata including artist, album, and duration. Supports filtering by single or multiple IDs and date ranges. ### Method GET ### Endpoint /tracks ### Parameters #### Query Parameters - **id** (array/int) - Optional - One or more track IDs to retrieve. - **datebetween** (array) - Optional - A range of dates to filter tracks by release date. - **limit** (int) - Optional - Number of results to return. ### Request Example { "id": [245, 246], "limit": 20 } ### Response #### Success Response (200) - **results** (array) - List of track objects containing metadata. #### Response Example { "results": [ { "id": "245", "name": "J.E.T. Apostrophe A.I.M.E", "artist_name": "Both" } ] } ``` -------------------------------- ### Initialize and Use Jamendo API Client (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Demonstrates how to initialize the Jamendo API client with settings and make a basic API call to fetch album data. It shows how to handle the response and potential errors. ```javascript var Jamendo = require('jamendo'); var jamendo = new Jamendo({ ... }); jamendo.albums({ id: 33 }, function(error, data){ console.log(data.results[0]); }); ``` -------------------------------- ### Initialize Jamendo Client Source: https://context7.com/vincent/node-jamendo/llms.txt Configures the Jamendo client instance with API credentials and optional settings like protocol, version, and debug mode. ```javascript var Jamendo = require('jamendo'); var jamendo = new Jamendo({ client_id: 'your_client_id', client_secret: 'your_secret', protocol: 'https', version: 'v3.0', debug: false, retry: true, rejectUnauthorized: false }); ``` -------------------------------- ### Jamendo Client Initialization Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Initializes the Jamendo API client with the required client_id and optional configuration settings. ```APIDOC ## Jamendo Constructor ### Description Initializes the Jamendo API client instance. Requires a client_id to authenticate requests. ### Method Constructor ### Parameters #### Request Body - **settings** (Object) - Required - A configuration object containing client_id and optional client_secret, protocol, and version. ### Request Example { "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET" } ### Response Returns an instance of the Jamendo client. ``` -------------------------------- ### Prism Syntax Highlighting Initialization Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.html Initializes Prism.js, a lightweight syntax highlighter. It includes utility functions for cloning objects and arrays, language extension, and DFS traversal. It also sets up the functionality to highlight all code blocks on the page or specific elements. ```javascript (function(){ var e=/\blang(?:uage)?-(?!\\])(\\w+)\\]/i, t=self.Prism={ util:{ type:function(e){ return Object.prototype.toString.call(e).match(/\\[object (\\w+)\\]/)[1] }, clone:function(e){ var n=t.util.type(e); switch(n){ case "Object": var r={}; for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i])); return r; case "Array": return e.slice() } return e } }, languages:{ extend:function(e,n){ var r=t.util.clone(t.languages[e]); for(var i in n)r[i]=n[i]; return r }, insertBefore:function(e,n,r,i){ i=i||t.languages; var s=i[e], o={}; for(var u in s)if(s.hasOwnProperty(u)){ if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]); o[u]=s[u] } return i[e]=o }, DFS:function(e,n){ for(var r in e){ n.call(e,r,e[r]); t.util.type(e)==="Object"&&t.languages.DFS(e[r],n) } } }, highlightAll:function(e,n){ var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'); for(var i=0,s;s=r[i++]) t.highlightElement(s,e===!0,n) }, highlightElement:function(r,i,s){ var o,u,a=r; while(a&&!e.test(a.className))a=a.parentNode; if(a){ o=(a.className.match(e)||["",""])[1]; u=t.languages[o] } if(!u)return; r.className=r.className.replace(e,"").replace(/\s+/g, " ")+" language-"+o; a=r.parentNode; /pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g, " ")+" language-"+o); var f=r.textContent; if(!f)return; f=f.replace(/&/g, "&").replace(//g, ">").replace(/\u00a0/g, " "); var l={element:r,language:o,grammar:u,code:f}; t.hooks.run("before-highlight",l); if(i&&self.Worker){ var c=new Worker(t.filename); c.onmessage=function(e){ l.highlightedCode=n.stringify(JSON.parse(e.data)); l.element.innerHTML=l.highlightedCode; s&&s.call(l.element); t.hooks.run("after-highlight",l) }; c.postMessage(JSON.stringify({language:l.language,code:l.code})) }else{ l.highlightedCode=t.highlight(l.code,l.grammar); l.element.innerHTML=l.highlightedCode; s&&s.call(r); t.hooks.run("after-highlight",l) } }, highlight:function(e,r){ return n.stringify(t.tokenize(e,r)) }, tokenize:function(e,n){ var r=t.Token, i=[e], s=n.rest; if(s){ for(var o in s)n[o]=s[o]; delete n.rest } e:for(var o in n){ if(!n.hasOwnProperty(o)||!n[o])continue; var u=n[o], a=u.inside, f=!!u.lookbehind||0; u=u.pattern||u; for(var l=0;le.length)break e; if(c instanceof r)continue; u.lastIndex=0; var h=u.exec(c); if(h){ f&&(f=h[1].length); var p=h.index-1+f, h=h[0].slice(f), d=h.length, v=p+d, m=c.slice(0,p+1), g=c.slice(v+1), y=[l,1]; m&&y.push(m); var b=new r(o,a?t.tokenize(h,a):h); y.push(b); g&&y.push(g); Array.prototype.splice.apply(i,y) } } } return i }, hooks:{ all:{}, add:function(e,n){ var r=t.hooks.all; r[e]=r[e]||[]; r[e].push(n) }, run:function(e ``` -------------------------------- ### Initialize Jamendo API Client Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html The Jamendo constructor initializes the client with necessary credentials. It requires a client_id and allows optional configuration for debug mode, protocol, and API version. ```javascript var Jamendo = function(settings) { if (!settings || !settings.client_id) { throw 'You must provide a client_id setting'; } this.debug = settings.debug; this.protocol = settings.protocol || 'http'; this.base_url = this.protocol + '://api.jamendo.com/' + (settings.version ? settings.version : 'v3.0'); this.client_id = settings.client_id; this.client_secret = settings.client_secret; this.rejectUnauthorized = settings.rejectUnauthorized || false; this.retry = settings.retry || false; }; module.exports = Jamendo; ``` -------------------------------- ### Initialize Prism Syntax Highlighting Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/Gruntfile.js.html The core Prism engine handles DOM scanning for code blocks and applies syntax highlighting. It supports asynchronous highlighting via Web Workers and provides a hook system for customization. ```javascript (function(){var e=/\blang(?:uage)?-(?!\ )(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}}}})(); ``` -------------------------------- ### Set User as Fan using OAuth2 Token (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Demonstrates how to use an obtained access token to perform write operations, such as setting the user as a fan of an artist. This requires a valid access token. ```javascript jamendo.setuser_fan({ access_token: 'c2839ba71a1e457e51e9c0d0f12345723e92b1865', artist_id: 5 }, function(error, error_message, warnings){ // you are now a fan of the artist Both }); ``` -------------------------------- ### Run Tests (Bash) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Command to execute the test suite for the node-jamendo library. Tests can be run with or without setting an authorization code for write method tests. ```bash $ npm test ``` -------------------------------- ### Fetch User Data Methods Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Methods to retrieve lists of artists, albums, or tracks associated with a user, including support for fan relations. ```javascript Jamendo.prototype.users_artists = function(parameters, callback) { return this.request('/users/artists', parameters, callback); }; Jamendo.prototype.users_albums = function(parameters, callback) { return this.request('/users/albums', parameters, callback); }; Jamendo.prototype.users_tracks = function(parameters, callback) { return this.request('/users/tracks', parameters, callback); }; Jamendo.prototype.users_favorites_artists = function(parameters, callback) { parameters.relation = 'fan'; return this.request('/users/artists', parameters, callback); }; Jamendo.prototype.users_favorites_albums = function(parameters, callback) { parameters.relation = 'fan'; return this.request('/users/albums', parameters, callback); }; Jamendo.prototype.users_favorites_tracks = function(parameters, callback) { parameters.relation = 'fan'; return this.request('/users/tracks', parameters, callback); }; ``` -------------------------------- ### Utilize Automatic Parameter Formatting Source: https://context7.com/vincent/node-jamendo/llms.txt Demonstrates how the library automatically handles parameter serialization, including converting arrays to space-separated strings, normalizing date ranges, and applying default API parameters. ```javascript jamendo.albums({ id: [33, 888] }, callback); jamendo.tracks({ datebetween: [449921044000, '2011-10-10'] }, callback); jamendo.tracks({ datebetween: [new Date('1984-04-04'), '2011-10-10'] }, callback); jamendo.artists({}, callback); ``` -------------------------------- ### User Action Methods Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Methods to perform write operations such as setting a user as a fan, adding to favorites, or liking/disliking tracks. ```javascript Jamendo.prototype.setuser_fan = function(parameters, callback) { return this.write_request('/setuser/fan', parameters, callback); }; Jamendo.prototype.setuser_favorite = function(parameters, callback) { return this.write_request('/setuser/favorite', parameters, callback); }; Jamendo.prototype.setuser_like = function(parameters, callback) { return this.write_request('/setuser/like', parameters, callback); }; ``` -------------------------------- ### Perform Jamendo API Data Queries Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/tests.js.html Demonstrates how to fetch data from various Jamendo API endpoints such as users, concerts, and artists. It shows handling of different parameter types including arrays and date ranges. ```javascript jamendo.users_favorites_artists({ id: 257235 }, function(error, data){ assert(data.results !== 'undefined'); assert(data.results.length === 1); }); jamendo.concerts({ }, function(error, data){ assert(typeof data.results !== 'undefined'); }); jamendo.artists({ id: [ 5, 888 ] }, function(error, data){ assert(typeof data.results !== 'undefined'); }); jamendo.tracks({ datebetween: [ new Date('1984-04-04'), new Date('2011-10-10') ], limit: 10 }, function(error, data){ assert(typeof data.results !== 'undefined'); }); ``` -------------------------------- ### Specify Date Range Parameters (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Explains the syntax sugar for the 'datebetween' parameter. It shows how to use arrays of timestamps or Date objects, which are converted to the API's required string format. ```javascript jamendo.tracks({ datebetween: [ 449921044 * 1000, '2011-10-10' ] }, ... // is the same as jamendo.tracks({ datebetween: [ new Date('1984-04-04'), '2011-10-10' ] }, ... // is the same as jamendo.tracks({ datebetween: '1984-04-04_2011-10-10' ] }, ... // api required syntax ``` -------------------------------- ### Run Grunt Tasks (Bash) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Command to run Grunt tasks, which include linting the JavaScript code (jslint) and building documentation. ```bash $ grunt ``` -------------------------------- ### Manage User Track Interactions Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/tests.js.html Demonstrates how to set a user's favorite status, like, or dislike for a specific track. These methods require an access token and a track ID, utilizing callbacks to handle errors and warnings. ```javascript jamendo.setuser_favorite({ access_token: access_token, track_id: 245 }, function(error, error_message, warnings){ assert.ok(!error, 'Cannot get be fan of track: ' + error_message); }); jamendo.setuser_like({ access_token: access_token, track_id: 245 }, function(error, error_message, warnings){ assert.ok(!error, 'Cannot like track: ' + error_message); }); jamendo.setuser_dislike({ access_token: access_token, track_id: 245 }, function(error, error_message, warnings){ assert.ok(!error, 'Cannot dislike track', error_message); }); ``` -------------------------------- ### Stream Track File using Jamendo API Client (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Shows how to stream a track file directly to a local file using the Jamendo API client. This leverages the streamable nature of the API responses. ```javascript // write the track #245 in mp3 on disk jamendo.tracks_file({ id: 245 }).pipe(fs.createWriteStream('Both - J.E.T. Apostrophe A.I.M.mp3')); ``` -------------------------------- ### Initialize Prism Syntax Highlighting Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html The core Prism IIFE (Immediately Invoked Function Expression) initializes the library, sets up utility functions for object cloning and type checking, and handles the automated highlighting of code blocks on the page. ```javascript (function(){var e=/\blang(?:uage)?-(?!\ )(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\\[object (\w+)\\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}}}})(); ``` -------------------------------- ### Specify List Parameters as Arrays (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Illustrates Jamendo API client's syntax sugar for list parameters. It shows how to pass arrays of IDs, which the library automatically converts to the comma-separated string format required by the API. ```javascript jamendo.albums({ id: [ 33, 888 ] }, ... // is the same as jamendo.albums({ id: '33,888' }, ... // api required syntax ``` -------------------------------- ### Manage Reviews Source: https://context7.com/vincent/node-jamendo/llms.txt Retrieve user-generated reviews for specific tracks or albums. ```javascript jamendo.reviews_albums({ id: 33 }, function(error, data) { console.log('Album reviews:', data.results); }); ``` -------------------------------- ### Define Markup and CSS Language Grammars Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html These snippets demonstrate how to extend Prism's language support by defining regex patterns for markup (HTML) and CSS syntax highlighting. ```javascript Prism.languages.markup={comment:/<!--[\w\W]*?--(>|>)/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]+?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\?.[\w\W])*?\1|\w+))?\s*)*\/?>/gi}}; Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:/@[\w-]+?(\s+[^;{]+)?(?=\s*{|\s*;)/gi,url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\}]*(?=\s*\{)/g}; ``` -------------------------------- ### Default API Parameters (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Highlights the default parameters used by the Jamendo API client for methods like 'artists'. It shows that calling a method with an empty options object uses the library's default values for offset, limit, and format. ```javascript jamendo.artists({ }, ... // is the same as jamendo.artists({ offset: 0, limit: 10, format: 'json' }, ... ``` -------------------------------- ### Manage Playlists and Downloads Source: https://context7.com/vincent/node-jamendo/llms.txt Access user-created playlists and their contents. Includes functionality to stream or download playlist files. ```javascript jamendo.playlists({ limit: 10 }, function(error, data) { console.log('Playlists:', data.results); }); jamendo.playlists_file({ id: 12345 }).pipe(fs.createWriteStream('playlist.m3u')); ``` -------------------------------- ### Retrieve User Profiles and Favorites Source: https://context7.com/vincent/node-jamendo/llms.txt Fetch user profile data, followed artists, and favorite albums or tracks using a user ID. ```javascript jamendo.users({ id: 257235 }, function(error, data) { console.log('User info:', data.results); }); jamendo.users_favorites_artists({ id: 257235 }, function(error, data) { console.log('Favorite artists:', data.results[0].artists); }); ``` -------------------------------- ### Set User Like API Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Allows a user to 'like' a specific track. This action is reflected in user track preferences. ```APIDOC ## POST /setuser/like ### Description Allows a user to like a given track. If the track does not exist, no error is raised, but it will not appear in read requests. ### Method POST ### Endpoint /setuser/like ### Parameters #### Request Body - **parameters** (Object) - Required - A query string object. - **access_token** (String) - Required - The access token for the authenticated user. - **track_id** (Integer) - Required - The ID of the track to like. ### Request Example ```json { "parameters": { "access_token": "YOUR_ACCESS_TOKEN", "track_id": 11223 } } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the success of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Handle OAuth2 Authorization URL (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Demonstrates how to obtain an authorization URL for OAuth2. This URL is used to redirect users to Jamendo for authentication and authorization of your application. ```javascript jamendo.authorize({}, function(error, login_url){ // redirect yourself the user to login_url ... // once your application is accepted, he will be redirected // with an authorization_code, valid for 30 seconds }); ``` -------------------------------- ### Query Albums API Source: https://context7.com/vincent/node-jamendo/llms.txt Retrieves album metadata, track listings, and music information such as tags and genres. ```javascript jamendo.albums({ id: 33 }, function(error, data) { console.log(data.results[0]); }); jamendo.album_tracks({ id: 33 }, function(error, data) { console.log('Album tracks:', data.results); }); jamendo.albums_musicinfo({ id: 33 }, function(error, data) { console.log('Music info:', data.results); }); ``` -------------------------------- ### Autocomplete API Source: https://context7.com/vincent/node-jamendo/llms.txt Search for artists, albums, and tracks with autocomplete suggestions. ```APIDOC ## Autocomplete API Search for artists, albums, and tracks with autocomplete suggestions. ### Get autocomplete suggestions ```javascript jamendo.autocomplete({ prefix: 'bot', limit: 5 }, function(error, data) { console.log('Suggestions:', data.results); }); ``` ``` -------------------------------- ### Set User Fan API Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Allows a user to become a fan of a specific artist. This action updates the user's fan list for the given artist. ```APIDOC ## POST /setuser/fan ### Description Allows a user to become a fan of a specific artist. If the artist does not exist, no error is raised, but the relationship will not be recorded. ### Method POST ### Endpoint /setuser/fan ### Parameters #### Request Body - **parameters** (Object) - Required - A query string object. - **access_token** (String) - Required - The access token for the authenticated user. - **artist_id** (Integer) - Required - The ID of the artist to become a fan of. ### Request Example ```json { "parameters": { "access_token": "YOUR_ACCESS_TOKEN", "artist_id": 12345 } } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the success of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Perform Authenticated User Write Operations Source: https://context7.com/vincent/node-jamendo/llms.txt Executes user-specific actions such as becoming a fan of an artist, adding favorites, or liking/disliking tracks. These methods require a valid access_token obtained via the OAuth2 flow. ```javascript jamendo.setuser_fan({ access_token: 'your_access_token', artist_id: 5 }, function(error, error_message, warnings) { if (error) console.error('Error:', error_message); }); jamendo.setuser_favorite({ access_token: 'your_access_token', track_id: 245 }, function(error, error_message, warnings) { if (error) console.error('Error:', error_message); }); jamendo.setuser_like({ access_token: 'your_access_token', track_id: 245 }, function(error, error_message, warnings) { if (error) console.error('Error:', error_message); }); jamendo.setuser_dislike({ access_token: 'your_access_token', track_id: 245 }, function(error, error_message, warnings) { if (error) console.error('Error:', error_message); }); ``` -------------------------------- ### Prism.js Core Tokenization and Highlighting Logic Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.html This snippet contains the core logic for Prism.js, handling tokenization of code based on language definitions and running hooks for syntax highlighting. It includes event listeners for message passing in web workers and DOMContentLoaded for automatic highlighting. ```javascript var Prism=window.Prism||{manual:!0,disableWorker:!0,util:{encode:function(e){var t=e.replace(/&/g,"&");t=t.replace(//g,">");t=t.replace(/"/g,""");t=t.replace(/'/g,"'");return t},type:function(e){var t="object"==typeof e?e:null;return t&&t.constructor?t.constructor.name:t?"null":typeof e},clone:function(e,t){var r={};for(var n in e)r[n]=e[n];return t&&Prism.util.copy(t,r),r}},languages:{extend:function(e,t){var r=Prism.util.clone(Prism.languages[e]);for(var n in t)r[n]=t[n];return r},insertBefore:function(e,t,r,n){var i=Prism.languages;n=n||i;var s=i[e];if(n==i&&e in n){i[e]=r;for(var o in s)o in i[e]&&delete i[e][o]}else{var u=n[e]={},a=s,l=void 0;for(l in u)a[l]=u[l];for(l in a)l in u||(u[l]=a[l]);n[e]=u}return n[e]},DFS:function e(t,r){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var i=t[n],s=/^.+?$/.test(n);if(s||Object.prototype.toString.call(i)==="[object Array]"){var o=s?n:"\\";o+=s?"("+i+")":"["+i.join(",")+"]";Prism.DFS(i,r);r.push("("+o+")")}}},hooks:{all:{},run:function(e,t){var r=this.all[e];if(!r)return;for(var n=0,i;i=r[n++])i(t)}}},Token:function(e,t){this.type=e;this.content=t},Token.stringify=function(e){if(typeof e==="string")return e;if(Object.prototype.toString.call(e)=== "[object Array]"){for(var r=0;r"+i.content+""}};if(!self.document){self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(Prism.tokenize(i,Prism.languages[r])));self.close()},!1);return}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){Prism.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",Prism.highlightAll)}})(); ``` -------------------------------- ### Download Track Files Source: https://context7.com/vincent/node-jamendo/llms.txt Downloads raw MP3 data for a specific track. Supports both callback-based retrieval and stream piping to the filesystem. ```javascript var fs = require('fs'); jamendo.tracks_file({ id: 245 }, function(error, mp3_data) { if (error) return console.error(error); console.log('Downloaded', mp3_data.length, 'bytes'); }); jamendo.tracks_file({ id: 245 }).pipe(fs.createWriteStream('track-245.mp3')); ``` -------------------------------- ### Jamendo API: Authorize Request Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html The authorize method is a wrapper for the OAuth2 authorize request. It prompts the user to grant specific rights to your application. It requires a client ID and returns the login URL. ```javascript Jamendo.prototype.authorize = function(parameters, callback) { parameters = parameters || {}; parameters.client_id = this.client_id; var self = this; // send authorize request var r = request({ url: this.base_url + '/oauth/authorize', method: 'GET', rejectUnauthorized: this.rejectUnauthorized, qs: parameters }, function(error, response, body){ if (error && !response && self.retry) { if (self.debug) { console.log('network error, retry', error); } return self.authorize(parameters, callback); } // forward the login url callback(null, response.request.href); }); return r; }; ``` -------------------------------- ### Query Artist Information Source: https://context7.com/vincent/node-jamendo/llms.txt Retrieve detailed artist profiles, albums, tracks, music metadata, and geographic locations. These methods require an artist ID to fetch specific data. ```javascript jamendo.artists({ id: 5 }, function(error, data) { console.log(data.results[0]); }); jamendo.artist_albums({ id: 5 }, function(error, data) { console.log('Albums by artist:', data.results); }); jamendo.artist_tracks({ id: 5 }, function(error, data) { console.log('Tracks by artist:', data.results); }); ``` -------------------------------- ### Obtain OAuth2 Access Token (JavaScript) Source: https://github.com/vincent/node-jamendo/blob/master/Readme.md Shows how to exchange an authorization code for an access token and refresh token using the Jamendo API client. This is a crucial step for accessing protected API endpoints. ```javascript jamendo.grant({ code: 'mysupergreatauthcode' }, function(error, oauth_data){ /* oauth_data == { access_token: 'c2839ba71a1e457e51e9c0d0f12345723e92b1865', refresh_token: '46f3fbc0e3fe7627503e3b12345c1e36ca92388b', expires_in: 7200, token_type: 'bearer', scope: 'music' } */ }); ``` -------------------------------- ### Autocomplete Method Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Wrapper for the autocomplete API endpoint to assist in search queries. ```javascript Jamendo.prototype.autocomplete = function(parameters, callback) { return this.request('/autocomplete', parameters, callback); }; ``` -------------------------------- ### Users API Source: https://context7.com/vincent/node-jamendo/llms.txt Retrieve user profile information and their relationships with artists, albums, and tracks. ```APIDOC ## Users API Retrieve user profile information and their relationships with artists, albums, and tracks. ### Get user information ```javascript jamendo.users({ id: 257235 }, function(error, data) { console.log('User info:', data.results); }); ``` ### Get artists a user follows ```javascript jamendo.users_artists({ id: 257235 }, function(error, data) { console.log('User artists:', data.results); }); ``` ### Get user's favorite artists (fan relation) ```javascript jamendo.users_favorites_artists({ id: 257235 }, function(error, data) { console.log('Favorite artists:', data.results[0].artists); }); ``` ### Get user's favorite albums ```javascript jamendo.users_favorites_albums({ id: 257235 }, function(error, data) { console.log('Favorite albums:', data.results); }); ``` ### Get user's favorite tracks ```javascript jamendo.users_favorites_tracks({ id: 257235 }, function(error, data) { console.log('Favorite tracks:', data.results); }); ``` ### Get user's albums and tracks ```javascript jamendo.users_albums({ id: 257235 }, function(error, data) { console.log('User albums:', data.results); }); jamendo.users_tracks({ id: 257235 }, function(error, data) { console.log('User tracks:', data.results); }); ``` ``` -------------------------------- ### Reviews API Source: https://context7.com/vincent/node-jamendo/llms.txt Access user reviews for tracks and albums. ```APIDOC ## Reviews API Access user reviews for tracks and albums. ### Get reviews ```javascript jamendo.reviews({ limit: 10 }, function(error, data) { console.log('Reviews:', data.results); }); ``` ### Get album reviews ```javascript jamendo.reviews_albums({ id: 33 }, function(error, data) { console.log('Album reviews:', data.results); }); ``` ``` -------------------------------- ### Jamendo API: Set User Dislike Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html This method allows users to perform a 'dislike' action on a track, similar to other social web platforms. It takes parameters and a callback function for handling the request. ```javascript Jamendo.prototype.setuser_dislike = function(parameters, callback) { return this.write_request('/setuser/dislike', parameters, callback); }; ``` -------------------------------- ### POST /setuser/dislike Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Allows a user to mark a track as disliked on the Jamendo platform. ```APIDOC ## POST /setuser/dislike ### Description Allows the authenticated user to mark a specific track as 'disliked'. ### Method POST ### Endpoint /setuser/dislike ### Parameters #### Request Body - **parameters** (Object) - Required - A query string object containing track details. ### Request Example { "track_id": "12345" } ### Response #### Success Response (200) - **status** (string) - Confirmation of the dislike action. #### Response Example { "status": "success" } ``` -------------------------------- ### API Endpoint Wrappers Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Convenience methods that wrap the base request function to target specific Jamendo API endpoints like tracks and albums. ```javascript Jamendo.prototype.tracks = function(parameters, callback) { return this.request('/tracks', parameters, callback); }; Jamendo.prototype.albums = function(parameters, callback) { return this.request('/albums', parameters, callback); }; ``` -------------------------------- ### clean_params Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Sanitizes and prepares request parameters according to Jamendo API requirements, including setting defaults for pagination and authentication. ```APIDOC ## Jamendo.prototype.clean_params ### Description Cleans an object of parameters according to Jamendo policy. It automatically injects client_id, sets default limit/offset, and converts arrays to space-separated strings. ### Method Internal Method ### Parameters #### Path Parameters - **path** (String) - Required - The API endpoint path to validate parameters against. #### Request Body - **object** (Object) - Required - The parameters to be cleaned. ### Response Returns a cleaned object containing valid parameters for the Jamendo API. ``` -------------------------------- ### Autocomplete API Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/index.js.html Provides autocomplete suggestions for search queries, useful for implementing search functionality. ```APIDOC ## GET /autocomplete ### Description Provides autocomplete suggestions for search queries. ### Method GET ### Endpoint /autocomplete ### Parameters #### Query Parameters - **parameters** (Object) - Required - A query string object containing search terms and other options. ### Request Example ```json { "parameters": { "query": "search term" } } ``` ### Response #### Success Response (200) - **results** (Array) - A list of autocomplete suggestions. #### Response Example ```json { "results": [ "suggestion 1", "suggestion 2" ] } ``` ``` -------------------------------- ### Authorize and Grant OAuth Access Source: https://github.com/vincent/node-jamendo/blob/master/public/docs/tests.js.html Illustrates the OAuth authorization flow for the Jamendo API. It includes generating a login URL and using an authorization code to obtain access tokens for authenticated requests. ```javascript var test_redirect_uri = 'http://localhost/DAT_CODE'; jamendo.authorize({ redirect_uri: test_redirect_uri }, function(error, login_url){ var authorization_code = process.env.AUTHORIZATION_CODE; if (authorization_code) { jamendo.grant({ redirect_uri: test_redirect_uri, code: authorization_code }, function(error, oauth_data){ assert(typeof oauth_data !== 'undefined'); jamendo.setuser_fan({ access_token: oauth_data.access_token, artist_id: 5 }, function(error, error_message, warnings){ assert.ok(!error); }); }); } }); ``` -------------------------------- ### OAuth2 Authorization Flow Source: https://context7.com/vincent/node-jamendo/llms.txt Initiate the OAuth2 handshake to obtain user permissions for write operations by generating an authorization URL. ```javascript jamendo.authorize({ redirect_uri: 'http://yourapp.com/callback' }, function(error, login_url) { if (error) return; console.log('Direct user to:', login_url); }); ```