Coinbase Swift Framework

Over the weekend I released the Coinbase Swift framework I've been building alongside Quids. It is still under heavy development so expect breaking changes!



github "reddavis/Coinbase"



The framework gives you the flexibility of how you store the oAuth credentials. You will need to implement a class that conforms to the CoinbaseAPIClientAuthStore protocol. var isAuthenticated, var hasExpired and func delete() all have default implementations, so you will only need to implement var auth.

The library will handle the refreshing of tokens.

public protocol CoinbaseAPIClientAuthStore: class
    var auth: CoinbaseAPIClient.Auth? { get set }
    var isAuthenticated: Bool { get }
    var hasExpired: Bool { get }

    func delete()

public extension CoinbaseAPIClientAuthStore
    public var isAuthenticated: Bool {
        return self.auth != nil

    public var hasExpired: Bool {
        guard let unwrappedAuth = self.auth else
            return true

        return unwrappedAuth.expiresAt < Date()

    public func delete()
        self.auth = nil


Firstly you need to initialize the auth flow:

let scopes: [CoinbaseAPIClient.Scope] = [

let url = self.coinbaseAPIClient.authorizeURL(scopes: scopes)

Then you need to get the oAuth token:

let redirectURL = URL(string: "quids://coinbase/auth")!

self.coinbaseAPIClient.authenticate(code: code, redirectURL: redirectURL) { (success, error) in
    self.authCompletionHandler?(success, error)


Only a few requests are currently supported, more will be added as we add features to Quids.

public func fetchAccounts(_ completionHandler: @escaping (_ accounts: [Account]?, _ errors: [Error]?) -> Void)
public func fetchTransactions(accountID: String, completionHandler: @escaping (_ transactions: [Transaction]?, _ errors: [Error]?) -> Void)
public func fetchCurrentUser(_ completionHandler: @escaping (_ user: User?, _ errors: [Error]?) -> Void)
public func updateCurrentUser(edits: UserEdits, completionHandler: @escaping (_ user: User?, _ errors: [Error]?) -> Void)
public func createAddress(accountID: String, completionHandler: @escaping (_ address: Address?, _ errors: [Error]?) -> Void)
public func fetchExchangeRates(baseCurrencyCode: String, completionHandler: @escaping (_ exchangeRate: ExchangeRate?, _ errors: [Error]?) -> Void)