Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including soundcloud-api-client with all npm packages installed. Try it out:

const { ValueViewerSymbol } = require("@runkit/value-viewer"); const SoundCloud = require('soundcloud-api-client'); class SoundCloudCharts { constructor () { const hostname = 'api-v2.soundcloud.com'; const client_id = 'your-client-id'; // paste your client id this.soundcloud = new SoundCloud({ client_id, hostname }); } async show ({ genre, limit }) { const params = { limit, kind: 'top', genre: `soundcloud:genres:${genre}` }; const { collection } = await this.soundcloud.get('/charts', params); const title = "Track viewer"; const HTML = this.getHTML(collection); Object.assign(this, collection, { [ValueViewerSymbol]: { title, HTML } }); return this; } getHTML (collection) { const images = collection.reduce((html, { track }, i) => { const { permalink_url, title, user } = track; const artwork_url = track.artwork_url || user.avatar_url; return ` ${html} <a title="${title}" href="${permalink_url}" target="_blank"> <span class="rank">#${i + 1}</span> <img src="${artwork_url}" /> <span class="title">${title}</span> </a> `; }, ''); return ` <link rel="stylesheet" href="https://guoyunhe.me/demo/flexbin/flexbin.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,900"> <style> .flexbin span { color: white; font-family: 'Roboto', sans-serif; left: 10px; position: absolute; } .flexbin span.rank { font-size: 20px; font-weight: bold; top: 5px; } .flexbin span.title { bottom: 5px; font-size: 12px; } </style> <div class="flexbin flexbin-margin"> ${images} </div> `; } } const charts = new SoundCloudCharts(); await charts.show({ genre: 'techno', limit: 50 });

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

soundcloud-api-client v0.0.9

Dead simple, promise-based Node.js library for interacting with the SoundCloud public API

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free