Package JavaScript để tương tác với SoundCloud API một cách dễ dàng và hiệu quả.
bun add @manhgdev/soundcloud-web
import SoundCloudAPI from '@manhgdev/soundcloud-web';
const api = new SoundCloudAPI({
clientId: 'YOUR_CLIENT_ID', // Tùy chọn
autoFetchClientId: true // Tự động lấy client ID
});
const result = await api.search.all('skrillex', {
limit: 20,
offset: 0,
facet: 'model',
linked_partitioning: 1
});
const tracks = await api.search.tracks('skrillex', {
limit: 20,
offset: 0,
facet: 'genre',
linked_partitioning: 1
});
const users = await api.search.users('skrillex', {
limit: 20,
offset: 0,
facet: 'place',
linked_partitioning: 1
});
const albums = await api.search.albums('skrillex', {
limit: 20,
offset: 0,
facet: 'genre',
linked_partitioning: 1
});
const playlists = await api.search.playlists('workout', {
limit: 20,
offset: 0,
facet: 'genre',
linked_partitioning: 1
});
const tracks = await api.search.byGenre('electronic', {
limit: 10,
offset: 0,
sort: 'popular',
linked_partitioning: 1
});
const tracks = await api.tracks.getMultiple([956017639, 789012]);
const comments = await api.tracks.getComments(956017639, {
threaded: 0,
limit: 200,
offset: 0,
linked_partitioning: 1
});
const related = await api.tracks.getRelated(956017639, {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const user = await api.users.getUser(856062);
const spotlight = await api.users.getSpotlight(856062, {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const profiles = await api.users.getFeaturedProfiles(856062, {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const likes = await api.users.getLikes(856062, {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const followings = await api.users.getFollowings(856062, {
limit: 3,
offset: 0,
linked_partitioning: 1
});
const artists = await api.users.getRelatedArtists(856062, {
creators_only: false,
page_size: 12,
limit: 12,
offset: 0,
linked_partitioning: 1
});
const comments = await api.users.getComments(856062, {
limit: 20,
offset: 0,
linked_partitioning: 1
});
const stream = await api.users.getStream(856062, {
limit: 20,
offset: 0,
linked_partitioning: 1
});
const topTracks = await api.users.getTopTracks(856062, {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const tracks = await api.users.getTracks(856062, {
limit: 20
});
const playlists = await api.users.getPlaylists(856062, {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const webProfiles = await api.users.getWebProfiles(856062);
const playlist = await api.playlists.getPlaylist(1236491080, {
representation: 'full'
});
const likers = await api.playlists.getLikers(1236491080, {
limit: 9,
offset: 0,
linked_partitioning: 1
});
const reposters = await api.playlists.getReposters(1236491080, {
limit: 9,
offset: 0,
linked_partitioning: 1
});
const playlists = await api.playlists.getByGenre('electronic', {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const playbackUrl = await api.media.getPlaybackUrl(956017639);
const downloadUrl = await api.media.getDownloadUrl(956017639);
const homeContent = await api.discover.getHomeContent({
limit: 10,
offset: 0,
linked_partitioning: 1
});
const recentTracks = await api.discover.getRecentTracks('electronic', {
limit: 10,
offset: 0,
linked_partitioning: 1
});
const countryTracks = await api.discover.getRecentTracksByCountry({
limit: 10,
offset: 0,
linked_partitioning: 1
});
Tất cả các phương thức đều có tham số mặc định phù hợp:
limit
: Số lượng kết quả tối đa (thường là 10-20)offset
: Vị trí bắt đầu (mặc định: 0)linked_partitioning
: Phân trang liên kết (mặc định: 1)facet
: Loại facet cho search (mặc định: 'model', 'genre', 'place')threaded
: Hiển thị theo thread cho comments (mặc định: 0)creators_only
: Chỉ hiển thị người tạo (mặc định: false)page_size
: Kích thước trang (mặc định: 12)representation
: Kiểu biểu diễn (mặc định: 'full')
- Package tự động lấy và cache client ID từ SoundCloud
- Tất cả các request đều có timeout và retry logic
- Hỗ trợ đầy đủ các endpoint của SoundCloud API v2
- Có JSDoc đầy đủ cho tất cả các phương thức
MIT