Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
soundcloud.ts
Advanced tools
This is a wrapper for the Soundcloud API that includes typings and various utility functions to make getting tracks, users, and playlists easier! You can also download single tracks, or download tracks in mass programmatically.
npm install soundcloud.ts
Authenticating with your account is optional, but I still recommend it. If you don't authenticate, you won't be able to use private endpoints such as /me
. Soundcloud has closed down their API applications, but you are still able to get your client id and oauth token by inspecting the network traffic.
session
(you can filter by typing session
in the filter box) and click on itaccess_token
) in the Request Payload sectionconst soundcloud = new Soundcloud(process.env.SOUNDCLOUD_CLIENT_ID, process.env.SOUNDCLOUD_OAUTH_TOKEN)
/*Get track v2*/
const track = await soundcloud.tracks.get("succducc/azure")
/*Search tracks v2*/
const tracks = await soundcloud.tracks.search({q: "cool track name"})
/*Get user v2*/
const user = await soundcloud.playlists.get("someone")
/*Search users v2*/
const users = await soundcloud.users.search({q: "cool username"})
/*Get playlist (web scraping)*/
const playlist = await soundcloud.playlists.getAlt("virtual-riot/sets/throwback-ep")
/*Search playlists v2*/
const playlists = await soundcloud.playlists.search({q: "cool playlist name"})
import Soundcloud from "soundcloud.ts"
async function useAPI() {
/*Credentials are optional, client id is manually found if omitted.*/
const soundcloud = new Soundcloud(process.env.SOUNDCLOUD_CLIENT_ID, process.env.SOUNDCLOUD_OAUTH_TOKEN)
/*You can get tracks by URL or ID (which can only be gotten from the API)*/
const track = await soundcloud.tracks.get("https://soundcloud.com/user/mysong")
/*Worth to mention that you can omit the soundcloud.com part.*/
const trackShorthand = await soundcloud.tracks.get("user/mysong")
/*To get the ID with the url of a track/playlist/user, you can use the resolve endpoint.*/
const id = await soundcloud.resolve.get("https://soundcloud.com/user/mysong")
/*You can search for tracks... with nothing?*/
const randomSearch = await soundcloud.tracks.search()
/*But more commonly, you will want to add parameters such as the search query.*/
const search = await soundcloud.tracks.search({q: "artist"})
/*You can also get the super secret token that is used on private tracks. Authentication required,
and only works with your own tracks.*/
const secretToken = await soundcloud.tracks.secretToken("user/mysecretsong")
/*Playlists are largely the same, you can use the get() and search() methods.*/
const playlist = await soundcloud.playlists.get("https://soundcloud.com/user/sets/my-songs")
}
async function useAPI() {
/*Users also have a get() and search() method.*/
const user = await soundcloud.users.get("user")
const userSearch = await soundcloud.users.search({q: "some user"})
/*You can get the followers and following of a user.*/
const following = await soundcloud.users.following("user")
const followers = await soundcloud.users.followers("user")
/*Favorite tracks too.*/
const favorites = await soundcloud.users.favorites("user")
/*The web profiles are the social links that show on the side of a user's profile*/
const socialLinks = await soundcloud.users.webProfiles("user")
/*It's very easy to get all of the comments on a track, or all of the comments by a user.*/
const userComments = await soundcloud.users.comments("user")
const trackComments = await soundcloud.tracks.comments("user/mysong")
/*And you can get a specific comment from its ID (must make an API call to get it).*/
const comment = await soundcloud.comments.get(577904916)
}
async function useAPI() {
/*If downloads aren't enabled, it will download the stream instead of the original file.*/
await soundcloud.util.downloadTrack("user/mysong", "./tracks")
/*You can download multiple tracks by passing them as an array to downloadTracks(). The third
parameter is the limit of tracks to download.*/
const tracks = await soundcloud.tracks.search({q: "cool track"})
await soundcloud.util.downloadTracks(tracks, "./tracks", 10)
/*In addition, there are a bunch of utilities that do the above automatically for convenience.*/
await soundcloud.util.downloadSearch("artist", "./tracks")
await soundcloud.util.downloadFavorites("user", "./tracks")
await soundcloud.util.downloadPlaylist("https://soundcloud.com/user/sets/my-songs", "./tracks")
/*streamTrack() will download the track and will return a stream.Readable automatically.*/
const readableStream = await soundcloud.util.streamTrack("https://soundcloud.com/virtual-riot/emotionalrmx")
}
There are more less commonly used endpoints such as me, apps, and oembed. Refer to the SoundCloud API Documentation for their usage.
export interface SoundcloudTrack {
comment_count: number
full_duration: number
downloadable: boolean
created_at: string
description: string | null
media: {
transcodings: SoundcloudTranscoding[]
}
title: string
publisher_metadata: {
urn: string
contains_music: boolean
id: number
}
duration: number
has_downloads_left: boolean
artwork_url: string
public: boolean
streamable: boolean
tag_list: string
genre: string
id: number
reposts_count: number
state: "processing" | "failed" | "finished"
label_name: string | null
last_modified: string
commentable: boolean
policy: string
visuals: string | null
kind: string
purchase_url: string | null
sharing: "private" | "public"
uri: string
secret_token: string | null
download_count: number
likes_count: number
urn: string
license: SoundcloudLicense
purchase_title: string | null
display_date: string
embeddable_by: "all" | "me" | "none"
release_date: string
user_id: number
monetization_model: string
waveform_url: string
permalink: string
permalink_url: string
user: SoundcloudUser
playback_count: number
}
export interface SoundcloudPlaylist {
duration: number
permalink_url: string
reposts_count: number
genre: string | null
permalink: string
purchase_url: string | null
description: string | null
uri: string
label_name: string | null
tag_list: string
set_type: string
public: boolean
track_count: number
user_id: number
last_modified: string
license: SoundcloudLicense
tracks: SoundcloudTrack[]
id: number
release_date: string | null
display_date: string
sharing: "public" | "private"
secret_token: string | null
created_at: string
likes_count: number
kind: string
title: string
purchase_title: string | null
managed_by_feeds: boolean
artwork_url: string | null
is_album: boolean
user: SoundcloudUser
published_at: string | null
embeddable_by: "all" | "me" | "none"
}
export interface SoundcloudUser {
avatar_url: string
city: string
comments_count: number
country_code: number | null
created_at: string
creator_subscriptions: SoundcloudCreatorSubscription[]
creator_subscription: SoundcloudCreatorSubscription
description: string
followers_count: number
followings_count: number
first_name: string
full_name: string
groups_count: number
id: number
kind: string
last_modified: string
last_name: string
likes_count: number
playlist_likes_count: number
permalink: string
permalink_url: string
playlist_count: number
reposts_count: number | null
track_count: number
uri: string
urn: string
username: string
verified: boolean
visuals: {
urn: string
enabled: boolean
visuals: SoundcloudVisual[]
tracking: null
}
}
export interface SoundCloudComment {
kind: "comment"
id: number
created_at: string
user_id: number
track_id: number
timestamp: number
body: string
uri: string
user: SoundCloudUserMini
self: {
urn: string
}
}
FAQs
Soundcloud API v2 wrapper with typings.
The npm package soundcloud.ts receives a total of 2,011 weekly downloads. As such, soundcloud.ts popularity was classified as popular.
We found that soundcloud.ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.