Skip to content

📦 Swift Package for making authenticated requests to SoundCloud public API

License

Notifications You must be signed in to change notification settings

superturboryan/SoundCloud-Swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 SoundCloud

SoundCloud supports iOS, macOS, and watchOS SoundCloud supports Swift Package Manager (SPM)

SoundCloud is a Swift Package that implements the SoundCloud Public API Specification (v1.0.0) .

It handles the logic for authenticating with a SoundCloud account using the OAuth 2.1 standard, including PKCE, and provides an API for streaming audio and accessing track, artist, and playlist data from SoundCloud.

Installation

Add the following line to your project's dependencies in the Package.swift file:

.package(url: "https://github.com/superturboryan/SoundCloud-api"),

and include "SoundCloud" as a dependency for your executable target:

.target(name: "Your App", dependencies: ["SoundCloud", ...]),

Setup

Define a custom URL scheme for your app, you will need to provide a redirect URI using the scheme so that the OAuth web page knows how to open your app when it receives the tokens callback.

The redirect URI used when creating the SoundCloud instance must also be paired with the client ID and client secret for your SoundCloud registered app.

Usage

To login using a SoundCloud account:

import SoundCloud

let config = SoundCloudConfig(clientId: ...)
@StateObject var sc = SoundCloud(config)  
  
...  

    
do {
    try await sc.login()
} catch {
    // Handle login error
}

To get the liked tracks for the authenticated user:

let likedTracks = try await sc.getMyLikedTracks()

Example apps

This package is used by the third-party SoundCloud watchOS app WatchCloud, check it out on the App Store: https://apps.apple.com/us/app/watchcloud/id6466678799 📲

Requirements

SoundCloud requires apps to be registered in order to access their public API. See terms of use