Swiftpack.co -  edualm/SwiftyBinance as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
edualm/SwiftyBinance
Binance API for Swift.
.package(url: "https://github.com/edualm/SwiftyBinance.git", from: "v0.2")

SwiftyBinance

Binance API for usage from within Swift.

For now, only a handful of API methods are implemented.

Requirements

iOS 13+ / macOS 10.15+ / watchOS 5+ / tvOS 13+

Installation

This package can be imported using Swift Package Manager.

Example Usage

import SwiftyBinance

let apiKey = "<Your API Key>"
let secretKey = "<Your Secret Key>"

let connection = BinanceConnection(apiKey: apiKey, secretKey: secretKey)

connection.getMinerList { result in
    switch result {
    case .success(let workers):
        workers.forEach {
            let hashRateMHs = $0.hashRate / 1_000_000
            
            print("[\($0.workerName)] Hash Rate: \(hashRateMHs) MH/s")
        }
        
    case .failure(let error):
        print(error)
    }
}

connection.getEarnings { result in
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "dd/MM/yyyy"
    
    switch result {
    case .success(let profits):
        profits.forEach {
            let date = Date(timeIntervalSince1970: TimeInterval($0.time / 1_000))
            let dateStr = dateFormatter.string(from: date)
            
            print("[\(dateStr)] \($0.profitAmount) \($0.coinName)")
        }
        
    case .failure(let error):
        print(error)
    }
}

GitHub

link
Stars: 0
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Version 0.2
4 weeks ago

Added getSymbolPriceTicker API call.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API