Swiftpack.co - Package - oliveroneill/Soft


Build Status Platform Swift Package Manager macOS Linux

A Spotify Web API library for Swift. This is to be used with Swift Package Manager and supports Linux, so that it can run in desktop and server-side applications.

This is based on rspotify's implementation.

This is still a work in progress and supports a limited number of calls. See SpotifyClient.swift for the supported calls and some TODOs on what to implement next. Any help is much appreciated.

Linux Support

Linux is now supported in Soft! In future we will remove all the unnecessary CodingKey declarations, once keyEncodingStrategy and keyDecodingStrategy are supported. See the bug report here.


Add this to your Package.swift:

.package(url: "https://github.com/oliveroneill/Soft.git", .upToNextMajor(from: "0.0.6")),


See SpotifyClient.swift for the calls are currently available. There are a number of TODOs in that class for calls that need implementing and I'd appreciate help in completing the implementation.


All methods require user authorization which means you will need to generate an authorization token that indicates that the user has granted permission for your application to perform the given task.

You will need to specify a redirect URL, this URL does not need to lead anywhere and is purely used to retrieve query parameters that Spotify has added.


import Foundation
import Soft

do {
    let oauth = try SpotifyOAuth(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET", redirectURI: URL(string: "http://localhost:8888/callback")!, state: "STATE", scope: "playlist-read-private")

    // Dispatch group is used so that program does not exit until the result
    // is received
    let dispatchGroup = DispatchGroup()
    getToken(oauth: oauth) { result in
        switch result {
        case .success(let token):
            let client = SpotifyClient(tokenInfo: token)
            client.track(trackID: "11dFghVXANMlKmJXsNCbNl") {
        case .failure(let error):
            print("error: \(error)")
    dispatchGroup.notify(queue: DispatchQueue.main) {
} catch {

Running tests on Linux

Use this command to run tests on Linux while on macOS, using Docker:

docker run --rm -v "$(pwd):/pkg" -w "/pkg" swift:latest /bin/bash -c "swift test --build-path ./.build/linux"


Stars: 1
Help us keep the lights on